# multiple interfaces / NIC troubles

## teedubb

I have installed gentoo on a soekris box.  It comes with four network interfaces (eth0 - eth3).  I want each interface to reside on a seperate VLAN.  Example below.

```
eth0 -> 192.168.17.200 -> VLAN 1

eth1 -> 192.168.6.200 -> VLAN 2

eth2 -> 192.168.12.200 -> VLAN 3

eth3 -> 192.168.15.125 -> VLAN 4
```

Below is what is in my /etc/conf.d/net

```
config_eth0="192.168.17.200 netmask 255.255.252.0"

routes_eth0="default via 192.168.16.2"

config_eth1="192.168.6.200 netmask 255.255.255.0"

routes_eth1="default via 192.168.6.1"

config_eth2="192.168.12.200 netmask 255.255.255.0"

routes_eth2="default via 192.168.12.1"

config_eth3="192.168.15.125 netmask 255.255.255.224"

routes_eth3="default via 192.168.15.97"
```

My issue is that I can only ping an interface if my workstation is on that VLAN.  So if my workstation is on VLAN 1 then I got no troubles pinging eth0 but cant ping the other interfaces.  If my workstation is on VLAN 2 then I can only ping eth1.  This also goes both ways so "ping -I eth1 192.168.6.x" works but "ping -I eth1 192.168.17.x" does not work.  My workstation can ping any device residing on these VLANs except for the gentoo soekris box so it's not an issue of connectivity to those VLANs it looks like it has something to do with my configuration.  Any suggestions?

----------

## NeddySeagoon

teedubb,

You may have at most one default route, you you need to remove three of the 

```
routes_ethX="default via 192.168.xx.xx"
```

 statements.

Leave the one you want to deal with any packets that do not match other rules in your routing table.

A sketch of your network would be useful. ASCII art in a Code block is adequate.

Sight of your routing table would be good too.  Thats output of 

```
route
```

----------

## cach0rr0

once you do get the routing all set up correctly, you *may* need to check /etc/sysctl.conf and see that you have:

```

net.ipv4.ip_forward =1

```

to set it without rebooting (which of course,will be lost upon reboot if you don't set it in sysctl.conf):

```

echo 1 > /proc/sys/net/ipv4/ip_forward

```

usual bits within iptables too, for the FORWARD chain

Not sure this is going to apply, but it's the most immediate thing that comes to mind.

----------

## TJNII

 *cach0rr0 wrote:*   

> once you do get the routing all set up correctly, you *may* need to check /etc/sysctl.conf and see that you have:
> 
> ```
> 
> net.ipv4.ip_forward =1
> ...

 

That's only needed if this is going to act as a gatway/NAT.  If it is just going to sit on 4 networks, then you don't need the forward bit.  Will this box be acting as a gateway/router forwarding traffic between networks?

You're talking about multiple VLANs going onto this thing, they are all untagged by the switch, yes?  That config won't if you're running tagged traffic into the box.

As NeddySeagoon said, you only want one default.  Pick one.  However, that shouldn't stop you from pinging within the subnets.  Can you post the output of ifconfig and route, please?

----------

## TJNII

 *Quote:*   

> "ping -I eth1 192.168.17.x" does not work.

 

Why would it?  That subnet is on eth0.

 *NeddySeagoon wrote:*   

> A sketch of your network would be useful

 

Very much so.  Please label what devices are supposed to route and act as gateways for network segments.

----------

## teedubb

ifconfig output

```
eth0      Link encap:Ethernet  HWaddr 00:00:24:ca:6b:08                         

          inet addr:192.168.17.200  Bcast:192.168.19.255  Mask:255.255.252.0      

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    

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

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

          collisions:0 txqueuelen:1000                                          

          RX bytes:111389 (108.7 KiB)  TX bytes:1058 (1.0 KiB)                  

          Interrupt:11 Base address:0x6000                                      

                                                                                

eth1      Link encap:Ethernet  HWaddr 00:00:24:ca:6b:09                         

          inet addr:192.168.6.200  Bcast:192.168.6.255  Mask:255.255.255.0        

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    

          RX packets:1176 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:99937 (97.5 KiB)  TX bytes:0 (0.0 B)                         

          Interrupt:5 Base address:0xa100                                       

                                                                                

eth2      Link encap:Ethernet  HWaddr 00:00:24:ca:6b:0a                         

          inet addr:192.168.12.200  Bcast:192.168.12.255  Mask:255.255.255.0      

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    

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

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

          collisions:0 txqueuelen:1000                                          

          RX bytes:11956 (11.6 KiB)  TX bytes:280 (280.0 B)                     

          Interrupt:9 Base address:0xe200                                       

                                                                                

eth3      Link encap:Ethernet  HWaddr 00:00:24:ca:6b:0b                         

          inet addr:192.168.15.125  Bcast:192.168.15.127  Mask:255.255.255.224    

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    

          RX packets:964 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:89117 (87.0 KiB)  TX bytes:0 (0.0 B)                         

          Interrupt:12 Base address:0x2300                                      

                                                                                

lo        Link encap:Local Loopback                                             

          inet addr:127.0.0.1  Mask:255.0.0.0                                   

          UP LOOPBACK RUNNING  MTU:16436  Metric:1                              

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

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

          collisions:0 txqueuelen:0                                             

          RX bytes:2996 (2.9 KiB)  TX bytes:2996 (2.9 KiB) 
```

route output

```
Kernel IP routing table                                                         

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface   

192.168.15.96    *               255.255.255.224 U     0      0        0 eth3    

192.168.6.0      *               255.255.255.0   U     0      0        0 eth1    

192.168.12.0     *               255.255.255.0   U     0      0        0 eth2    

192.168.16.0     *               255.255.252.0   U     0      0        0 eth0    

loopback        localhost       255.0.0.0       UG    0      0        0 lo      

default         192.168.16.2     0.0.0.0         UG    2      0        0 eth0     
```

below is a link to a basic diagram of my setup

http://1dl.us/gkb.png

So I removed all routes except for eth0 but I am still having the same problem, any ideas?

----------

## NeddySeagoon

teedubb,

```
if my workstation is on VLAN 1 then I got no troubles pinging eth0 but cant ping the other interfaces.
```

The routing you have now is fine as far as it goes.

When you are on VLANx, you can ping all of VLANx but not any other VLAN.

Your router needs some static routes to tel it what to do with packets on one VLAN that are destined for another or your Soekris box needs those static routes.

You will also need IPv4 forwarding on in the box doing the routing, so its allowed to pass packets between interfaces.

Its a kernel option, then its controllable via /proc.

```
      # turn on IP forwarding

    echo "1" >/proc/sys/net/ipv4/ip_forward
```

turns it on if its off - you can reat the value.

Your static route net entry from 192.168.12.0 to 192.168.16.0 would be

```
routes_eth0="default via ...

             192.168.16.0 via 192.168.12.x" 
```

where x is the IP of the gateway on the 192.168.12.0/24 net that can forward packets to the  192.168.16.0/24 subnet.

The default via ... can be absent.

You will have three entries for each interface. from vlan1 to vlans 2,3 and 4. From vlan 2 to vlan 1,3 and 4 an so on.

For ping to work, the routs have to be right in both directions

----------

## TJNII

So is the "router" in that diagram the Soekris box, or something else?

----------

