I'm replacing a wireless router/firewall running Tomato with a Debian server, and I was excited to have found tomato's iptables config so I could directly import it to the new server (my question before this). The iptables config file (at bottom) from Tomato fails iptables-restore in Debian:

# iptables-restore < iptables.eth0-eth1
iptables-restore v1.4.14: Couldn't load match `mport':No such file or directory

Error occurred at line: 7
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

Is there a way to get mport into "modern" iptables?
Or could you please help me translate mport to multiport?

Googling for iptables mport was pretty rough, but I eventually found someone complaining mport is gone and a multiport tutorial with passing reference to the mport extension, which led to me snooping around the two box's filesystems for modules and also trying every "firewall" tool Debian has, wishing for one to magically come with mport. I admit to being quite spoiled by Tomato's user interface -- every Debian package I have tried since has left me more and more confused (gui or cli). If I could get the server to briefly route everything, I think mason might work. No wonder everyone hates iptables.

I spent more time trying to figure out the errors than I should. Had I spent that much time trying to understand iptables, I probably could have translated the mport rules to multiport. Also, I pondered posting to SuperUser, however, the few iptables tagged questions weren't in the same league as ones I'm reading here in ServerFault.

Looking for modules:
I ssh'd into the wireless router with tomato firmware, I found the module libipt_mport.so in /usr/lib/iptables. But in the /lib/modules/2.4.20/kernel/net/ipv4/netfilter directory, there is no libipt_mport.so, only ipt_multiport.o.

On the Debian box (fresh install of wheezy), I used updatedb and locate to search on MASQ (for MASQUERADE object) and found the directory
/lib/modules/3.2.0-4-amd64/kernel/net/ipv4/netfilter has a good array of iptable_* and nf_nat_* ko files. The search also found libxt_multiport.so in /lib/xtables, but there is no reference to object modules for mport.

Additionally, are there any other problems below? I see the layer 7 stuff and have a feeling this will make for more complications next.

Tomato's config file:
» is WAN ip
» is ip for this Debian firewall
» is a server
» tomato's public interface vlan0 changed to eth0
» tomato's internal interface br0 changed to eth1
» ports 5060:5090 are for VoIP (probably don't need that whole range?)

:QOSO - [0:0]
-A QOSO -j CONNMARK --restore-mark --mask 0xff
-A QOSO -m connmark ! --mark 0/0xff00 -j RETURN
-A QOSO -p tcp -m mport --dports 80,443   -m bcount --range 0x0-0x7ffff -j CONNMARK --set-return 0x2/0xFF
-A QOSO -p tcp -m mport --dports 80,443   -m bcount --range 0x80000 -j CONNMARK --set-return 0x4/0xFF
-A QOSO -p udp --dport 53   -m bcount --range 0x0-0x7ff -j CONNMARK --set-return 0x1/0xFF
-A QOSO -p tcp --dport 53   -m bcount --range 0x0-0x7ff -j CONNMARK --set-return 0x1/0xFF
-A QOSO -p udp --dport 53   -m bcount --range 0x800 -j CONNMARK --set-return 0x5/0xFF
-A QOSO -p tcp --dport 53   -m bcount --range 0x800 -j CONNMARK --set-return 0x5/0xFF
-A QOSO -p udp --dport 1024:65535   -j CONNMARK --set-return 0x5/0xFF
-A QOSO -p tcp --dport 1024:65535   -j CONNMARK --set-return 0x5/0xFF
-A QOSO -p udp -m mport --ports 5060:5090  -m layer7 --l7dir /etc/l7-protocols --l7proto sip -j CONNMARK --set-return 0x101/0xFF
-A QOSO -j CONNMARK --set-return 0x4
-A FORWARD -o eth0 -j QOSO
-A OUTPUT -o eth0 -j QOSO
-A PREROUTING -i eth0 -d -j DROP
-A PREROUTING -p icmp -d -j DNAT --to-destination
-A PREROUTING  -p tcp -m tcp -d --dport 22 -j DNAT --to-destination
-A PREROUTING -p tcp  -d --dport 10022 -j DNAT --to-destination
-A POSTROUTING -p tcp --dport 22 -s -d -j SNAT --to-source
:upnp - [0:0]
-A PREROUTING -d -j upnp
-A INPUT -i eth1 -d -j DROP
-A INPUT -m state --state INVALID -j DROP
-N shlimit
-A shlimit -m recent --set --name shlimit
-A shlimit -m recent --update --hitcount 3 --seconds 60 --name shlimit -j DROP
-A INPUT -p tcp --dport 22 -m state --state NEW -j shlimit
-A INPUT -i eth1 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp  -m tcp -d --dport 22 -j ACCEPT
-A FORWARD -i eth1 -o eth1 -j ACCEPT
-A FORWARD -m state --state INVALID -j DROP
-A FORWARD -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1461: -j TCPMSS --set-mss 1460
:L7in - [0:0]
-A FORWARD -i eth0 -j L7in
-A L7in -m layer7 --l7dir /etc/l7-protocols --l7proto sip -j RETURN
:wanin - [0:0]
:wanout - [0:0]
-A FORWARD -i eth0 -j wanin
-A FORWARD -o eth0 -j wanout
-A FORWARD -i eth1 -j ACCEPT
:upnp - [0:0]
-A FORWARD -i eth0 -j upnp
-A wanin  -p tcp -m tcp -d --dport 22 -j ACCEPT
  • I am using Ubuntu 12.04 and on my system I have multiport and not mport. You can see man iptables if you are unsure.
    – Khaled
    Jan 14, 2014 at 11:07
  • Yes, your ubuntu is just like my debian and yes, my man doesn't know about mport.
    – Krista K
    Jan 14, 2014 at 11:24
  • What have you tried? It's pretty trivial to write a multiport rule, and the man page is crystal clear on how it works. Jan 14, 2014 at 15:49
  • Hi Michael, everything but learning iptables themselves. That's today's goal. Get a good base config set up, then go back and investigate the config I fetched. Thanks.
    – Krista K
    Jan 14, 2014 at 19:55

1 Answer 1


AFAIK, the parameters for the multiport module is identical to the parameters for the mport module you've shown.

Try a simple search-and-replace:

s/-m mport/-m multiport/g

PS: Certainly not everyone hates iptables; I personally LOVE iptables ;-)

  • But does multiport accept ranges? Oct 9, 2014 at 10:22
  • 1
    @danmaz74 try man iptables and search for multiport. Short answer, just in case you don't have access to a linux console: YES.
    – pepoluan
    Oct 9, 2014 at 10:47
  • 1
    Yes thanks actually I had found it it works fine :) Oct 10, 2014 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.