0

I have a centos7 os with 4 interfaces and 2 gateways, 2 network ranges. one interface has it's own gateway and works, no problem there.

the other 3 interfaces should be using a single gateway, but only one of them is able to see/ping the network.

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=enp2s0
DEVICE=enp2s0
ONBOOT=yes
PROXY_METHOD=none
BROWSER_ONLY=no
IPV6INIT=no
IPADDR=10.8.8.53
NETMASK=255.255.255.192
GATEWAY=10.8.8.3
DNS1=4.2.2.4

and the configs for the other 3 interfaces looks like:

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=enp3s0
DEVICE=enp3s0
ONBOOT=yes
PROXY_METHOD=none
BROWSER_ONLY=no
IPV6INIT=no
IPADDR=10.8.8.200
NETMASK=255.255.255.192
DNS1=4.2.2.4
ip route add 10.8.8.192/26 dev enp3s0 src 10.8.8.200 table rt3
ip route add default via 10.8.8.195 dev $device table rt4
ip rule add from 10.8.8.200/26 table rt3
ip rule add to 10.8.8.200/26 table rt3

device name and ip for other two interfaces are:

enp4s0 => 10.8.8.200
enp5s0 => 10.8.8.201

and here is the ip route show command:

default via 10.8.8.3 dev enp2s0 proto static metric 100
10.8.8.192/25 dev enp2s0 proto kernel scope link src 10.8.8.51 metric 100
10.8.8.192/26 dev enp5s0 proto kernel scope link src 10.8.8.201 metric 103
10.8.8.192/26 dev enp4s0 proto kernel scope link src 10.8.8.200 metric 104
10.8.8.192/26 dev enp3s0 proto kernel scope link src 10.8.8.199 metric 105

I have tried to set the DEFROUTE=no, I have tried to use the same rt name for all interfaces.

I need all interfaces (enp3s0, enp4s0, enp5s0) to be able to have gateway of 10.8.8.195.

senaps
  • 143
  • 1
  • 2
  • 7

1 Answers1

0
ip rule add from 10.8.8.200/26 table rt3

the /26 part is telling the machine that it should be sending out the result in the same netmask as the interface receiving it.

we just edited this part and changed it to /32 so it represents the same interface and ip it received it.

the 255.255.255.255 or /32 means only one host could be assigned and it is the current ip of the machine.

I don't know how or why, but it fixed the problem and my routing is fixed now.

ip rule add from 10.8.8.200/32 table rt3
ip rule add to 10.8.8.200/32 table rt3
senaps
  • 143
  • 1
  • 2
  • 7