I used to configure iptables to forward packages between different network interfaces on a muli-network-interface-server.
So long, it worked fine until I updated my server to Ubuntu 1604.
Ubuntu 1604 comes with the new kernal, which rename networkinterfaces(Predictable Network Interface Names)
Let's say, this server connects two sub-networks together:
- Interface
enp3s0
with ip192.168.1.155
, connects to the network192.168.1.0/24
, - Interface
enxa0cec80f64f3
with ip10.1.1.1
connects to the network10.1.1.0/24
.
As bellow.
Terminal1(10.1.1.2/24, gateway10.1.1.1)
||
||
\/
+---------------------------+
| enxa0cec80f64f3(10.1.1.1) |
| |
| Server |
| |
| enp3s0(192.168.1.155) |
+---------------------------+
/\
||
||
Host1(192.168.1.111/24, route to 10.1.1.0/24 via 192.168.1.155)
To enable hosts in the 2 networks talk to each other freely, iptables on the server is configured as
$ sudo iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s 10.1.1.0/24 -d 192.168.1.0/24 -i enxa0cec80f64f3 -o enp3s0 -m conntrack --ctstate NEW -j ACCEPT
-A FORWARD -s 192.168.1.0/24 -d 10.1.1.0/24 -i enp3s0 -o enxa0cec80f64f3 -m conntrack --ctstate NEW -j ACCEPT
The forwording does not work properly.
- Host1 ping
192.168.1.155
, SUCCEED; - Host1 ping
10.1.1.1
, SUCCEED; - Host1 ping Terminal1(
10.1.1.2
), FAILED; - Server ping Terminal1, SUCCEED
As i checked on the server with tcpdump, the packets from enp3s0
side was not forwarded on. (For some reason, I can not just check the packets from the other side)
Maybe iptables does not works with long-named network interfaces like enxa0cec80f64f3?