1

I've been trying to configure IPTABLES in my server so I can share the internet from the server with another machine. The server IP is 192.168.10.1 (eth0), the connection is coming from 192.168.0.6 (eth0:2), the client is 192.168.10.10 (eth1 in the machine). I've tried using the commands from

https://help.ubuntu.com/community/Internet/ConnectionSharing

with the correct changes, but I can't make it work, the client can ping 192.168.0.1 (where the internet is coming from), but it can't access the internet at all.

Server:

eth0 192.168.10.1 eth0:2 192.168.0.6 Currently has connection with both the client and the internet

Router:

192.168.0.1

Client:

eth1 192.168.10.10 Can ping both the router and the server

0

edit /etc/sysctl.conf and uncomment:

# net.ipv4.ip_forward=1

And the iptables part should look something like below, where eth0 is internet and eth1 is LAN:

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

iptables -A FORWARD -i eth1 -o eth0 -m state -–state RELATED,ESTABLISHED -j ACCEPT

iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT

If you have 2 physical network interfaces in server then it should work, you cant use your server as internet gateway if it only has 1 physical interface

  • Yes, I only have one physical interface, now I'm aware of the problem, thanks. – Luck20 Jun 22 '16 at 20:20

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.