# Two NICs, DHCP and routing - SOLVED

## janpla

I have an annoying problem that I haven't found a solution for on this site:

I have two network cards and configuretheir addresses with DHCP; this gives me:

```

# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:01:6C:AD:09:0A

          inet addr:10.33.2.158  Bcast:10.33.3.255  Mask:255.255.254.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000

          RX bytes:1024912 (1000.8 Kb)  TX bytes:89848 (87.7 Kb)

          Interrupt:10

eth1      Link encap:Ethernet  HWaddr 00:01:03:2E:27:9D

          inet addr:10.33.2.163  Bcast:10.33.3.255  Mask:255.255.254.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000

          RX bytes:89388 (87.2 Kb)  TX bytes:21122 (20.6 Kb)

          Interrupt:5 Base address:0xc000

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:101 errors:0 dropped:0 overruns:0 frame:0

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

          collisions:0 txqueuelen:0

          RX bytes:11326 (11.0 Kb)  TX bytes:11326 (11.0 Kb)

# netstat -nr

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

10.33.2.0       0.0.0.0         255.255.254.0   U         0 0          0 eth0

10.33.2.0       0.0.0.0         255.255.254.0   U         0 0          0 eth1

127.0.0.0       127.0.0.1       255.0.0.0       UG        0 0          0 lo

0.0.0.0         10.33.2.1       0.0.0.0         UG        0 0          0 eth1

0.0.0.0         10.33.2.1       0.0.0.0         UG        0 0          0 eth0

```

As you can see the routing is bad, and as a result I can't find the way out of my machine. How do I set up /etc/conf.d/net so that I avoid this problem? Is there a way avoid setting up routing for eth1?Last edited by janpla on Mon Apr 10, 2006 12:48 pm; edited 1 time in total

----------

## NeddySeagoon

janpla,

You must not have two NICs in the same subnet like that. Stop trying to use them both and it will JustWork.

----------

## janpla

You're wrong - I must actually have those two, and in that way. The problem if I am not much mistaken, is that the routing gets set up wrong, and that is what I ask about. Is there any documentation for the parameters in /etc/conf.d/net?

----------

## janpla

I found the solution: 

In /etc/conf.d/net, just add:

dhcpcd_eth1=( "-h zjan -G" )

The important part of this is the '-G', which tells dhcpcd to ignore routing information from the DHCP server. The explanation was in the Handbook under net work configuration.

----------

## NeddySeagoon

janpla,

Hmm - I would like to see your routing table now. I suspect that eth1 is now not used at all.

----------

## lbrtuk

None of your outgoing packets are going to exit eth1, but maybe that's ok.

----------

## janpla

This is my route table now:

```
# netstat -nr

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

192.168.200.1   0.0.0.0         255.255.255.255 UH        0 0          0 tun0

10.33.2.0       0.0.0.0         255.255.254.0   U         0 0          0 eth0

10.33.2.0       0.0.0.0         255.255.254.0   U         0 0          0 eth1

127.0.0.0       127.0.0.1       255.0.0.0       UG        0 0          0 lo

0.0.0.0         10.33.2.1       0.0.0.0         UG        0 0          0 eth0

```

As you can see outgoing packages only go through eth0, but that is OK. I use iptables to send all traffic on eth1 to a system running in an emulator (zOS in Hercules).

----------

## NeddySeagoon

janpla,

What you have is a horrible hack, still, if it works ...

----------

## janpla

Why do you say it is a 'horrible hack'? My goal in this case is to have 2 network interfaces on the machine: one for the actual machine and one for the emulated one; and as you say, it works.

I would be interested in seeing how you would do it better, since you seem to know. Apparently VMware manages to achieve a similar effect in another way, but I haven't had the energy to study what they do.

----------

## NeddySeagoon

janpla,

Its horrible because you have two interfaces in the same subnet. As you have already found out, this makes a mess of routing.

There is one exception. If you turn on packet forwarding and one of the interfaces provides a PPP link. You don't do that though.

Well, you may have packet forwarding on but your netmask on eth1 is not 255.255.255.255, so its not a point to point link.

----------

