# Problem with Having two Network Cards in System ...

## ckoeber

Hello,

I have a system with two network cards. The cards are configured for DHCP for two separate networks and they get their respective IP addresses from the different DCHP servers.

The problem is that the network access on <I>either</I> network is sporatic at best. The networks are as follows:

First, my network config file:

<B>/etc/conf.d/net</B>

-----------------------------

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

config_eth0=( "dhcp" )

dhcpcd_eth0="-N"

config_eth1=( "dhcp" )

dhcpcd_eth1="-N"

-----------------------------

<B>ETH0:</B>

This is on a Gigabit network and I rarely, if ever, get access on this network. This is an add-in card that I added after the initial installation.

Here is the ifconfig of eth0

-----------------------------

eth0      Link encap:Ethernet  HWaddr 00:26:f2:ac:c9:df  

          inet addr:10.10.50.68  Bcast:10.10.50.255  Mask:255.255.255.0

          inet6 addr: fe80::226:f2ff:feac:c9df/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000 

          RX bytes:5631144 (5.3 MiB)  TX bytes:237966 (232.3 KiB)

          Interrupt:23 Base address:0xc000 

-----------------------------

<B>ETH1:</B>

This is on a 10/100 network and I get access sporatically on this network. This card is a built-in card.

Here is the ifconfig of eth1

-----------------------------

eth1      Link encap:Ethernet  HWaddr 00:b0:d0:fc:51:c7  

          inet addr:10.60.1.1  Bcast:10.60.255.255  Mask:255.255.0.0

          inet6 addr: fe80::2b0:d0ff:fefc:51c7/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000 

          RX bytes:63730861 (60.7 MiB)  TX bytes:17820579 (16.9 MiB)

-----------------------------

Now, both networks neet to be operational as I would like for the system itself to be able to contact both networks and run services for each network. However, the networks will NOT be bridged by the server in question.

When i originally set up the system everything worked fine.

What do I need to do to make sure the system communicates to the networks in question?

Thank you for your time.

----------

## DONAHUE

use fixed ip's not dhcp

----------

## nativemad

I don't think that it actually matters how the IP's are assigned...

What can cause problems are similar routes on both nics!

Ckoeber, you havent mentioned if you are on the same subnets with the clients as the desired nic, or if there are maybe also routers in between....

Could you post to output of a "route -n"?

...if you have multiple default gateways you will need to use iproute2!

----------

## ckoeber

 *DONAHUE wrote:*   

> use fixed ip's not dhcp

 

I tried this but I had the same issue. Is there something else I need to do?

The goal is to have ETH0 as the primary interface where the system accesses network resources, etc. and ETH1 as an interface that is simply serving the seperate network that it is connected to.

----------

## ckoeber

 *nativemad wrote:*   

> I don't think that it actually matters how the IP's are assigned...
> 
> What can cause problems are similar routes on both nics!
> 
> Ckoeber, you havent mentioned if you are on the same subnets with the clients as the desired nic, or if there are maybe also routers in between....
> ...

 

route -n:

```

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

10.10.50.0      0.0.0.0         255.255.255.0   U     1      0        0 eth0

10.60.0.0       0.0.0.0         255.255.0.0     U     0      0        0 eth1

127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo

0.0.0.0         10.60.0.1       0.0.0.0         UG    0      0        0 eth1

0.0.0.0         10.10.50.1      0.0.0.0         UG    1      0        0 eth0

```

Upon reading this, it looks like I have multiple gateways, right?

----------

## DONAHUE

yup

delete from /etc/conf.d/net

routes_eth1=( "default gw 10.60.0.1" )

----------

## ckoeber

 *DONAHUE wrote:*   

> yup
> 
> delete from /etc/conf.d/net
> 
> routes_eth1=( "default gw 10.60.0.1" )

 

Thanks. I will try this now.

If I declare only one gateway for, say, the ETH0 interface, will systems still be able to access the ETH1 interface?

----------

## DONAHUE

to be tedious but hopefully clear:

