Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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 0.0.0.0/0

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 serverfault.com Nov 6 '11 at 14:25

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

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

3 Answers 3

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

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/natd.conf.apple
share|improve this answer

Your Answer

 
discard

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