# home router: DHCP doesn't work and LAN adapter fubars DNS

## blackdragonblood

I'm setting up a home router.  I have two issues right now.

1. Client times out waiting for DHCP

2. net.eth1 (LAN adapter) fubars DNS resolution on the router.  I can't emerge --sync or pull up any webpages.  I can stop eth1 and restart eth2 to get networking.

log: *Quote:*   

> 
> 
> Jul 23 10:22:16 [dhcpd] Internet Systems Consortium DHCP Server V3.0.3-Gentoo-r9
> 
> Jul 23 10:22:16 [dhcpd] Copyright 2004-2005 Internet Systems Consortium.
> ...

 

/etc/dhcp/dhcpd.conf

```
default-lease-time 3600;

max-lease-time 7200;

authorative;

log-facility local7;

ddns-update-style ad-hoc;

subnet 192.168.0.0 netmask 255.255.255.0 {

        range 192.168.0.100 192.168.0.250;

        option subnet-mask 255.255.255.0;

        option netbios-name-servers 192.168.0.1;

        option broadcast-address 192.168.0.255;

        option routers 192.168.0.1;

        option domain-name-servers 192.168.0.1;

        host blackwidow

        {

                hardware ethernet 00:xx:xx:xx:xx:xx;

                fixed-address 192.168.0.2;

        }

        host soulcage

        {

                hardware ethernet 00:11:xx:xx:xx:xx;

                fixed-address 192.168.0.3;

        }

}

```

How can I resolve these two issues?  I just want a subnet declaration for eth1, not both devices.  Eth2 should be getting dhcp leases from my existing d-link.

FYI: *Quote:*   

> 
> 
> eth0=dead NIC
> 
> eth1=LAN
> ...

 

----------

## thunder

i think you dont wan to broadcast dhcp on WAN interface so put eth1 in /etc/conf.d/

----------

## blackdragonblood

Thx for the reply.  I tried setting up /etc/conf.d/net.eth1 and I still can't get it to work.  Do I have something set up wrong for eth1?

Here is the relavent section of /etc/conf.d/net.eth1:

```
##############################################################################

# INTERFACE HANDLERS

#

# We provide two interface handlers presently: ifconfig and iproute2.

# You need one of these to do any kind of network configuration.

# For ifconfig support, emerge sys-apps/net-tools

# For iproute2 support, emerge sys-apps/iproute2

# If you don't specify an interface then we prefer ifconfig if it's installed

# Prefer iproute2 over ifconfig

#modules=( "iproute2" )

# For a static configuration, use something like this

# (They all do exactly the same thing btw)

#config_eth0=( "192.168.0.2/24" )

#config_eth1=( "192.168.0.1 netmask 255.255.255.0" )

# We can also specify a broadcast

#config_eth0=( "192.168.0.2/24 brd 192.168.0.255" )

config_eth1=( "192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255" )

# If you need more than one address, you can use something like this

# NOTE: ifconfig creates an aliased device for each extra IPv4 address

#       (eth0:1, eth0:2, etc)

#       iproute2 does not do this

#config_eth0=(

#       "192.168.0.2/24"

#       "192.168.0.3/24"

#       "192.168.0.4/24"

#)

# You can also use IPv6 addresses

#config_eth0=(

#       "192.168.0.2/24"

#       "4321:0:1:2:3:4:567:89ab"

#       "4321:0:1:2:3:4:567:89ac"

#)

# If you wish to keep existing addresses + routing and the interface is up,

# you can specify a noop (no operation). If the interface is down or there

# are no addresses assigned, then we move onto the next step (default dhcp)

# This is useful when configuring your interface with a kernel command line

# or similar

#config_eth0=( "noop" "192.168.0.2/24" )

# If you don't want ANY address (only useful when calling for advanced stuff)

#config_eth0=( "null" )

# Here's how todo routing if you need it - the below sets the default gateway

#routes_eth0=(

#       "default via 192.168.0.1"

#       "default via 4321:0:1:2:3:4:567:89ab"

#)

# If a specified module fails (like dhcp - see below), you can specify a

# fallback like so

#fallback_eth0=( "192.168.0.2 netmask 255.255.255.0" )

#fallback_route_eth0=( "default via 192.168.0.1" )

# NOTE: fallback entry must match the entry location in config_eth0

# As such you can only have one fallback route.
```

----------

## thunder

well, you dont have any NIC configured  :Smile:  please read gentoo manual at:

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4

----------

## blackdragonblood

Maybe I should have mentioned this sooner.  I have eth2 configured.  It use to be eth1 when I first set up this box.  Then I desided to make it a router and added a second NIC.  (not counting the onboard eth0 that's dead.)  What was previously eth1 is now eth2 and what is now eth1 I would like to serve dhcp to my lan.  Sorry for the confusion.  I just want dhcpd to listen on eth1.

I did some tweeking.  /etc/dhcp/dhcp.conf:

```
# dhcpd.conf

#

# Sample configuration file for ISC dhcpd

#

# option definitions common to all supported networks...

#option domain-name "example.org";

#option domain-name-servers ns1.example.org, ns2.example.org;

#default-lease-time 600;

#max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local

# network, the authoritative directive should be uncommented.

#authoritative;

# Use this to send dhcp log messages to a different log file (you also

# have to hack syslog.conf to complete the redirection).

log-facility local7;

# No service will be given on this subnet, but declaring it helps the 

# DHCP server to understand the network topology.

#subnet 10.152.187.0 netmask 255.255.255.0 {

#}

# This is a very basic subnet declaration.

#subnet 10.254.239.0 netmask 255.255.255.224 {

#  range 10.254.239.10 10.254.239.20;

#  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;

#}

# This declaration allows BOOTP clients to get dynamic addresses,

# which we don't really recommend.

#subnet 10.254.239.32 netmask 255.255.255.224 {

#  range dynamic-bootp 10.254.239.40 10.254.239.60;

#  option broadcast-address 10.254.239.31;

#  option routers rtr-239-32-1.example.org;

#}

ddns-update-style ad-hoc;

# A slightly different configuration for an internal subnet.

subnet 192.168.0.0 netmask 255.255.255.0 {

  range 192.168.0.100 192.168.0.150;

  option domain-name-servers 172.17.1.14, 172.17.1.15;

#  option domain-name "internal.example.org";

  option routers 192.168.0.1;

  option broadcast-address 192.168.0.255;

  default-lease-time 600;

  max-lease-time 7200;

}

# Hosts which require special configuration options can be listed in

# host statements.   If no address is specified, the address will be

# allocated dynamically (if possible), but the host-specific information

# will still come from the host declaration.

#host passacaglia {

#  hardware ethernet 0:0:c0:5d:bd:95;

#  filename "vmunix.passacaglia";

#  server-name "toccata.fugue.com";

#}

# Fixed IP addresses can also be specified for hosts.   These addresses

# should not also be listed as being available for dynamic assignment.

# Hosts for which fixed IP addresses have been specified can boot using

# BOOTP or DHCP.   Hosts for which no fixed address is specified can only

# be booted with DHCP, unless there is an address range on the subnet

# to which a BOOTP client is connected which has the dynamic-bootp flag

# set.

host blackwidow {

  hardware ethernet 00:xx:xx:xx:xx:xx;

  fixed-address 192.168.0.2;

}

host soulcage {

  hardware ethernet 00:xx:xx:xx:xx:xx;

  fixed-address 192.168.0.3;

}
```

EDIT:  added more info

----------

## Zi7

Here is your problem:

```
Jul 23 10:22:16 [dhcpd] Multiple interfaces match the same subnet: eth1 eth2

Jul 23 10:22:16 [dhcpd] Multiple interfaces match the same shared network: eth1 eth2
```

Basically it means that (whatever you're using to setup your network config on eth1/eth2) you're setting both interface to be on the same subnet: 192.168.0/24 from what i see.

It seems to me you're a little bit confused about what you're trying to do from a networking point of view.

Either you want both interface to be on the same network, in which case you'll have to work out proper netmasks for the eth1 and eth2 parts.

Or you want to make another network on eth2, in which case you can keep your 255.255.255.0 netmasks but you have to change one network part (192.168.0) and use NAT to make both networks communicate.

Can you be a little more specific?

----------

## blackdragonblood

This is my first time attemping this and it is true that I am confused.  I would like eth2 to get a dhcp lease from my ISP or, currently my d-link, and I want eth1 to serve dhcp to my LAN.  I also want the router to use NAT to hide my LAN.  Eventually, I also want the router to have a wireless card so that it can completely replace my d-link, but I will wait with the wireless and work with just ethernet to keep things simple.  Is there anything else I can clarify?

eth2=dhcp lease from ISP/d-link

eth1=serve dhcp to LAN

I appreciate the help.

----------

## Zi7

All right, i think i get it now.  :Smile: 

So, what you need to do is:

 Have two different networks, one for eth1 (LAN) and one for eth2 (WAN). That means two different network address (192.168.0 and 192.168.1 for example).

 Put on NAT on your box, masquerading everything that goes out on eth2.

 Install a DNS server on your box to resolve domain names for your LAN (if your ISP DNS servers are not static)

 Configure dhcpd to serve leases on eth1 for your LAN boxes

I'll assume from your previous posts you want your LAN (eth1) to be 192.168.0, so your /etc/conf.d/net should go:

```
config_eth1=( "192.168.0.1/24 brd 192.168.0.255" )

config_eth2=( "dhcp" )
```

Then, restart your 2 network devices (/etc/init.d/... restart) and check out their config (ifconfig). They should show 2 different network address. If not, change your Dlink config (or your eth1 config) to have so.

You should be able to ping the outside world from your box.

Now you want to start NAT.

If you don't have any iptables rules yet, just issue:

```
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

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

Your box is now able to forward IP packets from your LAN to the internet, back and forth.

DNS and DHCP configs depend on what packages you chose.

You might consider using dnsmasq which does both.

Hope this helps :p

----------

## blackdragonblood

That post is a tremendous help.  I decided to use dnsmasq.  I stepped through the config file and I still don't get and dns resolution when eth1 is up.

log:

 *Quote:*   

> Jul 25 18:18:36 [dnsmasq] started, version 2.31 cachesize 150
> 
> Jul 25 18:18:36 [dnsmasq] compile time options: IPv6 GNU-getopt no-ISC-leasefile no-DBus no-I18N
> 
> Jul 25 18:18:36 [dnsmasq] DHCP, IP range 192.168.0.2 -- 192.168.0.100, lease time 1h
> ...

 

How do I set up DNS using dnsmasq?  According the docs it should work auto-magiclly.   :Sad: 

----------

## Zi7

I don't use dnsmasq, so i don't know much about it, but from what i read in your logs it looks good.

By the way, i've just stumbled upon this gentoo home routeur guide which is exactly what you're trying to do. It includes a minimal - though functional - dsnmasq config file.

Even if you don't have DNS resolution working, can the boxes on your LAN ping internet IP addresses:

```
ping 72.14.207.99
```

(fyi: google.com)

----------

## blackdragonblood

I used that guide first.  When I was having problems I also consaulted the gentoo wiki guilde on home routers.  I restarted eth1, eth2, and dnsmasq.  My clients on the LAN still don't get any dhcp leases.    :Crying or Very sad:    To make things worse a new error popped up.    :Crying or Very sad: 

 *Quote:*   

>  * Stopping eth2
> 
>  *   Bringing down eth2
> 
>  *     Stopping dhcpcd on eth2 ...                                                                                                                   [ ok ]
> ...

 

I didn't think setting up a router would be this challenging for me.  Would it be possible that something like mDNSResponder would be interfering?  I haven't stripped the GUI off of this box yet.  I of cousre was going to do that before it went into production.  It was my first gentoo box.  (I am now up to two.)

----------

## Zi7

 *blackdragonblood wrote:*   

>  *       Running dhcpcd ...
> 
> Error, dhcpConfig: ioctl SIOCADDRT: Network is unreachable                                                                      
> 
>  *       eth2 received address 192.168.0.6                                                                                           [ ok ]

 

Now you're back into your first problem: you WAN NIC (eth2) is given a network address that's the same as your LAN NIC's (eth1) : 192.168.0

It won't work unless you make sure each NIC has its own network address.

Didn't you change you're Dlink config so that it gives you a lease on a 192.168.1 network?

If you don't want to do that, change the eth1 config in /etc/conf.d/net to:

```
config_eth1=( "192.168.1.1/24 brd 192.168.1.255" ) 
```

Edit: Made a typo on an IPLast edited by Zi7 on Wed Jul 26, 2006 11:30 am; edited 1 time in total

----------

## blackdragonblood

So, let me get this stright.  I can't hand out 192.168.0.0/24 if I'm already on that network?  (Forgive me if that seems obvious.)

----------

## Zi7

 :Shocked: 

 *Zi7 wrote:*   

>  Have two different networks, one for eth1 (LAN) and one for eth2 (WAN). That means two different network address (192.168.0 and 192.168.1 for example)

 

We've been through this already...

What's the point of doing NAT (Network Address Translation) if both of your NICs are on the same network? Why would you translate english to english?

I suggest you read a bit about what is a network, a network address/mask, a subnet, NAT.

Cause here it's like you wanted a car, not a motorbike, yet a car with 2 wheels.  :Wink: 

----------

## blackdragonblood

I agree.  I will be reading more docs before I attempt this again.  Thx for your help.

----------

