Script configuration method for opening and closing port forwarding under Mac

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.