Skip to content

Instantly share code, notes, and snippets.

@eddanger
Last active May 25, 2016 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eddanger/f67ce14f69c32bccfecc to your computer and use it in GitHub Desktop.
Save eddanger/f67ce14f69c32bccfecc to your computer and use it in GitHub Desktop.
Port Forwarding from 80 to 8080 in Yosemite

Add com.coverall file to /etc/pf.anchors with:

rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port = 80 -> 127.0.0.1 port 8080
rdr pass on en0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass on en1 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass on en2 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080

Update pf.conf to point to this new file a-la:

scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
rdr-anchor "coverall"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "coverall" from "/etc/pf.anchors/com.coverall"

Run: sudo pfctl -ef /etc/pf.conf

To startup port forwarding on boot:

cd /Library/LaunchDaemons

sudo curl -O https://gist.githubusercontent.com/eddanger/f67ce14f69c32bccfecc/raw/0c887ad24678241a6f1fb1855641bd63574fc80a/com.coverallcrew.firewall.plist

sudo launchctl load -w com.coverallcrew.firewall.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.coverallcrew.firewall</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<!---<string>ipfw add fwd 127.0.0.1,8080 tcp from any to me dst-port 80 in &amp;&amp; sysctl -w net.inet.ip.forwarding=1</string>-->
<string>pfctl -ef /etc/pf.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment