# [SOLVED] Gentoo routing - multiple NICs

## cezar.serban

Hello.

I work for a small telecom company which uses Gentoo for our routers.

I will attempt to describe my setup. The router has 2 NICs, one is used for LAN traffic, the other is the uplink with our ISP.

The LAN has 4 /28 subnets, and the various hosts use the router's interface as the default GW.

The WAN has a /30 subnet, one IP for the router and the other one for the ISP and is setup as the default route.

Below is the config. It's fairly simple (I had to change the IP addresses for security reasons).

```
config_eth0=(

        "10.10.10.130/30"

)

config_eth1=(

        "1.1.1.137/28"

        "2.2.2.129/28"

        "3.3.3.101/28"

        "4.4.4.17/28"

)

routes_eth0=(

        "default via 10.10.10.129"            # IPv4 default route

)
```

Right now I have an HP 360 server with an older version which is setup with this config and packets are being forwarded correctly.

However, I have installed a new snapshot of Gentoo on a Dell 1950 server and using the exact same configuration, the LAN hosts cannot reach the router. However, I do have Layer 3 connectivity on both NICs.

How should I configure the /etc/conf.d/net file in order to have correct routing?

I tried the following config, since I read that now you have to also include the subnets in the route statement as an array.

```

        routes_enp5s0=(

           "1.1.1.128/28  gw 1.1.1.137"

           "2.2.2.128/28 gw 2.2.2.2.129"

           "3.3.3.96/28 gw 3.3.3.101

           "4.4.4.16/28 gw 4.4.4.17

       "default via 10.10.10.129"

        )    

```

I hope I made my case clear. If not,I can try to explain in a different way.

Note: enp5s0 is eth0, renamed due to udev changes.

Thank you for your time.Last edited by cezar.serban on Tue Aug 13, 2013 10:53 pm; edited 1 time in total

----------

## 666threesixes666

i put requested articles in for brid, and quagga...  see if the original router has these.

----------

## py-ro

Did you enable forwarding?

```
cat /proc/sys/net/ipv4/ip_forward
```

----------

## NeddySeagoon

cezar.serban,

Welcome to Gentoo.

The syntax you are using is for baselayout1 but that has been obsolete for 2 years or so now.

My system has

```
config_eth0="5.135.178.112/24 brd 5.135.178.255

             2001:41d0:8:b970::2/56"

routes_eth0="default via 5.135.178.254

             default via 2001:41d0:8:b9ff:ff:ff:ff:fd"
```

This makes your         

```
routes_enp5s0=(

           "1.1.1.128/28  gw 1.1.1.137"

           "2.2.2.128/28 gw 2.2.2.2.129"

           "3.3.3.96/28 gw 3.3.3.101

           "4.4.4.16/28 gw 4.4.4.17

       "default via 10.10.10.129"

        )    
```

incorrect in several counts.  use via not gw, remove the ()  and fix the double quotes.

I trust the the quotes are missing only in your post and not in your net file?

Paste the output of route if fixing your net file and restarting net.enp5s0 fails.

----------

## cezar.serban

Sorry,I am not aware of what "brid" means. I assume it refers to bridging but this was not the case with the original router. Quagga was not used, just a static route via the ISP's IP address.

Yes, IP forwarding is enabled.

----------

## NeddySeagoon

cezar.serban,

It looks like our posts crossed in flight.  See above ^^^

----------

## cezar.serban

 *NeddySeagoon wrote:*   

> cezar.serban,
> 
> Welcome to Gentoo.
> 
> The syntax you are using is for baselayout1 but that has been obsolete for 2 years or so now.
> ...

 

Thank you for your quick reply.

Just to clarify, placing the subnets in route_enp5s0 is correct? They are configured on the LAN interface.

The quotes are missing only in the post.

----------

## NeddySeagoon

cezar.serban,

I have the subnets in the config_ statement.   There they generate the correct gateway free routes for all the hosts in the subnet.

There is a well commented example net file at /usr/share/doc/openrc-0.11.8/net.example.bz2 that explains how to set up the net file.

----------

## cezar.serban

 *NeddySeagoon wrote:*   

> cezar.serban,
> 
> I have the subnets in the config_ statement.   There they generate the correct gateway free routes for all the hosts in the subnet.
> 
> There is a well commented example net file at /usr/share/doc/openrc-0.11.8/net.example.bz2 that explains how to set up the net file.

 

I read the configuration file before but it did not really help me understand how to configure the interfaces.

The reason why I keep asking is because this router has to be set up during a maintenance work in order to avoid disrupting services.

In theory, should the following config allow for LAN traffic to pass via my WAN one? enp5s0 is WAN, enp9s0 is LAN.

 *Quote:*   

> config_en5s0="10.10.10.130/30 brd 10.10.10.131" 
> 
> config_enp9s0="1.1.1.137/28 brd ...
> 
>                         2.2.2.129/28 brd ...
> ...

 

Please let me know if this is correct or not, I seem to be having some trouble grasping a few basic concepts.

----------

## 666threesixes666

net-misc/bird

A routing daemon implementing OSPF, RIPv2 & BGP for IPv4 or IPv6

net-misc/quagga

A free routing daemon replacing Zebra supporting RIP, OSPF and BGP

id like to get a fierce routing wiki going, but unfortunately do not have the skils.  i can get to the point of pointing at and installing the packages.  i like static routes, so id be interested in the solution you get also.

----------

## cezar.serban

 *666threesixes666 wrote:*   

> net-misc/bird
> 
> A routing daemon implementing OSPF, RIPv2 & BGP for IPv4 or IPv6
> 
> net-misc/quagga
> ...

 

We do use quagga but on other routers. My company also has some /24 subnets which need to be advertised via BGP but in this case I just need static routing.

----------

## 666threesixes666

i found a tutorial online of static routing via quagga....  http://openmaniak.com/quagga_case1.php  i dont know the date or accuracy to it.  it seems as if this would be a good solution for your case as your office already runs quagga on other machines.

oh snap, looks like its already been done....  https://wiki.gentoo.org/wiki/Static_Routing

----------

## cezar.serban

I believe some confusion has been created as as results of the many replies posted in this thread.

I do not want/need to use Quagga for this router because all I need is a static route. I do not need a routing protocol which would only cause overhead when I only have a few internal networks which have 1 exit interface.

Could it be a problem with the kernel itself when routing?

----------

## py-ro

I ask again, did you enable Forwarding?

----------

## NeddySeagoon

cezar.serban,

Post your net file as it is now.

Post the output of the route command, so we can see the routing table your net file generates.

Do not copy type.  Use wgetpaste if you prefer.  You will need to emerge it.

----------

## cezar.serban

Hello again.

It seems the problem was with the vlans on our Switch. The configuration was correct after all. 

I have marked the thread as solved. Thank you again for all your help.

----------

