mac pf forwards local port 80 to port 80

The linux system generally uses iptables to forward 80 to 8080, but mac does not. 
But mac has other tools, the previous version is ipfw, and the newer version is replaced by pf. (mine is 10.11.3. According to the description of the official documentation, pf has been used since 10.10. The specific operations are as follows:

  1. Make sure that the firewall of the mac is turned on. It can be turned on as described below: System Preferences -> Security & Privacy -> Firewall -> Turn On Firewall
  2. After the firewall is turned on, you need to modify the pf configuration file: /etc/pf.conf, add rdr on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080 to the rdr-anchor “com.apple” of the file /*" after the line. Note that it must be below this line, the order of this file is required.
  3. Open pf: 
    sudo pfctl -f /etc/pf.conf 
    sudo pfctl -E

Excerpt: https://blog.csdn.net/ficksong/article/details/51223761

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326025316&siteId=291194637