Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a LAN at home.

  • One Netgear router - 192.168.0.1 connected to the internet.
  • One Macbook - 192.168.0.10 (connected to Netgear router)
  • One PC with Kali Linux - 192.168.0.20 (connected to Netgear too)

I'm trying to route all Macbook traffic through the PC. So I set the network settings on my Macbook proxy-server address - 192.168.0.20 (PC). I have no problems with this - all packets go to the PC (through Netgear router of course). Its okay. but..

How to manage the NAT table on Linux to route Macbook's traffic to the router (and so to the internet)?

I tried to do something like this, but it doesn't work correctly:

iptables -t nat -A PREROUTING -s 192.168.0.10 -j DNAT --to-destination 192.168.0.1
iptables -t nat -A POSTROUTING -s 192.168.0.10 -j SNAT --to-source 192.168.0.20

with this settings I have BAD REQUEST 400 in my browser on Mac.

share|improve this question

1 Answer 1

You should forget your DNAT line. It does not do anything useful here.

Also, you should use -j MASQUERADE instead of -j SNAT --to-source 192.168.0.20.

You also need to make sure the IP forwarding on your Linux box is turned on.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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