# Routing table configuration

## lostinspace2011

My network consists of one linux server which two network interfaces (eth0 - 192.168.0.3 and eth1 - 192.168.0.4) and several other computers. Both network interfaces are connected to the same subnet. ETH0 is the "public" interface on which I have the external DNS server running for the websites hosted on the server. ETH1 is the "internal" interface which runs the internal DNS server used by all the computers on the network.

I set the metric on eth1 to be higher than the one on eth0 to prevent routing issues.

```
bumblebee ~ # route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.0.0     *               255.255.255.0   U     100    0        0 eth0

192.168.0.0     *               255.255.255.0   U     200    0        0 eth1

loopback        *               255.0.0.0       U     0      0        0 lo

default         gateway....     0.0.0.0         UG    100    0        0 eth0

```

Most of the time this is all working but every so often some of the clients loose access to 192.168.0.4. It seems to be mostly Macs which are affected by this. Currently I just reset the DHCP lease which seem to fix this problem for the short term, but this has become tedious and frustrating. 

Any suggestions on what I can do to diagnose the cause of this problem? When it occurs it looks like 192.168.0.4 has disappeared from the network on the affected computers, while it's accessible for the other on the network.

Thanks in advance for any insight.

Alex

----------

## dE_logics

 *Quote:*   

> Both network interfaces are connected to the same subnet. ETH0 is the "public" interface on which I have the external DNS server running for the websites hosted on the server. ETH1 is the "internal" interface which runs the internal DNS server used by all the computers on the network. 

 

This cant happen.

The internet and internal network cant be on the same network... or do you mean they have the same subnet (for e.g. 255.0.0.0).

----------

## Hu

Based on the IP addresses posted, I believe he has a Gentoo system with two NICs and both NICs have addresses on the same subnet.  He also has a NAT device configured to forward DNS and web requests to the IP address that is assigned to eth0.

This seems like a poor network design.  Generally, placing distinct interfaces on the same subnet will lead to various subtle failures.  The solution is not to place both interfaces on the same subnet.  If the network cannot be rewired, and all services must be offered from the same machine, then I suggest assigning both IP addresses to a single interface.  The interface can optionally be a logical interface, such as a bond of the two physical interfaces.

----------

## dE_logics

Even more confusing is the fact that the internet and the internal network are on the same subnet.

In my case, when I get direct internet access (using ppp), the subnet is 255.255.255.255, i.e. I don't belong to any network.

----------

## luispa

This is wrong, re-design it correctly. Easier is to setup a new subnet for the public part, which should have few hosts (probably the router and the linux on that side). So you only need to change two configs, the router LAN setup and the linux eth0 bound address/mask + default gw.

example: eth0 phy network with 192.168.1/24 and leave eth1 phy network with 192.168.0/24. 

luis

----------

## lostinspace2011

Sorry I didn't explain my setup better. Basically I one a single network which is NAT'd behind one router. I am forwarding external DNS requests to one of the eth0 (192.168.0.3) on my server. This allows me to host my own DNS records for my domains. I am also using eth1 (192.168.0.4) to host a DNS cache so I don't have to go outside my network for DNS every time. 

I don't really want to go to the extend of separating my entire network just to have my own DNS servers. I don't have any other services running which require this. I think the suggestion to use an alias address on the same adaptor will work better. I just thought since I have two network cards available I might as well use them. Most of the time this works well, however from time to time (every other day) it causes a problem on the clients. Usually I resolve these by refreshing their DHCP leases or unplugging / replugging the network cable. I was hoping to get some assistance in diagnosing the problem further. For example I would like to see where the packets get stuck. For example if the server is receiving the DNS requests from the client and if the server is not sending them back correctly, or if the client is not able to connect to the server properly. 

I am guessing that wireshark / ethereal would help. Any other pointers.

----------

## gentoo_ram

Here's the basic problem with your setup... Let's say a computer 192.168.0.10 wants to talk to 192.168.0.4.  It tries to open a TCP connection to 192.168.0.4.  Your computer responds to 192.168.0.10.  According to your routing table, that packet should go out eth0.  The response going back to 0.10 now comes back from 0.3.  But 0.10 isn't listening for responses from 0.3, it was trying to talk to 0.4.  See the problem?  Your routing table makes it so that no responses to computers on your subnet can come from 0.4.

It might work sometimes based on the current state of the ARP tables in the various machines.  But it won't be reliable and may not work at all.  

It might work on DNS only if the request can come over UDP.  And that's only because the implementation of bind (the name serving daemon) is coded to communicate with specific interfaces and can send back responses on specific interfaces.

If your application is using UDP and only if the application is written to specifically open a socket on a specific interface will your dual interface setup work.  But most applications not coded that way and won't work.  And if the name request is too large and must go over TCP, the request probably won't work at all.  Like you're seeing.

----------

## lostinspace2011

Is there an option to configure my routing table to have any traffic which came in on 0.4  go out on 0.4 as well ?

----------

