-1

I'm setting marks with iptables like this

iptables -t mangle -A POSTROUTING -d 192.168.1.143 -j MARK --set-mark 10

if I want to clear what I do is remove all with

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

instead of removing all the rules to clear this, how to remove a mark only?

4

You could just delete that one rule.

iptables -L -t mangle --line-numbers

will give you a number for each rule in your mangle table, then use

iptables -t mangle -D POSTROUTING x

where x is the rule number where you defined the mark.

5

You can also use this syntax:

iptables -t mangle -D POSTROUTING -d 192.168.1.143 -j MARK --set-mark 10

(Note the -A changed to -D, everything else the same)

This format it useful if it is in your recent history which makes it easy to scroll back and change the A to a D. (ie, when you're testing a rule)

  • I have this code iptables -t mangle -A wlan0_Outgoing -m mac --mac-source ${mac} -j MARK --set-mark 2. Does change -A to a -D would remove this rule? – Reigel Aug 9 '18 at 10:19
  • @Reigel Yes.... – fukawi2 Aug 9 '18 at 23:03

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.