Port forwarding in OS X 10.10
If I understand your question and your comment correctly you are trying to achieve something like a local captive portal.

This can't be done with pf and a simple redirect. A lot more stuff and configuration is involved. Here (the link to bsdguides.org in the github readme doesn't work: correct link) you find an example how to do this in OpenBSD. The solution there may be adapted to OS X under certain circumstances.



The rule rdr pass inet proto tcp from any to any port 80 -&gt; 127.0.0.1 port 8080 does the following:

rdr pass inet proto tcp from any to any port 80 -&gt; 127.0.0.1 port 8080
|   |    |              |
|   |    |              #from any IP (all source IPs) to any IP (all destination IPs of the local machine)
|   |    |              from any to any
|   |    #IPv4 Protocol TCP
|   |    inet proto tcp
|   #allow
|   pass
#redirect from port 80 to localhost:8080
rdr                                     port 80 -&gt; 127.0.0.1 port 8080


Or: any incoming (rdr only redirects incoming packets) IPv4 TCP traffic (on any interface) to port 80 from any IP to any IP (on any interface) of the local machine is passed and redirected to 127.0.0.1:8080. 

The rule doesn't redirect requests from a local client machine for google.com:80 (i.e. 216.58.201.206:80) or 175.68.9.102:80 to 127.0.0.1:80 because neither of these IPs is an IP of the local (www-)server machine nor does the local (www-)server know of the requests.

This doesn't apply to outgoing traffic of the local machine because that's no incoming traffic. You have to loop this traffic first:


pf (Mac OS X) rule to redirect all traffic to a specific ip/port
OS X 10.8: redirecting locally initiated ssh connections to localhost:22