1

I have two internal networks (I do not want/have Internet access) where I connect my Ubuntu 14.04 (with eth0 and eth1 network interfaces). From eth0 (network 192.168.0.0) I connect another PC1 directly. Besides from eth1 (network 10.1.1.0) I have another connected PC2 directly. I would like to ping from PC1 to PC2 regardless of the direction, and until now I am unable to succeed.

The current IP configurations are:

- Ubuntu-eth0 has 192.168.0.1
- PC1 has 192.168.0.2
- Ubuntu-eth1 has 10.1.1.1
- PC2 has 10.1.1.2

Ubuntu /etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.0.1
    network 192.168.0.0
    netmask 255.255.255.0
    broadcast 192.168.0.255

auto eth1
iface eth1 inet static
    address 10.1.1.1
    network 10.1.1.0
    netmask 255.255.255.0
    broadcast 10.1.1.255

Ubuntu /etc/sysctl.conf also has:

net.ipv4.ip_forward = 1

This is what is run in the terminal:

~$ sudo iptables -A FORWARD  -i eth0 -o eth1 -j ACCEPT 
~$ sudo iptables -A FORWARD  -i eth1 -o eth0 -j ACCEPT 
~$ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 

With this configuration, I can ping from PC2 -> PC1, but as I enable nat features I cannot ping from PC1 -> PC2 and also PC2 does not have its real IP (as seen through Wireshark in PC1).

How can I do to establish a communication channel without nat features? The result I would like to have is to ping PC1 -> PC2 and PC2 -> PC1 with their real IPs at destination. I have followed many links and tutorials with no success yet.

Thanks in advance.

1

Don't run

sudo iptables -A FORWARD  -i eth0 -o eth1 -j ACCEPT 
sudo iptables -A FORWARD  -i eth1 -o eth0 -j ACCEPT 
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Simply turn on IP forwarding as you have done, with net.ipv4.ip_forward = 1 in /etc/sysctl.conf.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.