iptables sanity check

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
This seems to do what I want, but I want to make sure it is. The syntax for this stuff makes little sense, and getting this to work has been a PITA.

iptables -I INPUT 1 -s $machine2 -p TCP --dport 22 -m state --state NEW,ESTABLISHED -i eth1 -j ACCEPT

Basically, I want this rule to allow SSH from $machine2 (an ssh gateway) to the system iptables is running on. It should allow new and established connections, and keep track of state.

Is this doing what I want? Is there something more I could add, or something I should change?

Thanks in advance!
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
It looks ok to me, but I'm far from a netfilter guru.

Just realize that -I is insert and -A is append, so when you run that it'll become the first rule.
 

Haden

Senior member
Nov 21, 2001
578
0
0
It's not usual to use NEW,ESTABLISHED in one rule. Maybe you want:
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # accept connections we established or related ones (e.g. ftp)
iptables -A INPUT -m state -p tcp --dport 22 --state NEW -s $machine1 -j ACCEPT # accept ssh from machine1
iptables -A INPUT -j DROP # drop everything else
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
True, although I would assume that if the conntrack module accepts the combination that it would also be smart enough to do the right thing with it.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
The real rules use -A, I guess I posted a test one instead.

It's SSH. There isn't anything "RELATED" involved, that I'm aware of. It's bad enough I have to create multiple rules for multiple sources, I don't think it should be bad to have NEW and ESTABLISHED in the same rule. Especiallly since the ESTABLISHED connections should be restricted in the same manner as the NEW connections.

Thanks for the commends guys!
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
I usually change my port, adding 2 digits (i.e.2299 or something). I get a lot less login attempts (zero in 10 months in fact) after changing that.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: nweaver
I usually change my port, adding 2 digits (i.e.2299 or something). I get a lot less login attempts (zero in 10 months in fact) after changing that.

Standards are there for a reason. And we already do this. I just made it 22 so people knew what I was trying to allow.
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
I figured that might be the case....

My company sometimes does small security audits, and yet we forget to do things like deny root SSH access...creating usernames that are the same as computername/DNS name. No password/simple password on commenly named accounts. It makes me laugh when they get hacked (and they do, eventually.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: nweaver
I figured that might be the case....

My company sometimes does small security audits, and yet we forget to do things like deny root SSH access...creating usernames that are the same as computername/DNS name. No password/simple password on commenly named accounts. It makes me laugh when they get hacked (and they do, eventually.

We're constantly auditted. We do alright.
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
we are also "constantly auditted"...by the live IP's on our test lab machines and the script kiddies
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: nweaver
we are also "constantly auditted"...by the live IP's on our test lab machines and the script kiddies

Korea and China audit us constantly. We've also got plenty of internal and internalish audits going on.
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
lol. What is amazing is that a fully patched XP box, not running auto updates lasts about 2 days after patch tuesday before it's gone belly up. We also have an odd setup, as our test lab has very little firewalling on our live IP's for the test lab. The firewall between test lab and corp is pretty tight though.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |