Ask Different is a question and answer site for power users of Apple hardware and software. 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 am trying to figure out how to use this command with mac os x

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

The only thing I have found that seems like it might work is

ipfw add m all from me to

but I get: ipfw: invalid action m\n'

Does anybody know how I could translate the iptable code to mac compatible code?

share|improve this question

migrated from Nov 6 '11 at 14:25

This question came from our site for system and network administrators.

Why exactly do you have to do this? – Jason Salaz Jan 8 '12 at 5:44

If you are just trying to share your internet connection, you can do this from System Preferences > Sharing > Internet Sharing

If that's not why you posted this and you still do it manually(see Eir Nym's post). Don't forget to:

    sudo sysctl -w net.inet.ip.forwarding=1
share|improve this answer

You can try something like following. Please, read all details here. I hope this is working with non-server Lion (as FreeBSD nature of this OS), but I haven't tested it.

 ipfw add 00010 divert natd ip from any to any via (ext int name here)
 /usr/sbin/natd -config /path/to/SL/
share|improve this answer

Below are the steps needed to set this up. en0 in this case is the external interface:

/usr/sbin/natd -interface en0
/sbin/ipfw -f flush
/sbin/ipfw add divert natd all from any to any via en0
/sbin/ipfw add pass all from any to any
sudo sysctl -w net.inet.ip.forwarding=1
share|improve this answer

Your Answer


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