linux networking notes - animeshtrivedi/notes GitHub Wiki
Setup forwarding
from vmbox0 to wlp2s0 (and vice versa)
atr@host:~$ sudo iptables -I INPUT --source 192.168.56.0/24 -j ACCEPT
atr@host:~$ sudo iptables -t nat -I POSTROUTING --out-interface wlp2s0 -j MASQUERADE
atr@host:~$ sudo iptables -I FORWARD --in-interface wlp2s0 --out-interface vboxnet0 -j ACCEPT
atr@host:~$ sudo iptables -I FORWARD --in-interface vboxnet0 --out-interface wlp2s0 -j ACCEPT
IPV4 forwarding
# sysctl -w net.ipv4.ip_forward=0
OR
# sysctl -w net.ipv4.ip_forward=1
You can also change the setting inside /proc/sys/net/ipv4/ip_forward to turn the setting on or off.
# echo 0 > /proc/sys/net/ipv4/ip_forward
OR
# echo 1 > /proc/sys/net/ipv4/ip_forward
Then inside the other VM, setup IP routing
sudo route add default gw 192.168.56.1 enp0s3
https://www.cyberciti.biz/faq/linux-setup-default-gateway-with-route-command/
Temp internet interface, multiple IPs on the same NIC
ifconfig eth0:0
ifconfig eth0:0 123.123.22.22
ifconfig eth0:0 down
https://linuxconfig.org/configuring-virtual-network-interfaces-in-linux
ifconfig examples
https://www.tecmint.com/ifconfig-command-examples/