Link to home
Start Free TrialLog in
Avatar of DrDamnit
DrDamnitFlag for United States of America

asked on

ipv4 forwarding not working?

I have an ubuntu box setup with two nics: eth0 and eth1. Eth0 is a public IP. Eth0 is a private (192.168.0.0/29) network. Eth0 has dhcp on it, and distributes addresses just fine. Clients can ping the box from that network.

Clients cannot, however, ping public IP addresses like 207.69.188.185 (Earthlink DNS Servers).

I think I do not have ipv4 forwarding setup properly even though it is set to "1".

What's the problem?
michael@box:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
localnet        *               255.255.255.248 U     0      0        0 eth0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth1
default         2xx.xxx.xxx.xxx   0.0.0.0         UG    100    0        0 eth0

Open in new window

michael@box:~$ sudo sysctl -p
net.ipv4.ip_forward = 1

Open in new window

root@clientbox:/home/fakeuser# ping 207.69.188.185
PING 207.69.188.185 (207.69.188.185) 56(84) bytes of data.

[It does nothing]

Open in new window

root@clientbox:/home/fakeuser# ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=1.38 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=1.35 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=1.35 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=1.34 ms
64 bytes from 192.168.0.1: icmp_seq=5 ttl=64 time=0.185 ms
^C
--- 192.168.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of santoshmotwani
santoshmotwani
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
/etc/init.d/networking restart
Avatar of DrDamnit

ASKER

sudo iptables --table nat --append POSTROUTING --jump MASQUERADE --source 192.168.1.0/24

was the part from step 5 that fixed it.