Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have a user called "testuser" in my debian system and i want to mark the FTP traffic going from testuser's account

how can i do that?

i use following commands to mark all the outgoing traffic for "testuser"

iptables -t mangle -N HTB_OUT
iptables -t mangle -I POSTROUTING -j HTB_OUT
iptables -t mangle -A HTB_OUT -m owner --uid-owner testuser -j MARK --set-mark 10

how to set two marks for "testuser"? one for FTP traffic only and one for all other traffic?

share|improve this question
up vote 0 down vote accepted

Add a --dport (--destination-port) option. You'll need at least two of them - 20:21 for FTP traffic and !20:21 for non-FTP.

share|improve this answer
can you please show me how to combine it with "-m owner --uid-owner testuser -j MARK --set-mark" ? – Gihan Lasita Dec 10 '12 at 18:28
You simply add it as an option to the command line. – John Dec 10 '12 at 19:00
it gives me error "invalid argument" when its added to this "iptables -t mangle -A HTB_OUT -m owner --uid-owner testuser -j MARK --set-mark 10" – Gihan Lasita Dec 10 '12 at 19:43
Try "man iptables" – John Dec 10 '12 at 20:19
thanks by adding "-p tcp --dport 20:21" command executed without errors but not for "-p tcp --dport !20:21" it gives "-bash: !20: event not found" – Gihan Lasita Dec 11 '12 at 9:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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