Score:0

Networking - How to configure 2 routable IPs on different subnets on one CentOS machine

cn flag

Im trying to setup a Centos machine with 2 different IPs. I want that these IP's are able to communicate with their respective network.

  • ens192 : 10.17.252.254/24

  • ens256 : 10.16.51.131/24

Below is my routing table.

Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 
0.0.0.0 10.17.252.254 0.0.0.0 UG 0 0 0 ens192
10.16.51.0 10.16.51.254 255.255.255.0 UG 0 0 0 ens256 
10.16.51.0 0.0.0.0 255.255.255.0 U 0 0 0 ens256 
10.17.252.0 0.0.0.0 255.255.255.0 U 0 0 0 ens192
ip route show 
default via 10.17.252.254 dev ens192 proto static metric 101
10.16.51.0/24 via 10.16.51.254 dev ens256 
10.16.51.0/24 dev ens256 proto kernel scope link src 10.16.51.131 metric 100 
10.17.252.0/24 dev ens192 proto kernel scope link src 10.17.252.252 metric 101

Thanks

vidarlo avatar
ar flag
What is your problem?
Score:0
nl flag

This line is useless:

10.16.51.0/24 via 10.16.51.254 dev ens256 

You have two interfaces connected to their network no need to use IP routing.

You need to insert route with gateway to reach network not directly connected at layer 2.

You can remove it for the session with:

sudo ip r delete 10.16.51.0/24 via 10.16.51.254 

CentOS should use network manager, digit nmtui and double check the configuration of the interfaces to remove it.

Just for clarification, your server will be able to reach the hosts of the two networks not to forward packets between the two networks but that's not what you asked.

drowzee avatar
cn flag
Thanks for your reply, however by deleting that route nothing will be solved as I tried it. I want to be able to communicate with other hosts on those subnets. Without doing custom routes this is not possible as I already tried with nmtui.
fusillator avatar
nl flag
try to see the configuration of the ports on the switches.. it's not a routing issue. Just confirm if your problem is that the machine with the two interfaces ens256 and ens192 can't ping other hosts on its subnets 10.16.51.0/24 10.17.252.0/24 If so there's no routing involving at all, the server makes an arp request to get the layer 2 destination address and send the bits on the wire. could you provide further details on the network topology routers switches hosts...
fusillator avatar
nl flag
check also the configuration of the interfaces with ethtool
drowzee avatar
cn flag
Hi @fusillator thanks a lot for your reply. I have a vm connected to two vlans, 10.16.51.0 and 10.17.2525.0 where I installed haproxy. On this haproxy I am hosting two floating ips which are on different subnets. 10.16.51.0 & 10.17.252.0. I want the vm to listen on these IP's receive and reply traffic. I read that this could be done by doing 2 rt tables iproute2 but after I tried I couldn't ssh onto them.
fusillator avatar
nl flag
the concept is always the same for virtual networks/virtual machines, there are virtual bridges on the host to simulate the switches... you do not need routing to reach the host on the same virtual bridge. If the problem is you can't reach specific service but you can ping the ip try to set selinux in permissive mode (centos by default enable selinux, right?) and be sure it's not the cause of the block, check the log in /var/log/audit/*
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.