Apr 04, '05 09:46:00AM • Contributed by: tejinashi
Set your internal IP address on en0 (built-in Ethernet) to whatever non-routable address you like -- i.e. 192.168.x.x or 172.16.x.x or 10.x.x.x. Then cut and paste the following into your favorite Terminal-based text editor. Save it as simple_natd.
#!/bin/bash
interface="$1"
if [ "$interface" = "" ] ; then
echo "I need an interface to NAT on"
exit 1
fi
echo "you may need to run 'ipfw flush'"
natd=`ps awux |grep -v grep|grep -v $0|grep natd|awk '{print $2}'`
kill -9 $natd
sleep 1
sysctl -w net.inet.ip.forwarding=1
alias_ip=$(ifconfig $interface | grep inet | grep -v inet6 | \
awk '{print $2}' | head -1)
/usr/sbin/natd -alias_address $alias_ip -interface $interface -use_sockets \
-same_ports -unregistered_only -dynamic -clamp_mss
#ipfw -f flush
ipfw add divert natd ip from any to any via "$interface"
Run the simple_natd script in terminal to enable NAT for computers on your built-in ethernet (en0) network from your network connection on the Airport card (en1):
sudo bash simple_natd en1
Remember to make the script executable first. A much more elegant solution would be to change the network and range that the internal DHCP server uses when starting Internet connection sharing. However, after months of random searching, I have been unable to find how that is possible.
