Port Forwarding in Yosemite
If you are trying sudo ipfw for port forwarding and you are getting “command not found” then you must be using Yosemite.
The command ipfw has been deprecated since Mavericks and finally Apple took it off in Yosemite. However you can still forward port but its not going to be a one liner like
sudo ipfw add 1025 forward 127.0.0.1,1025 ip from any to any 25 in
After Googling around I found below steps to setup port forwarding.
Step 1: Create the Port Forwarding Rule
Open the terminal and navigate to /etc/pf.anchors/ and create a new file. I will call it com.iastute and open it in nano.
sudo touch com.iastute
sudo nano com.iastute
Paste the below rule and save it. Note: In my case I am forwarding port 80 to 8080 on my machine.
rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080
Step 2: Create the Port Forwarding Config
Navigate to /etc/ and create a new conf file. I am going to call it pf-iastute.conf
sudo touch pf-iastute.conf
sudo nano pf-iastute.conf
Paste the below 3 lines, yes including the 3rd empty newline.
rdr-anchor "forwarding" load anchor "forwarding" from "/etc/pf.anchors/com.iastute"
Step 3: Finally enable Port Forwarding
Enable port forwarding by running following command.
sudo pfctl -ef /etc/pf-iastute.conf
That should do it!