We are studying iptables for a Computer Systems Security course. We are confused as to what happens when the -s and -d arguments are both used in the same rule, such as:

iptables -A OUTPUT -s -d -j REJECT

We know how to block ports coming in and going out as well as ip addresses. However, we are unsure as to what the line above does.

At first we thought it blocks output from one ip address to another, but when we tested this theory we found the assumption was invalid.


1 Answer 1


As I understand:

Switch -d and -s are associated by a and expression.


As you're talking about a firewall, and iptables -A OUTPUT mean iptables -t filter -A OUTPUT, this seem not to be right:

chains INPUT and OUTPUT concern packet from or to the host (firewall).

This coud be usefull if your firewall hold many different IP address and want to make condition based on wich IP is used.

Even if is the only (local) IP of your firewall, -s switch is clearly useless.

For blocking a traversing connexion, you have to instruct FORWARD chain.

iptables -A FORWARD -s -d -j REJECT

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .