First, run the following command in turn:
CD/etclsgrep pf.confsudocp pf.conf Pf.conf.normal.bak sudocp pf.conf pf.conf.transmit.baklsgrep pf.conf
Ii. Modification of pf.conf Pf.conf.transmit.bak
Sudo
OR:
Sudo
The modified contents refer to the previous post on the configuration port forwarding, I am here (note ignored, for reference only):
Scrub-anchor"com.apple/*"Nat-anchor"com.apple/*"RDR-anchor"com.apple/*"rdr on Lo0 inet Proto TCP from all to127.0.0.1Port the-127.0.0.1Port8080dummynet-anchor"com.apple/*"Anchor"com.apple/*"Load Anchor"Com.apple"From"/etc/pf.anchors/com.apple"
After you have modified it, save it.
Iii. creating startup and shutdown script files
1. Find a folder that is convenient for you to find, such as the desktop, create a startup.sh file to enable port forwarding, the following:
CP /etc/pf.conf.transmit.bak/etc/pf.confsudo pfctl-dsudo pfctl-f/etc /pf.conf sudo pfctl-e
2. Create a shutdown.sh file to turn off port forwarding with the following content:
CP /etc/pf.conf.normal.bak/etc/pf.confsudo pfctl-dsudo Pfctl-f/etc/pf.conf sudo pfctl-e
PS: as mentioned above, before enabling, please stop other processes that occupy port 80, such as httpd
This port forwarding script is configured successfully, thank you all ~
Fullstack.yang
2016-12-26 Tianfu Software Park in Chengdu High-tech Zone
Script configuration method for opening and closing port forwarding under Mac