Port Forwarding is a way of making computer, in which located private LAN, accessible on the Internet. Even though it is behind the router. It is used for gaming, surveillance IP cameras, accessing your personnel computer on the Internet.
Actually, in this post port forwarding is used for accessing a web page that runs on CentOS7 virtual machine, which is hosted on Windows 10. You can catch a glimpse of picture for better understanding in Figure 1. So, any request that is destined for 192.168.1.11:10444 will be redirected to the 192.168.59.128:80, which is virtual guest(CentOS7) that runs an Apache server.
Figure – 1
Adding Forwarding Rule on Windows 10
To do that first open up command prompt as a elevated privilege (Run as Administrator.) and customize it for your needs.(Figure-2)
netsh interface portproxy add v4tov4 listenport=10444 listenaddress=192.168.1.11 connectport=80 connectaddress=192.168.59.128
Removing Forwarding Rule on Windows 10
You can delete existing forwarding rule such below. Figure-3
netsh interface portproxy delete v4tov4 listenport=10444 listenaddress=192.168.1.11
To test it, Virtual guest network was sniffed with tcpdump tool. Figure-4
[root@rhce html]# tcpdump -i any port 80 -nnvv
18:13:55.845170 IP (tos 0x0, ttl 128, id 2729, offset 0, flags [DF], proto TCP (6), length 40) 192.168.59.1.60177 > 192.168.59.128.80: Flags [.], cksum 0xc126 (correct), seq 440, ack 181, win 255, length 0 18:13:55.845353 IP (tos 0x0, ttl 128, id 2730, offset 0, flags [DF], proto TCP (6), length 40) 192.168.59.1.60177 > 192.168.59.128.80: Flags [F.], cksum 0xc125 (correct), seq 440, ack 181, win 255, length 0 18:13:55.845386 IP (tos 0x0, ttl 64, id 56843, offset 0, flags [DF], proto TCP (6), length 40) 192.168.59.128.80 > 192.168.59.1.60177: Flags [.], cksum 0xf7ec (incorrect -> 0xc137), seq 181, ack 441, win 237, length 0
Network was sniffed on Windows 10 host. Figure-5