LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-09-2006, 08:24 PM   #1
mjmwired
Member
 
Registered: Apr 2004
Distribution: CentOS6, CentOS5, F16, F15, Ubuntu, OpenSuse
Posts: 620

Rep: Reputation: 39
ssh ports and iptables


A quick question to the experts:

How do I run ssh on 2 ports and have each port restricted to a different network? Example:

ssh port 22: open to only 192.168.0.xxx
ssh port 45555: public internet

Thanks.
 
Old 08-09-2006, 08:32 PM   #2
w3bd3vil
Senior Member
 
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,191

Rep: Reputation: 49
iptables -A INPUT -p tcp -s ! 192.168.0.0/24 --dport 22 -j REJECT
I think this command would be sufficient, cause you wouldnt mind if a local lan ip connected on 45555

how to run ssh on two ports?
edit the /etc/ssh/sshd_config
you will see the port number hashed out, remove the hash. Next, add a new line and change the port number to 45555.
It should look like this
Port 22
Port 45555

Last edited by w3bd3vil; 08-09-2006 at 08:50 PM.
 
Old 08-09-2006, 10:35 PM   #3
scott2004
Member
 
Registered: Nov 2004
Location: Toronto, Canada
Distribution: Debian, OpenBSD, SuSE, Ubuntu
Posts: 68

Rep: Reputation: 15
Don't forget to configure your firewall to allow TCP connections on 4555 since this is not the default port for sshd and the firewall won't have a rule allowing it.

Plus, you'll need to issue this command as root each time after a reboot:

iptables -A INPUT -p tcp -s ! 192.168.0.0/24 --dport 22 -j REJECT

unless you add it to an rc.local script or custom firewall script.
 
  


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 ports Roosta21 Linux - Software 2 03-16-2006 04:00 AM
Open All Ports - iptables Artik Linux - Networking 2 06-21-2005 03:17 PM
ssh on two ports mazzo Linux - Security 8 09-25-2004 10:05 PM
SSH and ports zowey Linux - Networking 4 07-19-2004 06:31 AM
ssh ports phishintrip Linux - Networking 2 07-02-2003 02:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:41 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