= configuring routing for a server with two network interfaces =
If your physical server has two or more network interfaces you have to configure routing correctly, if you are running vservers in both networks. Packets must leave on the same interface on which they are received. The following configuration on Debian/Ubuntu /etc/network/interfaces sets up two additional routing tables and two rules to route packets from different subnets through the correct interfaces. <code> # The primary network interface auto eth0 iface eth0 inet static address 10.10.64.16 netmask 255.255.255.0 network 10.10.64.0 broadcast 10.10.64.255 gateway 10.10.64.1 up /bin/ip route add 10.10.64.0/24 dev eth0 src 10.10.64.16 table 64 up /bin/ip route add default via 10.10.64.1 table 64 up /bin/ip rule add from 10.10.64.0/24 table 64 post-down /bin/ip rule delete from 10.10.64.0/24 table 64 auto eth1 iface eth1 inet static address 10.10.68.61 netmask 255.255.255.0 network 10.10.68.0 broadcast 10.10.68.255 up /bin/ip route add 10.10.68.0/24 dev eth1 src 10.10.68.61 table 68 up /bin/ip route add default via 10.10.68.1 table 68 up /bin/ip rule add from 10.10.68.0/24 table 68 post-down /bin/ip rule delete from 10.10.68.0/24 table 68 </code> |