Hello, it can be resolved by the below script.
Assume-
ip1 is 192.168.1.100 and it's gateway is 192.168.1.1
ip2 is 9.169.2.100 and it's gateway is 9.169.2.1
At first you have configure both the network (i.e, eth0 and eth1) with proper ip, net mask and gateway also.
*** After configuration of two gateway for two ip your server will become out of network. Do not panic, simple make a script as below written and execute the same. ***
#!/bin/bash
echo 1 T1 >> /etc/iproute2/rt_tables
echo 2 T2 >> /etc/iproute2/rt_tables
IF1= eth0
IF2= eth1
IP1= 192.168.190.100
IP2= 9.169.150.100
GW1=192.168.190.1
GW2=9.169.150.1
GW1_NET=190
GW2_NET=150
ip route add $GW1_NET dev $IF1 src $IP1 table T1
ip route add default via $GW1 table T1
ip route add $GW2_NET dev $IF2 src $IP2 table T2
ip route add default via $GW2 table T2
ip route add $GW1_NET dev $IF1 src $IP1
ip route add $GW2_NET dev $IF2 src $IP2
ip rule add from $IP1 table T1
ip rule add from $IP2 table T2
Assume-
ip1 is 192.168.1.100 and it's gateway is 192.168.1.1
ip2 is 9.169.2.100 and it's gateway is 9.169.2.1
At first you have configure both the network (i.e, eth0 and eth1) with proper ip, net mask and gateway also.
*** After configuration of two gateway for two ip your server will become out of network. Do not panic, simple make a script as below written and execute the same. ***
#!/bin/bash
echo 1 T1 >> /etc/iproute2/rt_tables
echo 2 T2 >> /etc/iproute2/rt_tables
IF1= eth0
IF2= eth1
IP1= 192.168.190.100
IP2= 9.169.150.100
GW1=192.168.190.1
GW2=9.169.150.1
GW1_NET=190
GW2_NET=150
ip route add $GW1_NET dev $IF1 src $IP1 table T1
ip route add default via $GW1 table T1
ip route add $GW2_NET dev $IF2 src $IP2 table T2
ip route add default via $GW2 table T2
ip route add $GW1_NET dev $IF1 src $IP1
ip route add $GW2_NET dev $IF2 src $IP2
ip rule add from $IP1 table T1
ip rule add from $IP2 table T2
No comments:
Post a Comment