Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
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.
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.
I'm trying to figure out if there's a way to run SSH on different ports based on the IP address. I've got a linux box acting as my router. I want to be able to access SSH on the external interface via a different port than the internal interface, which will use standard port 22. Can anyone point me in the right direction?
nothing to do with ssh really.. just use port forwarding to a different port within the router. anything that hits my adsl router on port 2222 goes through to an internal machine on 22.
Have a look at man sshd_config. It sounds like you want the ListenAddress option. From the man page:
Code:
Specifies the local addresses sshd(8) should listen on. The following forms may be used:
ListenAddress host|IPv4_addr|IPv6_addr
ListenAddress host|IPv4_addr:port
ListenAddress [host|IPv6_addr]:port
If port is not specified, sshd will listen on the address and all prior Port options specified. The
default is to listen on all local addresses. Multiple ListenAddress options are permitted. Addition-
ally, any Port options must precede this option for non-port qualified addresses.
Router
-> Laptop (sshd listening on port X)
-> Desktop (sshd listening on port Y)
I have the router set to forward port X to the laptop and port Y to the desktop. Then when I ssh from some remote location I can pick my machine by port.
In /etc/ssh/sshd_config you can set the "Port" line without messing with the ListenAddress or anything fancy.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.