Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
  • I have a computer at home with ip 192.168.221.xxx

  • I have another computer at work that I can ping and it has 2 ip addresses: 192.168.1.xxx and 192.168.0.xxx. Those last 2 addresses have the same gateway ie 192.168.1.1 .

  • The computer at work is connected to a hub. That hub also has an embedded device connected to it with address 192.168.0.xxx

Now from my home computer I cannot ping this embedded device. How would I connect to it without changing the subnetwork it connects to? I can ping the embedded device from my work computer and I can ping the work computer from my home computer. So I am trying to connect to the embedded device from my home computer through my work computer. Port forwarding? how would I establish that on Ubuntu?

share|improve this question

migrated from stackoverflow.com Nov 4 '09 at 7:34

This question came from our site for professional and enthusiast programmers.

    
wrong site to ask. move it to Superuser! –  Mauris Nov 4 '09 at 7:32
    
IMHO more a Serverfault, then a Superuser question. –  Tim Büthe Nov 4 '09 at 8:58
    
Definitely a Server Fault question. –  CarlF Nov 6 '09 at 1:42
    
Please note Once a question has incorrectly been migrated it cannot be migrated again. Please don't flag this to be moved. –  Diago Nov 6 '09 at 5:39
    
Dont you find having a website for each category is a bit overkill? gets really hard to manage after a while –  user16654 Dec 22 '09 at 18:08

4 Answers 4

Set up B as a router.

If B is a linux machine, do this command:

echo 1 > /proc/sys/net/ipv4/ip_forward

Unless B is already the default gateway of A, You likely now need to configure A to know about network C, tell it to use B as a gateway to reach C.

route add -network 192.168.1.0 netmask 255.255.255.0 gw ip-of-B
share|improve this answer

The question is a little fuzzy (maybe be, first thing in the morning).

I would check your subnet masks, if you are on 255.255.255.0 then the .221, .1 and .0 machine are on completely separate networks.

As for the work and embedded machine, they are on the same network, but if they cannot communicate, my guess would be it is a routing conflict.

If this was me, I would disable the secondary interface on the work machine and make sure you put everything on the same network (255.255.255.0) and then use the ips in the same range (192.168.0.x).

If everything is on a subnet of 255.255.0.0 then they are on the same network already, so I would just disable the second interface on the work machine as this could be creating the conflict.

share|improve this answer

An easy way is to use SSH forwarding. Run a command like this:

ssh -L 8000:192.168.0.xxx:yyyy user@192.168.1.zzz

Once you authenticate to your work machine, ssh will be listening locally on port 8000. If you connect to localhost:8000, the connection will be forwarded to 192.168.0.xxx:yyyy.

[Edit: answer to below queries]

You are on host A. Using -R makes B listen on a port and forward to C. This might be fine, depending on how wide open your access to B is. Using -L makes A listen on a port, and tunnel the connection through B to C. So, let's say B is 10.10.10.10 and C is 20.20.20.20, and you want to connect to C via ssh. You run this command:

ssh -L 8000:20.20.20.20:22 user@10.10.10.10

Now A is listening on port 8000, but connections to it will be tunneled through to 20.20.20.20:22, so in a local shell, run this command:

ssh user@127.0.0.1:8000

This will make the connection to C (via your open session to B). Substitute other ports for other services, e.g. to connect to a webserver on C:

ssh -L 8000:20.20.20.20:80 user@10.10.10.10

then point your browser to http://127.0.0.1:8000

share|improve this answer
    
This pretty much answers the question. For GUI goodness you can also do this in PuTTY. –  Manos Dilaverakis Nov 4 '09 at 9:37
    
so what you are saying is if i start a ssh session with putty at home and authenticate. then anything I send from home to 192.168.1.zzz will be sent to 192.168.0.xxx:yyyy? I need to connect to 192.168.0.xxx with a program. –  user16654 Dec 22 '09 at 22:50
    
its not working but at least it sends me on the right track I am thinking UI should use -R remote port forwarding instead of local because I need remote connection to localhost to be forwarded to computer C –  user16654 Dec 23 '09 at 19:25

It could be that the embedded device has no gateway/route to your home PC range 192.168.221.xxx. If you have access to its configuration you may be able to connect without forwarding by just adding an appropriate gateway to its routing table.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.