As you can see from the log below ferm messes with iptables rules that
were present before starting ferm. It would be nice if ferm would insert
and remove itself into the iptables rules in a clean way that doesn't
mess with externally provided rules. The rule below provides Internet
access via NAT for my OpenMoko FreeRunner phone, which is connected to
my laptop via USB, with network forwarded using Ethernet-over-USB, using
the g_ether Linux module on the phone and cdc_ether on the laptop.
root@chianamo ~ # iptables-save
# Generated by iptables-save v1.4.12.2 on Mon Feb 6 18:03:32 2012
*filter
:INPUT ACCEPT [24200:18105777]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [27277:3551343]
COMMIT
# Completed on Mon Feb 6 18:03:32 2012
# Generated by iptables-save v1.4.12.2 on Mon Feb 6 18:03:32 2012
*nat
:PREROUTING ACCEPT [2:139]
:INPUT ACCEPT [2:139]
:OUTPUT ACCEPT [3560:261951]
:POSTROUTING ACCEPT [3551:260819]
-A POSTROUTING -s 192.168.0.192/28 -j MASQUERADE
COMMIT
# Completed on Mon Feb 6 18:03:32 2012
root@chianamo ~ # start ferm
Starting ferm (via systemctl): ferm.service.
root@chianamo ~ # iptables-save
# Generated by iptables-save v1.4.12.2 on Mon Feb 6 18:03:39 2012
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state INVALID -j DROP
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -p udp -m udp --dport 500 -j ACCEPT
-A INPUT -p esp -j ACCEPT
-A INPUT -p ah -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 2222 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5353 -j ACCEPT
-A FORWARD -m state --state INVALID -j DROP
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -m state --state INVALID -j DROP
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Mon Feb 6 18:03:39 2012
# Generated by iptables-save v1.4.12.2 on Mon Feb 6 18:03:39 2012
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Mon Feb 6 18:03:39 2012
root@chianamo ~ # stop ferm
Stopping ferm (via systemctl): ferm.service.
root@chianamo ~ # iptables-save
# Generated by iptables-save v1.4.12.2 on Mon Feb 6 18:03:50 2012
*filter
:INPUT ACCEPT [1:319]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2:411]
COMMIT
# Completed on Mon Feb 6 18:03:50 2012
# Generated by iptables-save v1.4.12.2 on Mon Feb 6 18:03:50 2012
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Mon Feb 6 18:03:50 2012