Skip to content

Instantly share code, notes, and snippets.

@fernyb
Forked from ef2k/pf_and_dns.markdown
Created October 26, 2015 20:24
Show Gist options
  • Save fernyb/4daf9254af85641291ee to your computer and use it in GitHub Desktop.
Save fernyb/4daf9254af85641291ee to your computer and use it in GitHub Desktop.
Port Forwarding and Domain Tricks (MAC OSX Yosemite)
In /etc/hosts, add:
127.0.0.1 foo.com
Create /etc/pf.anchors/foo.conf
$sudo vim /etc/pf.anchors/foo.conf
rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 3000
Add this to /etc/pf.conf:
$sudo vim /etc/pf.conf
rdr-anchor "forwarding"
load anchor "forwarding" from "/etc/pf.anchors/foo.conf"
Then load it up:
$ sudo pfctl -ef /etc/pf.anchors/foo.conf
If it doesnt work make sure the following is set:
$ sudo sysctl -a | grep forwarding
net.inet.ip.forwarding: 1
net.inet6.ip6.forwarding: 1
set it like this:
sudo sysctl -w net.inet.ip.forwarding=1
sudo sysctl -w net.inet6.ip6.forwarding=1
Add it to /etc/sysctl.conf and reboot for changes to take effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment