##1. Create the anchor file:
sodu vim /etc/pf.anchors/com.liuxingruo
Inside the anchor file, enter:
rdr pass on lo0 inet proto tcp from any to self port 80 -> 127.0.0.1 port 9191
rdr pass on en0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 9191
rdr pass on en1 inet proto tcp from any to any port 80 -> 127.0.0.1 port 9191
Make sure to add a newline at the end of this file.
##2. Test the anchor file:
sudo pfctl -vnf /etc/pf.anchors/com.jenkins
##3. Add the anchor file to the pf.conf file:
sudo vim /etc/pf.conf
Load the anchor file we previously created, make sure to add these entries to the appropriate spot.
#
# com.apple anchor point
#
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
rdr-anchor "com.liuxingruo" // new line
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "com.liuxingruo" from "/etc/pf.anchors/com.liuxingruo" // new line
##4. Load and enabling pf
- To manually enable it (no restart required)
sudo pfctl -ef /etc/pf.conf
- To enable it automatically after each restart
sudo vim /System/Library/LaunchDaemons/com.apple.pfctl.plist
<key>ProgramArguments</key>
<array>
<string>pfctl</string>
<string>-e</string> <!-- new line -->
<string>-f</string>
<string>/etc/pf.conf</string>
</array>
👍 It works thank you very much. But there are still 2 insignificant errors:
sodu
com.liuxingruo
but testcom.jenkins