# add route to reach the computer 192.168.1.141

## powah

I want to add route to reach the computer 192.168.1.141 through the gateway 192.168.1.41.

I tried the following but the error is "SIOCADDRT: Network is unreachable".

# route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

172.31.1.0 * 255.255.255.0 U 0 0 0 eth0

169.254.0.0 * 255.255.0.0 U 0 0 0 eth0

default 172.31.1.1 0.0.0.0 UG 0 0 0 eth0

# ping 192.168.1.41

PING 192.168.1.41 (192.168.1.41) 56(84) bytes of data.

64 bytes from 192.168.1.41: icmp_seq=0 ttl=64 time=61.7 ms

64 bytes from 192.168.1.41: icmp_seq=1 ttl=64 time=1.53 ms

64 bytes from 192.168.1.41: icmp_seq=2 ttl=64 time=56.1 ms

--- 192.168.1.41 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2002ms

rtt min/avg/max/mdev = 1.538/39.821/61.780/27.168 ms, pipe 2

# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.41

SIOCADDRT: Network is unreachable

----------

## Dlareh

please edit your post to add [ code ] tags and include ifconfig -a for good measure

----------

## powah

I want to add route to reach the computer 192.168.1.141 through the gateway 192.168.1.41.

I tried the following but the error is "SIOCADDRT: Network is unreachable".

```

# route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

172.31.1.0 * 255.255.255.0 U 0 0 0 eth0

169.254.0.0 * 255.255.0.0 U 0 0 0 eth0

default 172.31.1.1 0.0.0.0 UG 0 0 0 eth0

# ping 192.168.1.41

PING 192.168.1.41 (192.168.1.41) 56(84) bytes of data.

64 bytes from 192.168.1.41: icmp_seq=0 ttl=64 time=61.7 ms

64 bytes from 192.168.1.41: icmp_seq=1 ttl=64 time=1.53 ms

64 bytes from 192.168.1.41: icmp_seq=2 ttl=64 time=56.1 ms

--- 192.168.1.41 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2002ms

rtt min/avg/max/mdev = 1.538/39.821/61.780/27.168 ms, pipe 2

# ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:30:48:83:14:53

          inet addr:172.31.1.100  Bcast:172.31.1.255  Mask:255.255.255.0

          inet6 addr: fe80::230:48ff:fe83:1453/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1027858 errors:0 dropped:0 overruns:0 frame:0

          TX packets:908024 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:198692206 (189.4 Mb)  TX bytes:674441371 (643.1 Mb)

          Base address:0xc000 Memory:f2000000-f2020000

eth1      Link encap:Ethernet  HWaddr 00:30:48:83:E9:87

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

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

          collisions:0 txqueuelen:1000

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

          Base address:0xd100 Memory:f1000000-f1020000

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:76218 errors:0 dropped:0 overruns:0 frame:0

          TX packets:76218 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:13805088 (13.1 Mb)  TX bytes:13805088 (13.1 Mb)

sit0      Link encap:IPv6-in-IPv4

          NOARP  MTU:1480  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

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

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.41

SIOCADDRT: Network is unreachable

```

 *Dlareh wrote:*   

> please edit your post to add [ code ] tags and include ifconfig -a for good measure

 

----------

## Ph0eniX

 *powah wrote:*   

> I want to add route to reach the computer 192.168.1.141 through the gateway 192.168.1.41.
> 
> I tried the following but the error is "SIOCADDRT: Network is unreachable".
> 
> ```
> ...

 

The problem is that you can't reach the gateway/router you're specifying since it's on a different network.  It needs to be on the same network as your interface (eth0) address or there has to be another router in between knowing how to reach that network.Last edited by Ph0eniX on Thu Sep 01, 2005 4:54 pm; edited 1 time in total

----------

## Taladar

You could try:

```

route add 192.168.1.141 netmask 255.255.255.255 gw 192.168.1.41

```

When you specify a route to the whole subnet you override the use of the default route for the connection

to 192.168.1.41 and your computer doesn't find that one anymore (it would work that way if you were in the 192.168.1.0/24 subnet

yourself but according to your routing table and interfaces you are not directly connected to 192.168.1.41).

----------

## powah

It still does not work.

```

# route add 192.168.1.141 netmask 255.255.255.255 gw 192.168.1.41

route: netmask 00000000 doesn't make sense with host route

Usage: route [-nNvee] [-FC] [<AF>]           List kernel routing tables

       route [-v] [-FC] {add|del|flush} ...  Modify routing table for AF.

       route {-h|--help} [<AF>]              Detailed usage syntax for specified AF.

       route {-V|--version}                  Display version/author and exit.

        -v, --verbose            be verbose

        -n, --numeric            don't resolve names

        -e, --extend             display other/more information

        -F, --fib                display Forwarding Information Base (default)

        -C, --cache              display routing cache instead of FIB

  <AF>=Use '-A <af>' or '--<af>'; default: inet

  List of possible address families (which support routing):

    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)

    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)

    x25 (CCITT X.25)

```

 *Taladar wrote:*   

> You could try:
> 
> ```
> 
> route add 192.168.1.141 netmask 255.255.255.255 gw 192.168.1.41
> ...

 

----------

## Dlareh

```
 ifconfig eth0:1 192.168.1.xxx
```

----------

## swimmer

 *Dlareh wrote:*   

> 
> 
> ```
>  ifconfig eth0:1 192.168.1.xxx
> ```
> ...

 

Sorry, but I do not understand what you reach with that :-/

Can you please explain a bit more?

Thanks in advance

swimmer

----------

## powah

I don't understand.

Please explain.

Thanks.

 *Dlareh wrote:*   

> 
> 
> ```
>  ifconfig eth0:1 192.168.1.xxx
> ```
> ...

 

----------

## bluedevils

The problem is the gateway you specified.  Your eth0 is on the 172.31.1. network.  The gateway has to be a 172.31.1.x network address.  Your default gateway is 172.31.1.1 so that means it will currently go through that interface to find the 192.168.1. network.

What device physically connects your 172.31.1. network to your 192.168.1. network?  This device would have to have interfaces on both networks and be able to forward data onto the 192.168.1. network.  The interface on the 172.31.1. network is what you want to specify.

eg If you have a router or computer that has interfaces at 172.31.1.3 and 192.168.1.41, then your command would be:

```
route add 192.168.1.141 netmask 255.255.255.0 gw 172.31.1.3
```

See that the 192.168.1.41 is irrelevant.  Think of it like looking for a doorway to the outside.  You don't look for the "555 broadway" street address.  You look for the exit sign.

----------

## Dlareh

 *powah wrote:*   

> I don't understand.
> 
> Please explain.
> 
> Thanks.
> ...

 

This will create a 2nd IP for eth0.  Replace xxx with any 192.168.1.* address that is not being used.

----------

## bluedevils

hmmm....I just realized that you were pinging the 192.168.1.41 interface.  Doesn't that means it is on the otherside of your default gateway?  If you can ping the 192.168.1.41 interface, then that means you should be able to reach the 192.168.1.141 interface as well without a route statement.

----------

