Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static routes between IP addresses

Status
Not open for further replies.

linuxpyro

Technical User
Feb 11, 2003
38
US
Sorry about this, I'm a bit of a n00b when it comes to routing... I tried this question in the Linksys section, but haven't gotten an answer yet. At any rate it isn't too specific to those products for the most part.

My network has two subnets, 192.168.1.0, and 192.168.2.0. I have a Linksys router running as a gateway on the first subnet, and a Linux router running as a gateway to the second subnet (one interface has the IP 192.168.1.2, and the other has 192.168.2.0). I have a couple other computers I want to run as servers and put on the subnet 192.168.2.0, and I want to be able to forward ports from the internet to these servers.

On my Linksys router I have a static route set up as follows:

Destination: 192.168.2.0
Subnet Mask: 255.255.255.0
Gateway: 192.168.1.2

I can ping the computers on the second subnet just fine, but the Linksys box won't let me forward ports to a host on another subnet. So, is it possible to set up a route between an IP on the first subnet, such as 192.168.1.10, and an IP on the second, say 192.168.2.10, allowing me to simply enter 192.168.1.10 as the IP to forward ports to?

Another thing I have been a bit confused by is the net mask. Right now my entire network uses the netmask 255.255.255.0. Since I have the two subnets, should I be useing 255.255.0.0 instead?

Thanks in advance.
 
I think your problem might be with the second interface on the Linux router. 192.168.2.0 is the network address. Try changing it to something like 192.168.2.1.

The subnet mask you are using is appropriate for the networks you have. 255.255.255.0 (or /24 as it is also known) says that the first three blocks of the IP address are for the network and the final block for the workstation address. As long as your dont need more than 254 IP addresses in each network then you dont need to worry too much about the subnet mask.
 
mrbusy is correct:-

If you have a subnet maske of 255.255.255.0 then this shows the first threee octets as being the network address and the last octet being the host. You must start the host addresses under this subnet mask at 192.168.2.1.

As a rule of thumb a Gateway address is normally stipulated as 1, so in this case the gateway would be 192.168.2.1 and you first host might contain the following:-

IP Address: 192.168.2.5
Subnet mask: 255.255.255.0
Gateway: 192.168.2.1

Hope this is useful
 
Thanks guys. I changed the address of the second interface to 192.168.2.1. However I still need to be able to forward ports to a server on the second subnet, due to the router firmware (for the sake of keeping this discussion relevant to this forum, I will simply say that I do not wish to try a different firmware on my router). Is there another trick I can pull here to make the router forward traffic to a server on the other subnet without setting up port forwarding and/or NAT on the Linux router?
 
I am not much of a Linux expert, but from a router (Cisco) point of view, you may want to have a look into Policy mapping or route mapping....check out cisco's site at
 
you shouldnt need to set up any NAT or port forwarding on the linux router as long as the internet facing router has a route to the 192.168.2.0/24 network.
Can you ping the IP address you want to port forward to from the internet router?
You might want to check that the linux router is not set to block any ports. That would cause you problems.
 
Are the 2 routers connected to a switch, that is in turn connected to your broadband modem? What exactly is the topology you are using? This would help determine the correct configuration.
 
Ok, in order to forward ports to the machines on the 192.168.2 subnet, you will need to forward the ports on both the Linksys and the Linux routers.

For example, if your web server is running behind the Linux router, you would forward port 80 on the linksys to the Linux's external interface 192.168.1.2, then on your Linux router, forward port 80 to the IP of the web server (192.168.2.x).
 
So that's the only way? Can I set up port forwarding on the Linux router without using NAT?
 
Hardware is nice. Use a Level 3 switch to do the routing.
 
You can, but how will the packets destined for port 80 know where to go when they hit the Linksys router? Without a forward rule in place, the Linksys will just drop them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top