Port Forwarding From a Shared Connection
valid until 10.7, natd is deprecated in 10.8 and above but should still work

A solution found here:

First use "ifconfig" to see how the wireless and ethernet interfaces are called.
Probably the wireless interface is "en1" and the (shared) ethernet interface is "bridge0".

IP-settings of the "other device":


  IP address: 192.168.1.x (x ≠ 0,1,2,other used last octets in the 192.168.1- network),255)
  IP netmask: 255.255.255.0
  IP gateway: 192.168.1.2
  IP DNS server: 192.168.1.2


Mac OS X has no direct GUI option to configure port forwarding. However, you can create a shell script as follows (open terminal and create a script called osx_fw.sh):

#!/bin/bash
# http port forwarding with mac os x
killall -9 natd
sleep 5
# The following will forward 80 port to desktop computer located at 192.168.1.x
# 192.168.0.2 =&gt; airport IP
# 192.168.1.x =&gt; Desktop client ip
#  natd provides a Network Address Translation facility for use with divert(4) sockets under FreeBSD.
# -------------------------------------------------------------------------------------------------
/usr/sbin/natd -alias_address 192.168.0.2 -interface en1 -use_sockets -same_ports -unregistered_only -dynamic -clamp_mss -enable_natportmap -natportmap_interface bridge0 -redirect_port tcp 192.168.1.x:80 80 -l


Make the script executable:

chmod +x osx_fw.sh


Simply run this script whenever you need to forward ports:

sudo ./osx_fw.sh


Depending on your system you probably have to setup or modify some firewall rules.

since 10.8

check this answer