1

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?

1
  • 1
    Why exactly do you have to do this? Jan 8, 2012 at 5:44

3 Answers 3

2

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
0

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
0

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

You must log in to answer this question.