Connecting one system to multiple networks
Q. I have a Linux server that connects to the external network and internal. Both network cards have a gateway. How can I set it up, so that it can access both networks?
A. You would need to set up source routing. This can be done fairly easily, following those steps:
Open up /etc/iproute2/rt_tables, add those two at the bottom:
1 first
2 second
Open up /etc/rc.local add the following (before exit 0):
ip route add 192.168.0.0/24 dev eth0 src 192.168.0.15 table first
ip route add default via 192.168.0.1 table first
ip route add 10.1.37.0/24 dev eth1 src 10.1.37.15 table second
ip route add default via 10.1.37.1 table second
ip rule add from 192.168.0.15 table first
ip rule add from 10.1.37.15 table second
Network 1 information:
Gateway: 192.168.0.1
Mask: 255.255.255.0
IP: 192.168.0.15
Network 2 information:
Gateway: 10.1.37.1
Mask: 255.255.255.0
IP: 10.1.37.15
It doesn't really matter if one network is external and the other internal in this setup, you can pick either one and replace the values with your own settings.