Most people have a number of computers and need at NAT device to connect them to the Internet, but in my case I had to solve the opposite problem – I had two internet connections, but just a single computer. With other words: I wanted the computer to be reachable from two different public addresses within two different subnets.
This is the solution:
/etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
# Provider DF
1 DF
# Provider NX
2 NX
3 IN
Then I had to add some files in /etc/sysconfig/network-scripts
In my setup eth2 and eth2:0 are used for internet access:
ifcfg-eth2
DEVICE=eth2
ONBOOT=yes
BOOTPROTO=none
HWADDR=00:0c:29:3d:xx:xx
IPADDR=81.162.157.165
NETMASK=81.162.157.0
# no default gateway
TYPE=Ethernet
ifcfg-eth2:0
DEVICE=eth2:0
ONBOOT=yes
BOOTPROTO=none
HWADDR=00:0c:29:3d:xx:xx
IPADDR=81.162.149.189
NETMASK=255.255.255.240
GATEWAY=81.162.149.177
TYPE=Ethernet
route-eth2
default via 81.162.157.1 table DF
route-eth2:0
default via 81.162.149.177 table NX
rule-eth2
from 81.162.157.165 lookup DF
rule-eth2:0
from 81.162.149.189 lookup NX
That’s it. Of course you have to replace the addresses 81.162.149.189/28 and 81.162.157.165/24 with yours. I used dummy addresses in the examples above. Good luck.
And do not forget to backup before:
cd /source/dir
tar -cf - . | ( cd /destination/dir ; tar -xpvf - )