2

I would like to make a IP route persistent, but it disappears after a reboot or service restart.

here my net conf :

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:ce:1c:48 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.56/16 brd 10.0.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 10.255.255.24/9 brd 10.255.255.255 scope global eth0:23
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fece:1c48/64 scope link
       valid_lft forever preferred_lft forever

cat ifcfg-eth0

ONBOOT=yes
DEVICE=eth0
BOOTPROTO=static
IPADDR=10.0.0.56
NETMASK=255.255.0.0
GATEWAY=10.0.0.1

cat ifcfg-eth0:23

ONBOOT=yes
DEVICE=eth0:23
BOOTPROTO=static
IPADDR=10.255.255.24
CONNECTED_MODE=yes
NETMASK=255.128.0.0
GATEWAY=10.0.0.1

route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth0
10.0.0.0        0.0.0.0         255.255.0.0     U     0      0        0 eth0
10.128.0.0      0.0.0.0         255.128.0.0     U     0      0        0 eth0

When i want ping 10.128.0.1, I can't do it ! On the other hand, when i run this command :

ip r d 10.128.0.0/9 ; ip r a 10.128.0.0/9 via 10.0.0.1

i can ping my other server (10.128.0.1) and my route is corrected.

route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth0
10.0.0.0        0.0.0.0         255.255.0.0     U     0      0        0 eth0
10.128.0.0      10.0.0.1        255.128.0.0     UG    0      0        0 eth0

ping 10.128.0.1

PING 10.128.0.1 (10.128.0.1) 56(84) bytes of data.
64 bytes from 10.128.0.1: icmp_seq=1 ttl=64 time=0.124 ms
64 bytes from 10.128.0.1: icmp_seq=2 ttl=64 time=0.109 ms

Yet I took the care to add the route file in /etc/sysconfig/network-scripts/route-eth0

Like this :

default via 10.0.0.1 dev eth0
10.128.0.0/9 via 10.0.0.1 dev eth0

I don't understand why my route is wrong.

1 Answer 1

1

Check your eth0:23 configuration.

Its address overlaps with 10.128.0.0/9 so it looks to the system as directly connected. That's why the system won't let you add a route through the default gateway!

You can see by route -n that the gateway is 0.0.0.0, which means directly connected, so the line

10.128.0.0/9 via 10.0.0.1 dev eth0

cannot be execute (it probably gives an error in some log file, too).

Obviously, when you explicitly delete the route, then the system lets you add a route via the default gateway as it no more have another route (the directly connected one) in its tables.

To fix this, you have to delete the eth0:23 interface, as 10.128.0.0/9 it's not a connected network and you shouldn't have an IP address on that machine.

7
  • Effectively, but i need IP address 10.255.255.24/9. do you have other suggestions ?
    – BlaST77
    Commented Sep 6, 2018 at 8:06
  • @BlaST77 How can that IP be reached if it's not directly connected? Can you update your question sharing a bit more information on your network setup? Commented Sep 6, 2018 at 8:41
  • it's a virtual machine. VM : 10.0.0.56/16 ; 10.255.255.24/9 Hypervisor : 10.0.0.1/16 ; 10.128.0.1/9 The network 10.0.0.0/16 is connected on a bridge. IP 10.128.0.1 in Hypervisor is the real card
    – BlaST77
    Commented Sep 6, 2018 at 12:27
  • @BlaST77 well, it won't matter if it's virtual or not. If you need to go through 10.0.0.1 to reach the 10.128.0.0/9 network, your machine SHOULD NOT have an address in that network. Commented Sep 6, 2018 at 12:30
  • if I need this VM have the address 10.255.255.24 because this VM is a server and the listening IP is 10.255.255.24. the clients of this server are in the 10.128.0.0/9 network. You understand ?
    – BlaST77
    Commented Sep 6, 2018 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .