Goal: To configure the routing of the traffic from VM to the PC and to the internet. to configure the forwarding of the traffic from wlan0 to the eth0 on CentOS7, and vice versa.
My topology:
VM - (cable) --- eth0=RPI=wlan0 -(wireless)- Router -- ISP | (wireless) PC
- I have used this article to configure the traffic forwarding from eth0 to wlan0: https://gist.github.com/tzermias/5408466
- wlan0 has been configured using nmtui.
Commands being issued:
sudo ifconfig eth0 192.168.56.1 netmask 255.255.255.0
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -A FORWARD --in-interface eth0 -j ACCEPT
sudo iptables --table nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE
Now, I checked the network-scripts folder:
[pi@rtr001 network-scripts]$ ls
ifcfg-FunBox-84A8 ifdown-ppp ifup-ippp ifup-TeamPort
ifcfg-link ifdown-routes ifup-ipv6 ifup-tunnel
ifcfg-lo ifdown-sit ifup-isdn ifup-wireless
ifdown ifdown-Team ifup-plip init.ipv6-global
ifdown-bnep ifdown-TeamPort ifup-plusb keys-FunBox-84A8
ifdown-eth ifdown-tunnel ifup-post network-functions
ifdown-ippp ifup ifup-ppp network-functions-ipv6
ifdown-ipv6 ifup-aliases ifup-routes
ifdown-isdn ifup-bnep ifup-sit
ifdown-post ifup-eth ifup-Team
Noticed, that, the ifcfg-eth0
is not present in there, even, the output of ifconfig
, below, is showing the address is assigned, and I am able to ping device, plugged into the Ethernet port, with IP 10.10.10.2:
[pi@rtr001 network-scripts]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.10.1 netmask 255.255.255.0 broadcast 10.10.10.255
ether b8:27:eb:d7:d7:9a txqueuelen 1000 (Ethernet)
RX packets 3 bytes 214 (214.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 50 bytes 8296 (8.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 32 bytes 2592 (2.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32 bytes 2592 (2.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.26 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::47ae:281a:680f:11eb prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:82:82:cf txqueuelen 1000 (Ethernet)
RX packets 649 bytes 42528 (41.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 492 bytes 69881 (68.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Also, the VM, with IP: 10.10.10.2, is able to ping 10.10.10.1, but failing to ping 192.168.1.22, any IP in subnet 192.168.X.X, which is between RPI -- Router.
Questions:
- What does
sudo ifconfig eth0 10.10.10.1 netmask 255.255.255.0
do, in terms of modifying of the files in Linux? In other words, it looks, as per output ofifconfig
, that the address ofeth0
has been assigned, but, there is no specificifcfg-eth0
present. - How to make the configuration of eth0 present after the reboot?
- What I should modify in RPI, in order to be able to ping from VM, 192.168.X.X subnet?
- How can I see the NAT ip table, which command I should run? It looks,
iptables -L
is not showing the NAT rules...