# routes_eth0 documentation? [SOLVED]

## ulmi

I'm trying to configure my NIC with the /etc/conf.d/net.eth0 script, but I couldn't find any documentation about the syntax the routes_eth0 variable expects. Perhaps I'm just missing something obvious.

The routes I would like to add:

route add -host 10.0.0.1 dev eth0

route add -host 10.0.0.2 dev eth0

route add default gw 10.0.0.1

I tried setting routes_eth0 to the following:

routes_eth0=(   "-host 10.0.0.1 dev eth0" "-host 10.0.0.2 dev eth0" "default gw 10.0.0.1")

but I get a syntax error with the host-specific routes.Last edited by ulmi on Mon Nov 27, 2006 7:35 pm; edited 1 time in total

----------

## NeddySeagoon

ulmi,

Welcome to gentoo.

You will find what you are looking for in /etc/conf.d/net.example, its a fully documented net file.

----------

## ulmi

the only thing I found in the net.example file concerning routes was the following:

 *Quote:*   

> 
> 
> # Here's how todo routing if you need it
> 
> #routes_eth0=(
> ...

 

this doesn't tell me how to set a Interface as Destination instead of a IP-Address.

I tried  "10.0.0.1/32 via dev eth0" and "10.0.0.1/32 via eth0" but neither of it worked.

----------

## NeddySeagoon

ulmi,

Do not specify the interface. Its inferred from the 

```
routes_eth0
```

That says everything that follows is reached using eth0.

I'm not sure why you want the host specific routes

```
routes_eth0=(

   "default via 10.0.0.1" 

 )
```

sends all other packets to 10.0.0.1 as being the default to get to other networks.

You get a route associated with your own IP for your default subnet without asking for it.

From your original post 

```
route add -host 10.0.0.1 dev eth0

route add -host 10.0.0.2 dev eth0

route add default gw 10.0.0.1 
```

the -host route to 10.0.0.1 is redundant as its also your defualt gateway.

----------

## ulmi

NeddySeagoon,

My IP-Address is 10.0.0.2/32, which means I don't get a route associated with 10.0.0.1 automatically

(sorry for not stating that in my first post).

If I configure the routes manually it works just fine.

Output of route -n:

```

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

10.0.0.1   0.0.0.0         255.255.255.255 UH    0      0        0 eth0

10.0.0.2    0.0.0.0         255.255.255.255 UH    0      0        0 eth0

127.0.0.0  0.0.0.0         255.0.0.0       U     0      0        0 lo

0.0.0.0     10.0.0.1    0.0.0.0         UG    0      0        0 eth0

```

 *Quote:*   

> 
> 
> Do not specify the interface. Its inferred from the 
> 
> Code:	
> ...

 

If I do not specify the Interface(routes_eth0="10.0.0.1/32") I get a 'SIOCADDRT: Invalid argument' Error-Message

----------

## NeddySeagoon

ulmi,

I added in a static route to my existing setup, which is all static. Its the -host line below

```
config_eth_lan=(

       "192.168.100.18/24 broadcast 192.168.100.255"

)

routes_eth_lan=(

       "default via 192.168.100.1"

       "-net 192.168.0.0/24 via 192.168.100.6"

       "-host 10.0.0.1"

)
```

The message

```
 * Starting eth_lan

 *   Bringing up eth_lan

 *     192.168.100.18/24                                                  [ ok ]

 *   Adding routes

 *     default via 192.168.100.1 ...                                      [ ok ]

 *     -net 192.168.0.0/24 via 192.168.100.6 ...                          [ ok ]

 *     -host 10.0.0.1 ...                                                 [ ok ]
```

looks good as does

```
$ /sbin/route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

10.0.0.1        *               255.255.255.255 UH    0      0        0 eth_lan

192.168.100.0   *               255.255.255.0   U     0      0        0 eth_lan

192.168.101.0   *               255.255.255.0   U     0      0        0 eth_spare

192.168.0.0     192.168.100.6   255.255.255.0   UG    0      0        0 eth_lan

loopback        *               255.0.0.0       U     0      0        0 lo

default         Moriarty        0.0.0.0         UG    0      0        0 eth_lan
```

Add your host based routes, one per line, using the syntax above.

----------

## ulmi

Thanks a lot NeddySeagoon, that worked.

----------

