# routing issues over two subnets

## robinmarlow

Hello all,

I'm sure this is due to my ignorance around exactly how netmasks work,  but i still can't figure this one out.

I have a cable modem connected to my dlink 614+ router (198.162.0.1) which serves several computers on 198.162.0.x

With a default gateway of 192.168.0.1 & a netmask of 255.255.255.0 on the computers everything works.

except the cable modem occasionally needs resetting & i can just unplug it.   or it can be done from its web interface at 192.168.100.1.

but i can't figure out how to route this.

i thought intially that just changing my box to have a netmask of 255.255.0.0 might work.  it didn't.

so i also changed the router to a mask of the same,  no dice

currently on my main box

```

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.0.0     *               255.255.255.0   U     0      0        0 eth0

loopback        *               255.0.0.0       U     0      0        0 lo

default         router          0.0.0.0         UG    0      0        0 eth0

>ifconfig 

eth0      Link encap:Ethernet  HWaddr 00:0B:2B:14:66:D6  

          inet addr:192.168.0.8  Bcast:192.168.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:6016602 errors:26 dropped:25 overruns:25 frame:0

          TX packets:6636204 errors:0 dropped:0 overruns:48 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:2243048385 (2139.1 Mb)  TX bytes:317152963 (302.4 Mb)

          Interrupt:10 Base address:0xf00

```

i tried

```
route add -host 192.168.100.1 netmask 255.255.0.0 eth0

route: netmask 0000ffff doesn't make sense with host route
```

Any other suggestions?

----------

## Airpizza

You need to set your local network to 192.168 instead of 198.162. The ip 198.162 is not a private ip used for local networks, while the 192.168 is.

Your subnet mask should be 255.255.255.0 also.

----------

## TheX

Take a loot at this Howto :

http://gentoo-wiki.com/HOWTO_setup_a_home-server#Configuring_masquerading_and_basic_firewall

TheX

----------

## robinmarlow

oops that'll teach me to post before bed!

where ever i wrote 198.162.x.x i meant 192.168.x.x

I don't see how ip masquerading helps me - i can't run that on my router and that is acting as the gateway.

i suppose more my question is that - 

if the router has an ip of 192,158.0.1 and a netmask of 255.255.0.0

and my computer 192.168.0.8 n/m 255.255.0.0 g/w 192.168.0.1

why can i not ping 192.168.100.1?

----------

## Makido

Did you look at the man-pages?

Here an example:

```

route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0

adds a route to the network 192.56.76.x via "eth0". The Class C netmask  modifier  is  not  really

necessary here because 192.* is a Class C IP address. The word "dev" can be omitted here.

```

I think, you should try:

```

route add -net 192.168.100.0 netmask 255.255.0.0 dev eth0

```

Regards,

Maik

----------

## Airpizza

 *robinmarlow wrote:*   

> oops that'll teach me to post before bed!
> 
> where ever i wrote 198.162.x.x i meant 192.168.x.x
> 
> I don't see how ip masquerading helps me - i can't run that on my router and that is acting as the gateway.
> ...

 

I think that its impossible to have that subnet mask of 255.255.0.0

255.255.255.0 and above are the ones that can be used for the 192.168 ip.

----------

## thepustule

You can definitely have a netmask of 255.255.0.0 if you want to.  As long as all of your hosts are configured in a matching manner, it will work.

As for pinging 192.168.100.1 - you should be able to do it, IF 192.168.100.1 is on the same physical subnet as all of your other machines.

When you use a netmask of 255.255.0.0 you are telling your computer that 192.168.any.thing is on the same subnet as you, and you don't need to go through a gateway.

Remember, the netmask tells your IP stack about your LOCAL segment - when you use 192.168.0.0/255.255.0.0 you are telling your IP stack that it can directly access any machine from 192.168.0.0 all the way up to 192.168.255.255 directly on the same hub or switch as itself - no gateway necessary.  Theoretically this means you can have up to 65534 computers on the same switch.  Your computer won't even TRY to use the gateway unless the machine you are trying to reach is outside this network range.  That could be something like 192.169.4.4 or 192.167.2.2 or anything as long as it's not 192.168.  It is VERY likely that your network is NOT set up like this, even though it is possible to do it.

If your 192.168.100.1 is on a different network, you will never reach it this way.

It's a little weird that you are saying your router has an IP address of 192.168.0.1 and a web admin address of 192.168.100.1.  Well, which is it?  Does your router have two different interfaces, with both of these addresses?  Or have you tried browsing to 192.168.0.1?

A little more explanation of the setup of your router would help.  Other than that, some details of where this mysterious 192.168.100.1 host is located in relation to the rest of your network.

----------