any computer interface on the 10.60.1.0/24 subnet should be able to access any other computer interface on the 10.60.1.0/24 subnet.

any computer interface on the 10.60.1.0/24 subnet should not be able to access any computer interface on the 10.10.50/24 subnet.

any computer interface on the 10.60.0.0/16 subnet should not be able to access any computer interface not on the 10.60.0.0/16 subnet.

any computer interface on the 10.60.1.0/24 subnet may not be able to access any computer interface on the 10.60.x.0/16 subnet where x is from 2 to 254.

your interfaces on the 10.60.1 will not be able to connect to the internet unless a gateway that is not 10.60.1.1 is provided or 10.60.1.1 is made a bridge.

----------

## ckoeber

 *DONAHUE wrote:*   

> to be tedious but hopefully clear:
> 
> any computer interface on the 10.60.1.0/24 subnet should be able to access any other computer interface on the 10.60.1.0/24 subnet.
> 
> any computer interface on the 10.60.1.0/24 subnet should not be able to access any computer interface on the 10.10.50/24 subnet.
> ...

 

Well, I can come back to this for the moment as I cannot get ANY interface up:

Here is my current /etc/conf.d/net file:

```

config_eth0={ "10.10.50.68 netmask 255.255.255.0" }

routes_eth0={ "default via 10.10.50.1" }

config_eth1={ "10.60.1.1 netmask 255.255.0.0" }

```

With this configuration I get NO access at all. Having it with DHCP I get sporadic access.

I set the IP's to static per a suggestion here.

What else do I need to do to get both interfaces talking on the two separate networks? I don't want them bridged but is that needed?

Also, I would like to install iproutes2 as suggested bhut I can't do it without access.

Thanks.

----------

## DONAHUE

Not curly braces:

 *Quote:*   

> config_eth0=( "10.10.50.68 netmask 255.255.255.0" ) 
> 
> routes_eth0=( "default via 10.10.50.1" ) 
> 
> dns_servers_eth0="4.2.2.6"
> ...

 

are you using openrc and baselayout2?

If so, no braces and spaces: 

 *Quote:*   

> config_eth0="10.10.50.68 netmask 255.255.255.0" 
> 
> routes_eth0="default via 10.10.50.1"
> 
> dns_servers_eth0="4.2.2.6"
> ...

 

----------

## ckoeber

 *DONAHUE wrote:*   

> Not curly braces:
> 
>  *Quote:*   config_eth0=( "10.10.50.68 netmask 255.255.255.0" ) 
> 
> routes_eth0=( "default via 10.10.50.1" ) 
> ...

 

Well, the settings are applied as I see the configuration that I set when I do an ifconfig and route -n

Anything else?

Thanks.

----------

## DONAHUE

curly braces  {}  in these /etc/conf.d/net lines kill, they are not allowed where you have them

if you changed the /etc/conf.d/net to match one of the two choices above (depending on whether you use openrc or not) next step is to run:

```
/etc/init.d/net.eth0 restart

/etc/init.d/net.eth1 restart

ping -c 2 google.com #should work

ping -I eth0 -c 2 google.com #should work

ping -I eth1 -c 2 google.com #should fail --> Destination Host Unreachable

```

----------

## nativemad

Could it be that you've accidentally switched the cables or the names from eth0 and eth1!?

You should at least be able to reach the router 10.10.50.1.

Maybe it's easier to test the whole thing manually from the console...

```
ifconfig eth1 down

ifconfig eth0 10.10.50.68 netmask 255.255.255.0

ping 10.10.50.1 #if that doesn't work right now, i would say you've got a wiring problem otherwise you can move on like

route add default gw 10.10.50.1

ping 8.8.8.8 #an official google dns server... if this works, move on to the next eth

ifconfig eth1 10.60.1.1 netmask 255.255.0.0

ping 10.60.0.1 # the other gateway should now work as well

echo nameserver 8.8.8.8 >>/etc/resolv.conf #this is just a dns example.. 
```

You only need iproute2 if you would like to use multiple routes to one destination (the well known example would be the default gateway/route).

----------

