Setting up linux routing

9,852

The 149.x.x.x host wouldn't be on your local subnet, so your computer would have no way of contacting it. A router between your subnet and that subnet should have both a 149.x and a 172.x address (on two different NICs hopefully), it would route between the two subnets.

Share:
9,852

Related videos on Youtube

Sagar
Author by

Sagar

I'm a software engineer, working as part of an Infrastructure & Tools Team. My main interests are in Python, C, and C++ development, and continuous integration methodologies (including infrastructure tools such as Jenkins). I also love refactoring old/legacy software.

Updated on September 17, 2022

Comments

  • Sagar
    Sagar over 1 year

    The system I'm trying to set up has an IP address 172.31.2.1. Its default gateway is 172.31.254.1. This works fine, and I can reach anything the gateway allows me to go to (172.31.0.0/16 + 149.244.178.0/24).

    There is another gateway at 149.244.178.1 which will allow me to reach anything in 149.244.0.0, and I'm trying to add that to the table so I can access 149.244.64.250.

    This is what my routing table currently looks like:

    Kernel IP Routing table
    Destination    Gateway      Genmask      Flags    Metric    Ref    Use    Iface
    172.31.0.0     *            255.255.0.0  U        0         0        0    eth0
    169.254.0.0    *            255.255.0.0  U        0         0        0    eth0
    default        172.31.254.1 0.0.0.0      UG       0         0        0    eth0
    

    route add 149.244.0.0/16 gw 149.244.178.1 gives the error:

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

    route add -net 149.244.0.0/16 dev eth0 changes the route table to:

    Kernel IP Routing table
    Destination    Gateway      Genmask      Flags    Metric    Ref    Use    Iface
    172.31.0.0     *            255.255.0.0  U        0         0        0    eth0
    169.254.0.0    *            255.255.0.0  U        0         0        0    eth0
    149.244.0.0    *            255.255.0.0  U        0         0        0    eth0
    default        172.31.254.1 0.0.0.0      UG       0         0        0    eth0
    

    However, trying to add the gateway still gives me the same error. Sorry if it sounds convoluted, and any help is appreciated!

  • Zoredache
    Zoredache over 13 years
    Or to put it a different way. Your routes always should specify a gateway on the directly attached networks that will be the next hop.
  • Sagar
    Sagar over 13 years
    Ok. I thought that was the case, but was hoping against hope. Oh well.