Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a LAN at home.

  • One Netgear router - connected to the internet.
  • One Macbook - (connected to Netgear router)
  • One PC with Kali Linux - (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 - (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 -j DNAT --to-destination
iptables -t nat -A POSTROUTING -s -j SNAT --to-source

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

share|improve this question

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

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

share|improve this answer

Your Answer


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.