Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You don't need the -m option. -p implicitly loads the tcp module. Heres the extract from the manual
Code:
MATCH EXTENSIONS
iptables can use extended packet matching modules. These are loaded in two ways: implicitly, when -p or --protocol is specified, or with the -m
or --match options, followed by the matching module name; after these, various extra command line options become available, depending on the speā
cific module. You can specify multiple extended match modules in one line, and you can use the -h or --help options after the module has been
specified to receive help specific to that module.
Just my opinion matching is a bad wording I'd rather say module but who cares.
You don't need it when executing an iptables command (since the match module gets auto-loaded), but is anyone positive it's not needed in the actual configuration file? I don't ever edit that file manually (only with iptables-save) so I'm not sure.
You don't need it when executing an iptables command (since the match module gets auto-loaded), but is anyone positive it's not needed in the actual configuration file? I don't ever edit that file manually (only with iptables-save) so I'm not sure.
Your absolute right win32sux. When adding the rule by hand -m tcp is not needed but when saving iptables rules its always added.
Did a trial run adding the iptables rule once with and once without -m tcp and iptables-save always prints the line with -m tcp
Empty iptables
Code:
# iptables-save
# Generated by iptables-save v1.4.2 on Fri Oct 9 10:09:12 2009
*filter
:INPUT ACCEPT [84697:13964056]
:FORWARD ACCEPT [90216:12884867]
:OUTPUT ACCEPT [29225:6783683]
COMMIT
# Completed on Fri Oct 9 10:09:12 2009
Now add the line with -m tcp option
Code:
# iptables -A INPUT -s 192.168.1.1 -p tcp -m tcp --dport 22 -j ACCEPT
# iptables-save
# Generated by iptables-save v1.4.2 on Fri Oct 9 10:09:38 2009
*filter
:INPUT ACCEPT [84787:13973745]
:FORWARD ACCEPT [90248:12890096]
:OUTPUT ACCEPT [29282:6790635]
-A INPUT -s 192.168.1.1/32 -p tcp -m tcp --dport 22 -j ACCEPT
COMMIT
# Completed on Fri Oct 9 10:09:38 2009
Now add the line without
Code:
# iptables -A INPUT -s 192.168.1.1 -p tcp --dport 22 -j ACCEPT
Producer:/home/ase# iptables-save
# Generated by iptables-save v1.4.2 on Fri Oct 9 10:10:12 2009
*filter
:INPUT ACCEPT [84877:13985121]
:FORWARD ACCEPT [90282:12897348]
:OUTPUT ACCEPT [29334:6796807]
-A INPUT -s 192.168.1.1/32 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -s 192.168.1.1/32 -p tcp -m tcp --dport 22 -j ACCEPT
COMMIT
# Completed on Fri Oct 9 10:10:12 2009
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.