Setup Port Forwarding OS X Router

Macbook 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 osxfw.sh):



#!/bin/bash
# bit-torrent port forwarding with mac os x
killall-9 natd
sleep5
# The following will forward 6881 to 6999 port to desktop computer located at 192.168.2.2
# 192.168.1.100 => airport IP
# 192.168.2.2 => Desktop client ip
# natd provides a Network Address Translation facility for use with divert(4) sockets under FreeBSD.
# ————————————————————————————————————————————————–
/usr/sbin/natd -aliasaddress 192.168.1.100 -interface en1 -usesockets -sameports -unregisteredonly -dynamic -clampmss -enablenatportmap -natportmapinterface en0 -redirectport tcp 192.168.2.2:6881-69996881-6999 -l


Simply run this script whenever you need to forward ports:

chmod +x osxfw.sh
sudo ./osx_fw.sh


Type the following command to list current rules (these are set by above Internet sharing procedure):

sudo ipfw list

Posted on Friday, 12 August, 2011, in Mac. Bookmark the permalink. Comments Off on Setup Port Forwarding OS X Router.

Comments are closed.

%d bloggers like this: