Why can't I forward from my host port 8080 to guest port 80 (Mojave)?

Solution 1:

You have created the forwarding rule the wrong way around - i.e. you have reversed it.

Instead of:

rdr pass inet proto tcp from any to any port 8080 -> 127.0.0.1 port 80

It needs to look like this:

rdr pass inet proto tcp from any to any port 80 -> 10.0.2.15 port 8080

In regards to the sysctl.conf file, you'll absolutely need to make that change. It doesn't matter that the file doesn't exist on your computer - just create an empty file (/etc/sysctl.conf) and add those lines.

If you can't get the sysctl.conf file working, you can run the sysctl command manually on the command line:

 sudo sysctl -w net.inet.ip.forwarding=1