Multiple gateways problem

Issues related to configuring your network
Post Reply
senaps
Posts: 1
Joined: 2018/06/18 06:05:44

Multiple gateways problem

Post by senaps » 2018/06/18 06:29:49

Hi all,
i have a system with 4 interfaces. they are all in different subnets. some of these subnets have routes to each other(connected via a router).
now, the problem is i want each interface, act independently and receive/response to requests on the same interface.

i have 4 interfaces:

enp2s0 : 192.168.0.40 - > 255.255.255.0 - > 192.168.0.1 -> Internet Access
enp3s0 : 192.168.50.40 - > 255.255.255.0 - > 192.168.50.1
enp4s0 : 192.168.30.40 - > 255.255.255.0 - > 192.168.30.1
enp4s0 : 192.168.10.40 - > 255.255.255.0 - > 192.168.10.1


subnet 192.168.30.X and 192.168.50.X have routes to each other.

i have three workstations :

system1 : 192.168.30.30
system2 : 192.168.50.30
system3 : 192.168.0.30
=-=-=-=-=-==-=-=-=-=-=-=-=-=-
i have GATEWAY set at each ifcfg file. here is my `ip r l` command output:

Code: Select all

default via 192.168.0.1 dev enp2s0  proto static  metric 100 
default via 192.168.50.1 dev enp3s0  proto static  metric 101 
default via 192.168.30.1 dev enp4s0  proto static  metric 102 
192.168.0.0/24 dev enp2s0  proto kernel  scope link  src 192.168.0.174  metric 100 
192.168.30.0/24 dev enp4s0  proto kernel  scope link  src 192.168.30.40  metric 100 
192.168.50.0/24 dev enp3s0  proto kernel  scope link  src 192.168.50.40  metric 100 
=-=-=-=-=-=-=-=-=-=-=-

i can ping successfully:
ping google.com
ping 192.168.0.30
ping 192.168.30.30
ping 192.168.50.30

from system 2: ping 192.168.30.30
from system 1: ping 192.168.50.30

i can't ping:
ping -I enp3s0 192.168.30.30
ping -I enp4s0 192.168.50.30

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
i have placed a tcpdump on the packets:

tcpdump -i enp3s0 src 192.168.30.30 # i want to see what comes from .30.30 system and where it's getting stuck at. i am pinging from `.50.30` interface the `.30.30` system.

Code: Select all

08:05:46.838726 IP 192.168.30.30 > Saba-HP: ICMP echo reply, id 6194, seq 1, length 64
08:05:47.838196 IP 192.168.30.30 > Saba-HP: ICMP echo reply, id 6194, seq 2, length 64
08:05:48.838083 IP 192.168.30.30 > Saba-HP: ICMP echo reply, id 6194, seq 3, length 64
08:05:49.837869 IP 192.168.30.30 > Saba-HP: ICMP echo reply, id 6194, seq 4, length 64
as you can see, packets are getting in through interface, so routing and everything is happening, but it's messed up at application layer and centos can't decide where to deliver the response packets.

=-=-=-=-==-=-=-=-=-=-=-=-=-=-
i have tried to create route-X files too. but its not doing it neither.

here is what i have in my route-X files:

route-enp3s0:
default via 192.168.50.1 dev enp3s0

route-enp4s0:
default via 192.168.30.1 dev enp4s0

in this case, i have GATEWAY set in enp2s0 as default and all other interfaces have their own route-X file. ( though i have tried with adding route file for enp2s0 and removing GATEWAY from ifcfg-enp2s0 file, i have tried adding GATEWAY to `/etc/sysconfig/network` file too.

this is `ip r l` command output for them:

Code: Select all

default via 192.168.0.1 dev enp2s0  proto static  metric 100 
default via 192.168.0.1 dev enp3s0  proto static  metric 101 
default via 192.168.0.1 dev enp4s0  proto static  metric 102 
192.168.0.0/24 dev enp2s0  proto kernel  scope link  src 192.168.0.174  metric 100 
192.168.0.1 dev enp3s0  proto static  scope link  metric 100 
192.168.0.1 dev enp4s0  proto static  scope link  metric 101 
192.168.30.0/24 dev enp4s0  proto kernel  scope link  src 192.168.30.40  metric 100 
192.168.50.0/24 dev enp3s0  proto kernel  scope link  src 192.168.50.40  metric 100 
above is with GATEWAY=192.168.0.1 in /etc/sysconfig/network file

and here is without that:

Code: Select all

default via 192.168.0.1 dev enp2s0  proto static  metric 100 
192.168.0.0/24 dev enp2s0  proto kernel  scope link  src 192.168.0.174  metric 100 
192.168.30.0/24 dev enp4s0  proto kernel  scope link  src 192.168.30.40  metric 100 
192.168.50.0/24 dev enp3s0  proto kernel  scope link  src 192.168.50.40  metric 100 

where am i doing wrong? what should i do? how would i fix this problem? i have multiple interfaces, i want multiple gateways and and interface responding to all traffic coming through it, independent of where that has come from. it should serve some python applications on different interfaces for different networks.

northpoint
Posts: 80
Joined: 2016/05/23 11:57:12

Re: Multiple gateways problem

Post by northpoint » 2018/06/18 12:24:15

I would think that

enp2s0 : 192.168.0.40 - > 255.255.255.0 - > 192.168.0.1 -> Internet Access

Should be your only default GW. Then just have routes to your other subnets in your routing table.

I had an issue kinda similar in that I had two nics in the server and the default GW would always set to the internal nic after a reboot. So, After some helpful info from members here I fired up nmtui and corrected the issue setting the nic with internet access as the default GW and then also using nat/masq for the others.

Perhaps this is what you want.
Ryzen x1800 * Asus x370 Pro * CentOS 7.4 64bit / Icewarp /

Post Reply