LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   accessing my router from a different computer (https://www.linuxquestions.org/questions/linux-networking-3/accessing-my-router-from-a-different-computer-396292/)

true_atlantis 12-24-2005 02:50 PM

accessing my router from a different computer
 
i have a machine that i cannot physically access, but i can ssh to it. there is a router connected to that machine that i need to access (http://192.168.1.1). is it possible to do this from a different location?

pnellesen 12-24-2005 03:17 PM

Any chance you can start up a VNC server instance on that machine via SSH? If not, maybe try one of the various text-based browsers? (Hopefully someone reading this has some better ideas ;) [Edit - like the reply below me, for instance :o ] )

haertig 12-24-2005 03:24 PM

Quote:

Originally Posted by true_atlantis
i have a machine that i cannot physically access, but i can ssh to it. there is a router connected to that machine that i need to access (http://192.168.1.1). is it possible to do this from a different location?

You want to access the router using http, correct?

From your client computer, run the following ssh command:

ssh -L8999:192.168.1.1:80 server_ip_address

Enter your login/password so you have an established ssh connection between the client and server. What you have done is setup ssh port forwarding between localhost:8999 and 192.168.1.1:80 using your server as the intermediate.

[edit]
p.s. If your client is a Windows computer and you're using Putty as the ssh client program, it supports port forwarding too. Just browse through the GUI based configuration of Putty and you'll find it somewhere.
[/edit]

Fire up the web browser on your client, and enter the following URL:

http://localhost:8999

That should put you in to your router (on port 80). That "8999" is a local port on your client computer. It doesn't have to be 8999, just any port that is available. Generally chose some port above 1025 because you may not be able to use ports below this, depending on your permissions on the client computer.

true_atlantis 12-24-2005 09:02 PM

i am using putty, but i cannot get it to work... here is how i have it set up...

source port: 80
destination: localhost:8999

then i connecto to my ip, and it gives me a 'connection refused' when i try to opeh http://localhost:8999

there are some othe roptions, but im not sure which to select...
'local ports accept connections from other hosts'
'remote ports do the same'

then under destination i have options
'local' 'remote' or 'dynamic'
and
'auto' 'IPv4' or 'IPv6'

am i doing something wrong?

haertig 12-24-2005 10:13 PM

Quote:

Originally Posted by true_atlantis
i am using putty, but i cannot get it to work... here is how i have it set up...

source port: 80
destination: localhost:8999

You have it backwards.

For SOURCE PORT, put 8999
For DESTINATION, put 192.168.1.1:80

The SOURCE PORT, according to Putty, is the port on your client that you will be connecting to. Thus you would point the web browser on your client to http://localhost:8999 for this example. Your client computer is connecting to ITSELF, thus the "localhost" in the URL.

The DESTINATION is where the connection will ultimately end up. In this example, your router. Thus you specify your router's IP address and port in the DESTINATION field. Note that the IP address in the DESTINATION does not have to be accessible from the client computer. It needs to be accessible from the ssh server computer. That's the whole point in what we're trying to do here. Your client computer cannot contact your router directly, but your ssh server can, so we set up a tunnel from the client to the router via the ssh server.

I'll try to draw what's happening as viewed from your client computer:

localhost:8999 ---> ssh_server_ip_address:22 ---> 192.168.1.1:80

Your client computer's web browser thinks its talking to port 8999 on its own local self (actually, it IS). But ssh is encrypting the data, sending it to your ssh server, then unencrypting it, and finally sending it on to 192.168.1.1:80. Note that it's entirely possible that your client computer can also talk to something at 192.168.1.1, but it's a totally different thing than the 192.168.1.1 that your ssh_server can talk to. The DESTINATION is specified relative to your ssh_server, not your client.

Now if THAT wasn't confusing, I don't know what is!!!

[edit]
Sorry, I forgot the other part of your question before posting last time.

In Putty, fill in your SOURCE PORT and your DESTINATION. Leave everything else at it's default. Then click the ADD button. You may also want to go back to the "Session" area of the config and click SAVE so that your port forwarding comes up automatically next time as well.
[/edit]


All times are GMT -5. The time now is 03:32 AM.