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 12-22-2004, 01:21 PM   #1
tebucky
Member
 
Registered: Mar 2004
Posts: 89

Rep: Reputation: 15
IPtables Question


I am runnng Fedora Core 3 and have a question regarding iptables.

I want only allow ssh connections from specific IP address and deny all other attempts. What would the entry look like in the iptable.

TIA!
 
Old 12-22-2004, 03:10 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Code:
iptables -A INPUT -s specificIP --dport 22 -j ACCEPT
iptables -A INPUT --dport 22 -j DROP
Rules order is important.
 
Old 12-28-2004, 12:37 PM   #3
tebucky
Member
 
Registered: Mar 2004
Posts: 89

Original Poster
Rep: Reputation: 15
So I applied that rule within iptables and I am still receiving these unwatned attempts.

###########################################################################
Dec 26 20:05:35 localhost sshd[26372]: Failed password for invalid user guest from ::ffff:211.189.116.220 port 56783 ssh2
Dec 26 20:05:39 localhost sshd[26375]: Invalid user admin from ::ffff:211.189.116.220
Dec 26 20:05:42 localhost sshd[26375]: Failed password for invalid user admin from ::ffff:211.189.116.220 port 57004 ssh2
Dec 26 20:05:45 localhost sshd[26378]: Invalid user admin from ::ffff:211.189.116.220
Dec 26 20:05:47 localhost sshd[26378]: Failed password for invalid user admin from ::ffff:211.189.116.220 port 57170 ssh2
Dec 26 20:05:50 localhost sshd[26381]: Invalid user user from ::ffff:211.189.116.220
Dec 26 20:05:52 localhost sshd[26381]: Failed password for invalid user user from ::ffff:211.189.116.220 port 57271 ssh2
Dec 26 20:05:57 localhost sshd[26384]: Failed password for root from ::ffff:211.189.116.220 port 57334 ssh2
#############################################################################

Do you need a snapshot of my table to discover the problem? again, I only want specific IP addy's to be able to ssh to my machine.

TIA!!!
 
Old 12-28-2004, 05:09 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
It's IP version 6. So you need to use iptables for IPv6: ip6tables.
 
Old 12-29-2004, 08:22 AM   #5
tebucky
Member
 
Registered: Mar 2004
Posts: 89

Original Poster
Rep: Reputation: 15
So here is a snippet of what I have so far, can you tell me what I am missing?

##################################################
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp -s IP ADDY --dport 22 --syn -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp -s IP ADDY --dport 22 --syn -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp -s IP ADDY --dport 22 --syn -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 22 -j DROP
###################################################

Sorry guys, I am a newbie and still getting me feet wet....
 
Old 12-30-2004, 04:24 PM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Make FORWARD to DENY (it's not safe). Don't know what's eth0, but you accept everything comming from it (the extra limitations on port are after this, so they don't work for traffic to eth0). Then you have three identical rules (-A RH-Firewall-1-INPUT -p tcp -m tcp -s IP ADDY --dport 22 --syn -j ACCEPT).
 
Old 12-31-2004, 12:49 AM   #7
rajsmilesalways
LQ Newbie
 
Registered: Dec 2004
Distribution: fedora,mandrake,redhat,suse
Posts: 3

Rep: Reputation: 0
do one thing
1.Drop all the packets on all the chains i.e
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
2.Write rules for allowing ssh to your machine
iptables -t filter -A INPUT -s 0/0 -p tcp --dport 22 -d <yourip> -j ACCEPT
iptables -t filter -A OUTPUT -d 0/0 -p tcp --sport 22 -s <yourip> -j ACCEPT
This should solve your purpose
 
  


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
iptables question iomari Linux - Security 4 01-13-2005 12:14 AM
Iptables Question? unixfreak Linux - Security 1 09-01-2004 08:23 PM
iptables Question gauge73 Linux - Networking 3 12-14-2003 12:02 AM
IPtables Question jacovds Linux - Security 10 11-17-2003 09:46 AM
iptables question Texicle Slackware 7 01-19-2003 12:48 AM

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

All times are GMT -5. The time now is 06:35 AM.

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