Suggestion: Marker option in iptable, netfilter chains
Hello,
I have a suggestion about a new feature.
( i don't know if such thing allready exists so i assume it does not exist)
Normally you create a bash scipt where you set up all your rules of your iptables firewall.
A bash script like this example:
(i know this example is unsecure and shound't be used in reality, so it's just for showing what i want to tell you)
----------------
#!/bin/sh
iptables -P INPUT DROP
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 21 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 29 -j REJECT iptables -A INPUT -i eth0 -p tcp --dport 50 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 130 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 804 -j DROP iptables -A INPUT -i eth0 -p tcp --dport 21456 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 2955 -j ACCEPT
-----------------
Now when you start this script and
check your iptable rules again with
$ iptables -L
you get something like this:
------------------
Chain INPUT (policy DROP)
target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:http ACCEPT tcp -- anywhere anywhere tcp dpt:ftp REJECT tcp -- anywhere anywhere tcp dpt:msg-icp reject-with icmp-port-unreachable ACCEPT tcp -- anywhere anywhere tcp dpt:re-mail-ck ACCEPT tcp -- anywhere anywhere tcp dpt:cisco-fna DROP tcp -- anywhere anywhere tcp dpt:804 ACCEPT tcp -- anywhere anywhere tcp dpt:21456 ACCEPT tcp -- anywhere anywhere tcp dpt:2955
------------------
This firewall example is very easy to understand, but
sometimes your firewall is very complex and the rules chain is very long with branches to other chains etc..
In such a situtaion it would be great to have a thing like a "marker" in the rule chain when using "iptables -L".
This marker would help you to find the exact position in your firewall script, in other words the place where the marker was set.
Such a feature would be very handy for debugging the firewall.
To show what i meant we assume we have a marker option in iptables which could be used in our firewall script. Let's say this option can be used with a -S option:
-S = Set Marker
Now let's take a look at the same script but with a marker option:
------------------
#!/bin/sh
iptables -P INPUT DROP
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 21 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 29 -j REJECT iptables -S Marker-1
iptables -A INPUT -i eth0 -p tcp --dport 50 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 130 -j ACCEPT iptables -S Marker-2
iptables -A INPUT -i eth0 -p tcp --dport 804 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 21456 -j DROP iptables -S Marker-3
iptables -A INPUT -i eth0 -p tcp --dport 2955 -j ACCEPT
-----------------
When we now view our firewall rules with
iptables -L we would see something like this:
------------------
Chain INPUT (policy DROP)
target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:http ACCEPT tcp -- anywhere anywhere tcp dpt:ftp REJECT tcp -- anywhere anywhere tcp dpt:msg-icp reject-with icmp-port-unreachable Marker 1 was set! ACCEPT tcp -- anywhere anywhere tcp dpt:re-mail-ck ACCEPT tcp -- anywhere anywhere tcp dpt:cisco-fna Marker 2 was set! DROP tcp -- anywhere anywhere tcp dpt:804 ACCEPT tcp -- anywhere anywhere tcp dpt:21456
Marker 3 was set!
ACCEPT tcp -- anywhere anywhere tcp dpt:2955
------------------
It should be clear that such a feature would be realy helpfull for debugging the firewall script, especially when it is a very long firewall with a lot of ramifications.
Now my question is, would such a feature in iptables/netfilter be possible?
Best Regards,
Oliver C.
Please send me a copy of your answers to me because i am not on the mailinglist.
Quoted 5 lines · On Sun, 9 Nov 2003 [email protected] wrote:
It should be clear that such a feature would be realy helpfull for debugging the firewall script, especially when it is a very long firewall with a lot of ramifications.
Now my question is, would such a feature in iptables/netfilter be possible?
The easiest way I see for implementhing this is implementing it as a dummy match always returning true, with the rule "mark" as parameter to the match.
See the netfilter hacking howto for instructions how to write a new match module. It is not at all a difficult thing to do if you know a little (not much) C programming.
Regards
Henrik
Good day, Oliver,
Quoted 4 lines · On Sun, 9 Nov 2003 [email protected] wrote:
Hello,
I have a suggestion about a new feature.
( i don't know if such thing allready exists so i assume it does not exist)
[snip]
Quoted 14 lines
This firewall example is very easy to understand, but
sometimes your firewall is very complex and the rules chain is very long with branches to other chains etc..
In such a situtaion it would be great to have a thing like a "marker" in the rule chain when using "iptables -L".
This marker would help you to find the exact position in your firewall script, in other words the place where the marker was set.
Such a feature would be very handy for debugging the firewall.To show what i meant we assume we have a marker option in iptables which could be used in our firewall script. Let's say this option can be used with a -S option:
-S = Set Marker
Quoted 16 lines
Now let's take a look at the same script but with a marker option:
------------------
#!/bin/sh
iptables -P INPUT DROP
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 21 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 29 -j REJECT iptables -S Marker-1
iptables -A INPUT -i eth0 -p tcp --dport 50 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 130 -j ACCEPT iptables -S Marker-2
iptables -A INPUT -i eth0 -p tcp --dport 804 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 21456 -j DROP iptables -S Marker-3
iptables -A INPUT -i eth0 -p tcp --dport 2955 -j ACCEPT
-----------------
How about:
iptables -i eth99 -s 127.99.99.99 -d 127.200.200.200 -j LOG --log-prefix "Marker-1 "
You can reuse that rule as many time as you'd like, verbatim, just
change the log string each time.
[snip]
Quoted 5 lines
It should be clear that such a feature would be realy helpfull for debugging the firewall script, especially when it is a very long firewall with a lot of ramifications.
Now my question is, would such a feature in iptables/netfilter be possible?
It already is.
Quoted 2 lines
Please send me a copy of your answers to me because i am not on the mailinglist.
Please sign up for the mailing list. ;-)
Cheers,
- Bill
---------------------------------------------------------------------------
"Hackers do not feel that leisure time is automatically any more
meaningful than work time. The desirability of both depends on how they are realized. From the point of a view of a meaningful life, the entire work/leisure duality must be abandoned. As long as we are living our work or our leisure, we are not even truly living. Meaning cannot be found in work or leisure but has to arise out of the nature of the activity itself. Out of passion. Social value. Creativity."
-- Andrew Leonard <[email protected]>
http://salon.com/tech/col/leon/2001/02/05/hacker_ethic/index2.html
--------------------------------------------------------------------------
William Stearns ([email protected]). Mason, Buildkernel, freedups, p0f,
rsync-backup, ssh-keyinstall, dns-check, more at: http://www.stearns.org
Linux articles at: http://www.opensourcedigest.com
--------------------------------------------------------------------------