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 two routers, Router A is connected to the internet, and Router B is connected to the LAN port of Router A.

Router A: 192.168.1.1 Subnet 255.255.255.0

Router B: IP leased from router A: 192.168.1.2 Its own ip: 192.168.0.1 subnet 255.255.255.0

I have a machine C plugged to router A with ip 192.168.1.3 also a machine D plugged to router B with ip 192.168.0.199

enter image description here

I want to access machine D from a machine C. What settings do I need to change to do that?

share|improve this question
1  
Do routers A & B both hand out dhcp addresses? Also, why does B use a gateway of 192.168.0.1? –  uSlackr Apr 12 '12 at 16:39
    
@uSlackr, yes both A&B hand out dhcp addresses. 192.168.0.1 is just the factory default –  xiamx Apr 12 '12 at 16:41
    
I lost you here "gateway 192.168.0.1". What do you mean by gateway? Or you mean the default LAN address of router B. –  Radoo Apr 12 '12 at 19:41
    
@Radoo, 192.168.0.1 is not the gateway used on router B, but rather its own IP on the LAN interface. Sorry about that. –  xiamx Apr 12 '12 at 19:56
add comment

7 Answers

Router A needs to know which route to use to reach the 192.168.0.0/24 network.

Initially try adding a static route that says it can reach 192.168.0.0/24 via 192.168.1.2.

On a Cisco router running IOS you'd do

 ip route 192.168.0.0 255.255.255.0 192.168.1.2

On your unspecified make and model of router you'll have to use a web-interface or read the manual to find it's equivalent.

share|improve this answer
add comment

If these are standard residental "routers" with 4 LAN ports, then you actually have a device that is a combination of router and switch. The 4 LAN ports are a switch. Devices connected to that will see each other without you having to do anything other than take care of IP address setup, which is normally DHCP's job. You can "cascade" switches and things will work just fine.

If you are looking to just connect more than 4 devices in your home to the Internet, Router B does not need to be doing routing or DHCP at all, and the functionality should be disabled. Connect "router" B to a LAN port in router A, and anything else you need to the LAN ports on router B and as long as router B is not doing DHCP or anything else, it should just work.

share|improve this answer
add comment

I am assuming 192.168.0.1 is not the gateway used on router B, but rather its own IP on the LAN interface. If router A is giving out addresses through DHCP, it is also informing B of what gateway to use, and this should be 192.168.1.1. If you can access the internet from B's subnet, this is the case, unless you have a very excentring setup that needs a far more detailed explanation.

To answer your question, machines C and D are on seperate networks, but D can initiate a connection with C just fine. It can't find the IP 192.168.1.3 on its own subnet, so it passes on the request to its gateway, i.e. router B, who does know where the target machine is located.

The other way around is more difficult. Neither host D itself nor its gateway, router A, knows that traffic intended for 192.168.0.199 should traverse through router B. Even if they did, for instance by defining a route '192.168.0.0/24 trough 192.168.1.2', router B would not allow the packets to pass from its WAN interface to the LAN interface.

Although you may be better off using B as a 'dumb' switch instead of a router by simply connecting everything to its LAN ports, it is possible to circumvent this issue without changing the network topology. You will need to forward ports on router B that are used in communication originating outside the 192.168.0.0/24 network.

For instance, if machine D is running a web server, to which communication must be initiated from machine C, you will want to configure router B to forward port 80 towards 192.168.0.199. Alternatively, given your router supports such a feature, you can place machine D in router B's DMZ, thus forwarding all ports to this machine, unless they are configured otherwise. Normally, this could be regarded as insecure, but in this case, the machine will still be protected through router A, unless the 192.168.1.0/24 network is compromised.

share|improve this answer
add comment

You are preforming network address translation twice and it's probably set to moderate/strict settings. So Router B is hiding it's private addresses from connections initiated from outside router b's subnet and vice versa. This is because it assumes the network attached to it's WAN port is the public web. Normally this is fine because if the connection is established from inside the private network the router then knows where to send the incoming traffic back to. But in your case both sides are preforming NAT so each side is hiding it's private addresses from the other. This is why you need port forwarding behind a NAT so the router knows where to route connections being initiated from outside the network. A great way to understand what is happening is to look into UDP hole punching which is what many VNC and gaming applications use to allow connections to be initiated from outside.

Strict NAT is generally a limitation with consumer grade routers, but some of the better ones allow you to adjust NAT settings. Alternatively you can use DD-WRT, tomato, or another thrid party firmware that allows adjustments made to the NAT. You can also use port forwarding (which is a little more cumbersome) as mentioned by other users.

share|improve this answer
add comment

If your network is as simple as your diagram, with no NAT surprises, then there just needs to be a static route for 192.168.0.0/255.255.255.0 pointing to 192.168.1.2. This route can be on either Router A or Machine C, the latter being more restrictive than the former.

share|improve this answer
add comment

(Assuming you can get router B's WAN interface to be a normal ethernet interface, like on a cable router)

You need to set static routes on both machines C and D. If you have something more than basic doing DHCP and the machines C and D get their addresses from DCHP, you could push the routes out to all DHCP clients automatically.

Otherwise, you can set the routes like this:

Windows

Machine C

route -p ADD 192.168.0.0 MASK 255.255.255.0 192.168.1.1 METRIC 1

Machine D

route -p ADD 192.168.1.0 MASK 255.255.255.0 192.168.0.1 METRIC 1

Linux (added to network interface settings)

Machine C

route add -net 192.168.0.0/24 gw 192.168.1.1 

Machine D

route add -net 192.168.1.0/24 gw 192.168.0.1
share|improve this answer
    
For machine D, 192.168.0.1 is already the default gateway. No specific route needs to be added to the table. –  Marcks Thomas Apr 13 '12 at 21:26
    
@MarcksThomas: Oh yes of course, you're right. –  paradroid Apr 13 '12 at 22:49
add comment

Like Marks Thomas said, you have to do some port forwarding on router B.

This means that for accessing machine D, you will actually use the WAN IP address of router B, and the forwarded port of the application that runs on machine D.

You can do this from Port Forwarding/Virtual Server/NAT Settings (depends on the router how is called). * NAT = Network Address Translation

So basically you have to forward from IP address 192.168.0.199 the ports you want to connect to, from the WAN of router B.

A simple port forwarding configuration looks like this: enter image description here

Here I forwarded the HTTPS protocol port to the same WAN port of router B. So if, from machine C you will access https://192.168.1.2, you will be forwarded to the actual https://192.168.0.199 on the LAN of router B, which is machine D's http server software.

If you want to use Remote Desktop Connection you will have to forward port 3389.

share|improve this answer
1  
Sorry, but this makes things only more complicated. –  Bora Apr 12 '12 at 20:59
1  
Things are complicated... –  Radoo Apr 13 '12 at 9:26
add comment

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.