I am trying to learn iptables and virtualbox.
I have 3 Centos7 VMs configured as follows with iptables configured on VM2. All interfaces are configured as "host only adapter" in virtual box as /24 networks:
VM1 - - - - - - - - - - - VM2- - - - - - - - - - -VM3
192.168.1.1 192.168.1.2
172.16.0.2 172.16.0.1
10.0.0.1
iptables is configured on VM2 as follows:
LINE 1: -A INPUT -s 192.168.1.1 -d 192.168.1.2 -j LOG
LINE 2: -A FORWARD -s 192.168.1.1 -d 172.16.0.2 -j LOG
LINE 3: -A FORWARD -s 192.168.1.1 -d 172.16.0.1 -j LOG
LINE 4: -A FORWARD -s 192.168.1.1 -d 10.0.0.1 -j LOG
When I send data using scapy -- send(IP(src="n.n.n.n", dst="y.y.y.y")/TCP()) -- the traffic flow described on LINES 1, 2 and 4 is logged. But the flow from LINE 3 is not.
I have tried LINE 3 using INPUT and OUTPUT rules without success.
What am I missing?
Thanks.
Steve
There are no nat rules involved? (In that case those are processes first (PREROUTING) or last (POSTROUTING).
INPUT only is used in INCOMING packets into the system, OUTPUT only for packets leaving the system (both not for forwarding).
FORWARDING is the passthrough chain.
Didn't you swap the addresses 172.16.0.1 & 172.16.0.2.... I would expect 172.16.0.2 in INPUT and 172.16.0.1 on FORWARD with the addresses mentioned in your schema.