2 Gateways or Multiple Gateway on a single CentOS box

Scenerio-

eth0- 172.30.0.100 | Gateway- 172.30.0.97

eth1- 192.168.2.247 | Gateway- 192.168.2.1

Need to connect to SIP BOX destination (fictitious)- 202.140.1.1

eth0 has not internet access but it uses the mentioned (172.30.0.97) as gateway to reach 202.140.1.1 server

eth0 has internet access by using 192.168.2.1 gateway.

Here goes the configuration on /etc/sysconfig/network-scripts/ifcfg-eth0

# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth0
BOOTPROTO=static
BROADCAST=172.30.0.103
DHCPCLASS=
HWADDR=08:00:27:E6:A6:62
IPADDR=172.30.0.100
NETMASK=255.255.255.248
NETWORK=172.30.0.96
ONBOOT=yes
ip route add 202.40.1.1/32 via 172.30.0.97

Here goes the configuration on /etc/sysconfig/network-scripts/ifcfg-eth1

# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth1
BOOTPROTO=static
BROADCAST=192.168.2.255
HWADDR=08:00:27:86:40:CD
IPADDR=192.168.2.247
NETMASK=255.255.255.0
NETWORK=192.168.2.0
ONBOOT=yes

Configuration on /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=16426
#GATEWAY=172.30.0.97
GATEWAY=192.168.2.1

Configuration on /etc/resolv.conf (Your DNS Server)-

#nameserver 8.8.8.8
nameserver 114.130.5.5
nameserver 114.130.5.6
Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.