How to add 2 default gateway on RHEL or SLES server


#1

Hi Team,

We have a SLES11 SP4 server which is access from outside and internal. So, We have to add 2 default gateway.

If we set 10.30.4.1 default gateway then only internal employee is able to access the server & If we set 172.19.1.1 default gateway then only outsider is able to access the server.

I am doing some changes on server but still not able to access server internally & outsider. Please check below steps :

########################################################
echo “1 admin” >> /etc/iproute2/rt_tables
echo “2 users” >> /etc/iproute2/rt_tables
ip rule add from 192.168.122.40/32 dev eth0 table admin
ip rule add from 192.168.123.41/32 dev eth1 table users
ip route add default via 192.168.122.1 dev eth0 table admin
ip route add default via 192.168.123.1 dev eth1 table users ########################################################
Also, Check attached screenshot. Please help me

Thanks & Regards,
Rajesh Kathar


#2

@rajeshkathar

After seeing your post i got that you have two interfaces: br0 and br1.

br0 - > inet addr:10.30.4.114 Gateway:10.30.4.1
br1 - > inet addr:172.19.1.145 Gateway:172.19.1.1

this is your requirement and also you configured two routing tables, admin and users to be used for packets sent to or from these NICs in /etc/iproute2/rt_tables.

#vim /etc/iproute2/rt_tables

0       unspec
#
# local
#
#1      inr.ruhep


1 admin
2 users

Now set up the routing rules to route incoming and outgoing packets via these tables:

ip route add 10.30.0.0/24 dev br0 src 10.30.4.114 table users

ip route add default via 10.30.4.1 dev br0 table users

Above command says that the network, 10.30.0.0/24, can be reached through the br0 interface and the second command sets the default gateway.

ip rule add from 10.30.4.114/32 table users

ip rule add to 10.30.4.114/32 table users

Above rules say that both traffic from the IP address, 10.30.4.114, as well as traffic directed to or through this IP address, should use the users routing table.

You can follow the same procedure for remaining networks and try to do telnet in some cases ping will not work

and also send me the output of below command

#ip route list table uers

#ip rule show

I hope this will work and also look at the below link

http://www.novell.com/support/kb/doc.php?id=7000318