I'll have to setup a few servers with each 2 network interfaces. Since I am new to server configuration and networks, I am currently trying to simulate everything on virtual machines.
Each server will have 2 NICs, eth0 and eth1. All eth0 will be connected to a gateway and through that to the internet. All eth1 will be connected to a private switch. eth0 should be used for all external traffic (internet). All traffic between the servers should go only through each server's eth1 (without using the gateway).
If I understand everything right, I have to define (static) routes. What I don't really get are the netmasks and if I have to setup a route for every server or if I have to define one route with a specific netmask to cover all the eth1 IP addresses.
Let's say:
Server A eth0 has the IP 192.168.1.91 (will be later internet).
Server A eth1 has the IP 192.168.1.92 (local network).
Server B eth0 has the IP 192.168.1.93 (will be later internet).
Server B eth1 has the IP 192.168.1.94 (local network).
Server C eth0 has the IP 192.168.1.95 (will be later internet).
Server C eth1 has the IP 192.168.1.96 (local network).
I've defined a route now on Server A:
route add -net 192.168.1.94 netmask 255.255.255.255 dev eth1
route add -net 192.168.1.96 netmask 255.255.255.255 dev eth1
ip route get 192.168.1.94 results in
192.168.1.94 dev eth1 src 192.168.1.91
ip route get 192.168.1.96 results in
192.168.1.96 dev eth1 src 192.168.1.91
If I understand it right, then packets to 192.168.1.94 (and 96) will now be sent through eth1. But why is the source IP 192.168.1.91, even if this is eth0 and eth1 would be 192.168.1.92? Is there any possibility to to see on Server B, from each IP on Server A a request came? Let's say I make on Server A something like ping 192.168.1.93, can I check then on Server B from which IP that ping request came?
ip route getresults in what I wanted. And I think, I understand now what it means to have separate networks even if it's physically one. – antesoles Feb 23 '17 at 22:21