I try to route packets between two interfaces of a virtual Ubuntu 16.04 machine hosted in OpenStack. Following what I found on Internet, here is what I did:
# Enable ip forwarding:
sysctl -w net.ipv4.ip_forward=1
echo 'net.ipv4.ip_forward = 1' >> net.ipv4.ip_forward = 1
sysctl -p /etc/sysctl.conf
# Update IP tables:
iptables -A FORWARD -i ens3 -o ens4 -j ACCEPT
iptables -A FORWARD -i ens4 -o ens3 -j ACCEPT
Now, here is my Linux router interfaces and routing table:
ens3: 192.168.217.6/24
ens4: 10.0.0.13/24
ip route
default via 10.0.0.1 dev ens4
10.0.0.0/26 dev ens4 proto kernel scope link src 10.0.0.13
169.254.169.254 via 10.0.0.1 dev ens4
192.168.217.0/24 dev ens3 proto kernel scope link src 192.168.217.6
I have a machine on LAN 10.0.0.0/24, and one on LAN 192.168.217.0/24. Both have my Linux router as their default gateway, but they can't ping each other. However, machine on LAN 10.0.0.0/24 has Internet access:
traceroute 1.1.1.1
10.0.0.1
...
1.1.1.1
ip route
default via 10.0.0.13 dev eth0
10.0.0.0/24 dev eth0 10.0.0.14
This is strange, as the traceoute do not use 10.0.0.13, which is the default gateway of my host.
What am I doing wrong ? Thank you.
ip route
output of the "machine on LAN 10.0.0.0/24" to the question. – wurtel Jun 22 '18 at 10:05sysctl -a|grep net.ipv4.ip_forward
– pawel7318 Jun 22 '18 at 11:57cat /proc/sys/net/ipv4/ip_forwarding
return 1. – Nakrule Jun 22 '18 at 12:16