Linux - Security This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
01-21-2007, 12:14 AM
|
#1
|
LQ Newbie
Registered: Jan 2007
Posts: 14
Rep:
|
iptables - interfaces, ports restrictions
Hi All,
How can I
1. restrict port 22 traffic to the x.x.x.x interface to only allow incoming traffic from x.x.x.0/25
2. allow all incoming port 22 traffic to the y.y.y.y interface
Thanks for any help.
|
|
|
01-21-2007, 12:35 AM
|
#2
|
LQ Guru
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211
Rep:
|
assuming a default drop policy
1. you want ssh connection from your machine to be allowed, but only from a particular net? I think that's something like:
iptables -A INPUT -p tcp -i eth1 -s x.x.x.0\24 -j ACCEPT -dport 22
2. so similarily:
iptables -A INPUT -p tcp -i eth0 -j ACCEPT -dport 22
if eth1 is x.x.x.x and eth0 is y.y.y.y
Last edited by Simon Bridge; 02-04-2007 at 05:46 PM.
|
|
|
01-21-2007, 11:37 PM
|
#3
|
Senior Member
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291
Rep:
|
Quote:
Originally Posted by owbr4dh02
Hi All,
2. allow all incoming port 22 traffic to the y.y.y.y interface
Thanks for any help.
|
In the configuration file for the ssh server /etc/ssh/sshd.config you can set the ssh server to only listen on the ipaddress of the interface you specify, it will then refuse connection on any other interface. For example if you ssh server runs and ipaddress of 192.168.1.1 you would have something like this:
Code:
ListenAddress 192.168.1.1
|
|
|
01-22-2007, 10:53 PM
|
#4
|
LQ Newbie
Registered: Jan 2007
Posts: 14
Original Poster
Rep:
|
Hi Simon Bridge, fotoguy !
Thank you very much for your help!
|
|
|
01-23-2007, 04:07 AM
|
#5
|
Senior Member
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291
Rep:
|
Quote:
Originally Posted by owbr4dh02
Hi Simon Bridge, fotoguy !
Thank you very much for your help!
|
Glad to help out, if you would like to make it even more secure you can change the default port that ssh listens on to a completely different port. In the /etc/ssh/sshd.config you will see the #Port 22, just remove the hash symbol (uncomment), change the port to anything eg. Port 6893 then restart the ssh server and it will now listen to port 6893 for connectiosn.
|
|
|
01-23-2007, 10:14 AM
|
#6
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
Quote:
Originally Posted by fotoguy
Glad to help out, if you would like to make it even more secure you can change the default port that ssh listens on to a completely different port. In the /etc/ssh/sshd.config you will see the #Port 22, just remove the hash symbol (uncomment), change the port to anything eg. Port 6893 then restart the ssh server and it will now listen to port 6893 for connectiosn.
|
hi, i don't mean to nit-pick, but i just wanted to comment that, technically speaking, changing the port ssh listens on has absolutely no effect as far as security is concerned... obscurity doesn't give more security...
but yes, having it listen on another port does have its benefits, such as making an ssh daemon less prone to getting picked-up by spiders, etc... but that's not in any way shape or form an increase in the security level...
|
|
|
01-23-2007, 09:55 PM
|
#7
|
Senior Member
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291
Rep:
|
Quote:
Originally Posted by win32sux
hi, i don't mean to nit-pick, but i just wanted to comment that, technically speaking, changing the port ssh listens on has absolutely no effect as far as security is concerned... obscurity doesn't give more security...
but yes, having it listen on another port does have its benefits, such as making an ssh daemon less prone to getting picked-up by spiders, etc... but that's not in any way shape or form an increase in the security level...
|
Yes that is true, I should have said that it will help to minimise the threats from automated programs/scripts which target port 22 by default.
|
|
|
01-25-2007, 04:58 AM
|
#8
|
LQ Guru
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211
Rep:
|
Quote:
Thank you very much for your help!
|
Glad to be of assistance (as the door said to Zaphod Beeblebrox)... so did this actually work?
|
|
|
02-04-2007, 12:44 AM
|
#9
|
Member
Registered: Oct 2006
Posts: 42
Rep:
|
It ain't working, just because "-t" stands for "table".
so the rules gotta be :
iptables -P INPUT DROP
#default policy of the chain
iptables -A INPUT -p tcp --dport 22 -i eth1 -s x.x.x.x -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -i eth0 -j ACCEPT
#any other allowed ports go below(may use multiport..)
iptables -A INPUT -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
|
|
|
02-04-2007, 05:46 PM
|
#10
|
LQ Guru
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211
Rep:
|
I'm sorry, that should be -p (protocol). I'll edit the previous post so folk don't get confused.
|
|
|
All times are GMT -5. The time now is 10:48 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|