Pings from LAN to WAN fail
The issue below was resolved by following the advice given in the following video:
https://sandilands.info/sgordon/building-internal-network-virtualbox
Here's my topology:
WAN_PC ------PC1--------PC2
Internet Edge LAN
Overview:
I'm setting this up in the latest version of VirtualBox. I have two VMs in VirtualBox (PC1 and PC2). PC2 is on an internal network. The WAN_PC represents the outside world or Internet. PC1 is connected to the Internet on one NIC and to the internal network on a second NIC. I want PC2 on the internal network to be able to get to the Internet - using PC1 as its gateway. That is, the ping needs to start on PC2 and go to PC1. PC1 needs to route the packet received on its inside NIC to its outside NIC and on to the Internet. The reply packet from the Internet arrives on the outside NIC on PC1. PC1 needs to route that packet over to its inside NIC and on to PC2.
PC1 is running RHELv94 (Linux). PC2 can run either a Windows OS or a Linux OS - really doesn't matter.
PC1 and PC2 can ping each other. PC1 can ping a host on the Internet. But PC2 does not get a reply when pinging a host on the Internet. How do I fix this?
For troubleshooting, I turned the firewall off on PC1:
systemctl stop firewalld.service
I enabled IP forwarding by editing /etc/sysctl.conf and adding the following line on PC1:
net.ipv4.ip_forward=1
...and then rebooted and double-checked the value to confirm it was changed to 1:
sysctl net.ipv4.ip_forward
The routing table has a default route naming the outside interface on PC1, a static route for all traffic destined to the PC2 LAN naming the inside interface on PC1, and a static route for all traffic destined to the PC2 WAN network naming the outside interface on PC1.
I also tried adding the following line to /etc/sysctl.conf:
net.ipv4.conf.default.rp_filter=2
I'd really appreciate any help to get traffic from PC2 through PC1 to the outside and back to PC2. What am I missing?