Static routing issues

Issues related to configuring your network
Post Reply
uns3en
Posts: 8
Joined: 2017/09/15 16:19:27

Static routing issues

Post by uns3en » 2018/02/21 12:09:26

Hi guys,

Have a CentOS 6.9 Plesk VM with 2 network interfaces - one for WAN web hosting (2 IPs in the same subnet), other for LAN connection (1 IP on a LAN subnet):

Code: Select all

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0c:29:85:dd:b8 brd ff:ff:ff:ff:ff:ff
    inet xx.xx.xx.138/29 brd xx.xx.xx.143 scope global eth0
    inet xx.xx.xx.139/29 brd xx.xx.xx.143 scope global secondary eth0
    inet6 ffffffffffffffffffffffffffffffff/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0c:29:85:dd:ae brd ff:ff:ff:ff:ff:ff
    inet 172.20.30.138/24 brd 172.20.30.255 scope global eth1
    inet6 ffffffffffffffffffffffffffffffff/64 scope link
       valid_lft forever preferred_lft forever
Right now I have the routes assigned dynamically, as I can't get static routing to work on boot / network restart.

Code: Select all

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
xx.xx.xx.136    *               255.255.255.248 U     0      0        0 eth0
192.168.100.0   172.20.30.2     255.255.255.0   UG    0      0        0 eth1
192.168.98.0    172.20.30.2     255.255.255.0   UG    0      0        0 eth1
192.168.99.0    172.20.30.2     255.255.255.0   UG    0      0        0 eth1
172.20.31.0     172.20.30.2     255.255.255.0   UG    0      0        0 eth1
172.20.30.0     *               255.255.255.0   U     0      0        0 eth1
192.168.95.0    172.20.30.2     255.255.255.0   UG    0      0        0 eth1
link-local      *               255.255.0.0     U     1002   0        0 eth0
link-local      *               255.255.0.0     U     1003   0        0 eth1
default         xx.xx.xx.137    0.0.0.0         UG    0      0        0 eth0

Code: Select all

# ip route
xxx.xx.xx.136/29 dev eth0  proto kernel  scope link  src xx.xx.xx.138
192.168.100.0/24 via 172.20.30.2 dev eth1
192.168.98.0/24 via 172.20.30.2 dev eth1
192.168.99.0/24 via 172.20.30.2 dev eth1
172.20.31.0/24 via 172.20.30.2 dev eth1
172.20.30.0/24 dev eth1  scope link
default via xx.xx.xx.137 dev eth0
As far as I can tell both route-eth0 and route-eth1 have all the correct information on them:

Code: Select all

# cat route-eth0
default via xx.xx.xx.137 dev eth0

Code: Select all

# cat route-eth1
192.168.100.0/24 via 172.20.30.2 dev eth1
192.168.99.0/24 via 172.20.30.2 dev eth1
192.168.98.0/24 via 172.20.30.2 dev eth1
192.168.95.0/24 via 172.20.30.2 dev eth1
172.20.31.0/24 via 172.20.30.2 dev eth1
Interface configs:

Code: Select all

# cat ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:85:DD:B8
TYPE=Ethernet
UUID=0afa1f71-7e3c-4250-9962-23c4f9385ad9
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=xx.xx.xx.138
NETMASK=255.255.255.248
GATEWAY=xx.xx.xx.137

Code: Select all

# cat ifcfg-eth0:1
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=xx.xx.xx.139
NETMASK=255.255.255.248

Code: Select all

# cat ifcfg-eth1
DEVICE=eth1
HWADDR=00:0C:29:85:DD:AE
TYPE=Ethernet
UUID=27810de2-5e98-4ce6-8308-8aef34ecbbfe
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=172.20.30.138
NETMASK=255.255.255.0
GATEWAY=172.20.30.2
Whenever I reboot, the default route switches to eth1 (LAN) and I get no traffic on eth0 (WAN), meaning all the sites on it go down. Even though the machine is rarely rebooted, I'd rather it start with the correct routing settings, than to spend my spending time to fix the broken routing.

route after network restart:

Code: Select all

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
xx.xx.xx.136    *               255.255.255.248 U     0      0        0 eth0
192.168.100.0   172.20.30.2     255.255.255.0   UG    0      0        0 eth1
192.168.98.0    172.20.30.2     255.255.255.0   UG    0      0        0 eth1
192.168.99.0    172.20.30.2     255.255.255.0   UG    0      0        0 eth1
172.20.31.0     172.20.30.2     255.255.255.0   UG    0      0        0 eth1
172.20.30.0     *               255.255.255.0   U     0      0        0 eth1
192.168.95.0    172.20.30.2     255.255.255.0   UG    0      0        0 eth1
link-local      *               255.255.0.0     U     1002   0        0 eth0
link-local      *               255.255.0.0     U     1003   0        0 eth1
default         172.20.30.2     0.0.0.0         UG    0      0        0 eth0
Any idea what I'm missing?

uns3en
Posts: 8
Joined: 2017/09/15 16:19:27

Re: Static routing issues

Post by uns3en » 2018/02/21 14:32:21

Thanks, siXy and TrevorH @ #centos.

The issue was caused by the extra "GATEWAY=" configuration in ifcfg-eth1.

Code: Select all

<TrevorH> UnS3eN: you don't need your route-eth0 file, it's already done by having GATEWAY= in the ifcfg file
<TrevorH> and your problem is that you have GATEWAY= in ifcfg-eth1 too, remove it

Post Reply