Super User is a question and answer site for computer enthusiasts and power users. 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 to NAT a Windows PC with IP through a Linux server with two network cards. The IP addresses of the NICs are (connected to an external network) and The second NIC is conneted to the Windows PC. My requirement is that I should be able to reach the Windows PC from the external network, so I need to NAT (this is the IP through which the external network should be able to access the Windows PC) to

How should I set up iptables on the Linux server to accomplish this?

share|improve this question

@John Siu is only partially correct - while the steps he pointed out are needed to get forwarding to work the magic NAT sauce is definitely needed as is a real IP adddress but 10.10.10.x is not.

For Outbound Connectivity (which it sounds like you may already have)

Assuming the External Interface is eth0 and the internal interface is eth1 you additionally need a rule like

/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

or similarly, but with much tighter control

/sbin/iptables -t nat -A POSTROUTING -s -o eth0 -j SNAT --to

For Inbound Connectivity from the world to your PC

/sbin/iptables -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination

This will allow requests coming from the world on TCP port 80 to your Windows PC. (You would, of-course modify the ports and protocol as required)

share|improve this answer
LOL, I didn't pay attention the is a public ip, it look so "private" to me :P. I will just remove mine and up vote yours +1. – John Siu Feb 1 '13 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .