Sharing an Internet Connection
Configuring a Local Gateway Server
Change the /etc/sysctl.conf file by using ” net.ipv4.ip_forward=1 ” and activate the changes with #sysctl -p
Internet NIC —> eth0 (the ID of the Internet connected network adapter)
1 2 3 |
IP = 192.168.2.10 netmask = 255.255.255.0 GateWay = 192.168.2.1 |
Local NIC—> vboxnet0
1 2 3 |
IP = 10.0.2.1 netmask = 255.255.255.0 GateWay = leave empty |
iptables rules
1 2 3 4 |
ptables -A FORWARD -o eth0 -i vboxnet0 -s 10.0.2.0/24 -m conntrack --ctstate NEW -j ACCEPT iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT iptables -t nat -F POSTROUTING iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
Client Machine Settings
Note: The gateway’s IP address is what will be used by clients wanting to connect to the Internet using the gateway server.
1 2 3 4 |
ethx ip = 10.0.2.x netmask = 255.255.255.0 GateWay = 10.0.2.1 |
1 2 3 4 |
/etc/resolv.conf should have a valid dns entered. Example: No response with ping google.com A response with ping 8.8.8.8 or another public IP address indicates that there's a problem with the DNS or that the dns string is missing from the /etc/nsswitch.conf file. |
User, Roles &...
12 March 2019