LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-07-2005, 01:25 PM   #1
ruleman
LQ Newbie
 
Registered: Feb 2004
Distribution: Slackware 9.1
Posts: 22

Rep: Reputation: 15
iptables ssh


Hello,

I currently have full c class on my server (/24). And i want to ssh to be allowed only from one ip. The rest of ips should be droped. I configured sshd_config file to listen only one ip but some attacker still can flood port 22 of other ips. So what should add my iptables rules?

Thanks for replies.
 
Old 05-07-2005, 02:09 PM   #2
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
If I'm understanding you correctly ...you want to allow incomming connections to this box from only one ip, correct? if so....
Code:
iptables -A INPUT -i eth0 -s xxx.xxx.xxx.xxx -p tcp -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 22 -j DROP
Replace xxx's with the ip you wish to allow...
Be advised this isn't a "complete" firewall, but just 2 rules to do what you want

Last edited by zeos; 05-07-2005 at 02:11 PM.
 
Old 05-07-2005, 02:35 PM   #3
ruleman
LQ Newbie
 
Registered: Feb 2004
Distribution: Slackware 9.1
Posts: 22

Original Poster
Rep: Reputation: 15
thank i'm using apf. i'll add following lines to bt.rules. usally i'm getting udp and syn floods. I just want to block them. When some one floods ipconntract table goes full and it consumes all cpu resources.
 
Old 05-07-2005, 03:46 PM   #4
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
If you're getting flooded with bogus syn requests you need to enable tcp_syncookies 'echo 1 >> /proc/sys/net/ipv4/tcp_syncookies'

I didn't realize you were a target of a coordinated attack from your first post, but simply restricting the port in which ssh listens on isn't going to help against a syn or ddos attack against your box .....

You may need to talk to your upstream provider about dropping the rogue packets at their border as just about anything you do (system level) is going to eat into your cpu resources...

I'm not familiar with apf, but search around here, there are plenty of iptables examples (I've posted at least one myself somewhere)that will get you at least a rudimentary understanding. You really should set the default input policy to DROP (don't use reject, as you're system will still have to work overtime to respond to the packets in this case) then explicitly allow connections you need.

Last edited by zeos; 05-07-2005 at 03:52 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH and IPTABLES metallica1973 Linux - Security 17 09-05-2005 07:02 PM
iptables and ssh iomari Linux - Networking 6 10-01-2004 07:44 PM
ssh / iptables bruj3w Linux - Networking 17 08-05-2004 12:00 PM
iptables ssh priority? Emanon Linux - Networking 2 04-15-2004 02:22 AM
Ipchains/iptables/ssh RockerSWE Linux - Networking 6 03-18-2003 03:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration