LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-07-2008, 12:52 AM   #1
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,143
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
Question iptables quivalent of tcpwrapper


Hi frns,

I have the following tcpwrapper rule
#vi /etc/hosts.deny

sshd : ALL EXCEPT 192.168.0.100 : spawn /bin/echo `/bin/date` from %h >> /var/log/ssh.log : spawn (echo -e "Access denied to external ssh connection from %h " | mail -s "SSH connection denied" root@localhost) : DENY


I want the equivalent rule in iptables to log and send mail.
 
Old 02-07-2008, 02:28 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
You want to deny ssh action to everyone except 192.168.0.100, refused attempts get logged (which must a big log file make.)

Presumably you can figure out how to rig policy deny, and accept incoming ssh connections by IP?

This leaves adding a log entry... which is just the same as the accept incoming, except it jumps to a log instead.

I think it is important that you understand your firewall. It is also good discipline to describe what you hope to acheive in normal language instead of trying to duplicate the effect from another application.
 
Old 02-08-2008, 04:16 AM   #3
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,143
Blog Entries: 4

Original Poster
Rep: Reputation: 147Reputation: 147
Question

Hi

Thanks for the wise advice but at least i should get a mail when some one tries to ssh me...Can i achieve this through iptables or is there any other method except tcp-wrappers,port sentry and tripwire?

Regards,
Prayag
 
Old 02-08-2008, 05:17 AM   #4
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Yes, I already said, you can set iptables to write a log entry whenever a packet gets denied.

Something[*] like this:
iptables -A INPUT -p tcp -m tcp --dport 22 -m recent --name ssh --set -j LOG --log-prefix "SSH Attempt:"

... should appear after the -j ACCEPT entry for ssh from that one allowed IP. Since you have a default drop policy <raised eyebrow> you don't need an explicit DROP rule here.
[*]I don't do this myself, but I modified a rule to log portscans.
http://www.newartisans.com/blog_file...h.iptables.php
... caveat: these guys don't seem to use default DROP policies. Sad sad sad... you will always forget something: -P DROP catches it.
 
Old 02-08-2008, 06:53 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,353
Blog Entries: 55

Rep: Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541
To be clear about the other things: Port Sentry is deprecated and should not be used anymore. Use something like Snort or Prelude if you want IDS capabilities or else something "simple" like PSAD could do. tripwire is a filesystem integrity checker like Aide, Samhain, Osiris and such has nothing to do with checking ports. Wrt to SSH it would be good to harden your setup, read the sticky Failed SSH login attempts thread and implement one of the solutions. The idea to e-mail an alert on tripping a port is nice if your part of the 'net doesn't receive any port probing but it is not an efficient or scalable solution.
 
Old 02-15-2008, 02:02 AM   #6
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,143
Blog Entries: 4

Original Poster
Rep: Reputation: 147Reputation: 147
Hi frns,
Thanks for the valuable suggestions.What i want was that i should get the alert through mail when the hacker attacks or even tries to attack my Server.So again in brief tell me how to prevent server from being hacked and get alerts.

Regards,
Prayag
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
VSFTP, tcpwrapper teruzzi Linux - Security 0 01-06-2008 01:26 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
[DEBIAN SARGE] problems setting up sshd to use tcpwrapper nonutopia Linux - Security 1 08-23-2005 08:04 AM
IPtables Log Analyzer from http://www.gege.org/iptables/ brainlego Linux - Software 0 08-11-2003 06:08 AM
My iptables script is /etc/sysconfig/iptables. How do i make this baby execute on boo ForumKid Linux - General 3 01-22-2002 07:36 AM


All times are GMT -5. The time now is 06:22 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration