Page 1 of 1

Made DHCP server. How to clients to my router?

Posted: Fri Jan 29, 2016 4:50 pm
by hormel09
I made a DHCP on my pi using

Code: Select all

isc-dhcp-server
I confirmed it's working by connecting my pi directly to my laptop to my with an Ethernet cable (no switch). Now I want the PI to handle DHCP for my home network. I'm not sure how to go about this. I think I need to turn off the DHCP service in my modem/router, assign it a static IP address, and make that static address the gateway address in my PI's DHCP server. Static IP addresses are assigned in

Code: Select all

/etc/dhcp/dhcpd.conf
with a MAC address. My router/modem seems to have two MAC addresses. One is a cable modem MAC address and the other is wireless interface MAC address. Any idea which I should use? Does it sound like I'm on the right track? Is there anything I'm missing to achieve this goal? Thanks! :mrgreen:

Re: Made DHCP server. How to clients to my router?

Posted: Fri Jan 29, 2016 6:37 pm
by DougieLawson
If you have two DHCP servers you will get lots of problems when the same address gets issued a second time. Disable the server on your router.

Re: Made DHCP server. How to clients to my router?

Posted: Fri Jan 29, 2016 8:39 pm
by davidcoton
hormel09 wrote: I think I need to turn off the DHCP service in my modem/router,
DougieLawson wrote:Disable the server on your router.
Never mind, Dougie. Keep taking the tablets. :lol:
hormel09 wrote:Static IP addresses are assigned in

Code: Select all

/etc/dhcp/dhcpd.conf
with a MAC address. My router/modem seems to have two MAC addresses. One is a cable modem MAC address and the other is wireless interface MAC address. Any idea which I should use? Does it sound like I'm on the right track?
My turn to be possibly idiotic. I would expect one address for the upstream (cable) interface, another for wired ethernet, and a third for wireless (more if it's multi-band). Others (including Dougie, when he is concentrating) will know better than I. You will have to use the correct MAC for the interface you are connecting to.

I checked my router -- apart from the two wireless MACs, I couldn't see any others listed (but that doesn't mean they don't exist). It should be possible to find one for the wired interface (I just don't know the magic incantation). Don't know about the upstream one, but it shouldn't be relevant.

Re: Made DHCP server. How to clients to my router?

Posted: Fri Jan 29, 2016 9:05 pm
by asandford
You'll need to disable the router's DHCP: how you acheive that depends on the make/model, which you haven't told us.

Re: Made DHCP server. How to clients to my router?

Posted: Fri Jan 29, 2016 9:40 pm
by davidcoton
asandford wrote:You'll need to disable the router's DHCP: how you acheive that depends on the make/model, which you haven't told us.
I think the OP (not me) knows that. Hence my too unsubtle dig at Dougie.

In case anyone thinks otherwise, I respect and value Dougie's contributions here. I'm sure my posts have a higher rate of missing the point than his.

Re: Made DHCP server. How to clients to my router?

Posted: Fri Jan 29, 2016 9:49 pm
by asandford
davidcoton wrote:
asandford wrote:You'll need to disable the router's DHCP: how you acheive that depends on the make/model, which you haven't told us.
I think the OP (not me) knows that. Hence my too unsubtle dig at Dougie.

In case anyone thinks otherwise, I respect and value Dougie's contributions here. I'm sure my posts have a higher rate of missing the point than his.
Althought the OP may know that they have to do it, they may not know *how to* (in which case giving us make & model will help).
(I'm not going to comment on any of the rest of your post :))

Re: Made DHCP server. How to clients to my router?

Posted: Fri Jan 29, 2016 11:32 pm
by DougieLawson
DHCP works on the hardware MAC layer (because there's no IP addresses assigned until DHCP is complete). When it comes to configuring it you need to use the LAN side MAC address, not the WAN side MAC.

The basic dialog runs like this. Your DHCP client shouts with source addr 0.0.0.0, dest address 255.255.255.255, "Hello is there a DHCP server out there?" (That's the DHCPDISCOVER packet). The DHCP server replies with "Hello, I'm your DHCP server my address is '192.168.hhh.hhh' would you like IP address '192.168.xxx.xxx' until your lease expires?" (That's the DHCPOFFER packet which is why things get confused with two DHCP servers). The client machine then sends back "I think I'll accept that '192.168.xxx.xxx' address, thanks." (That's the DHCPREQUEST packet) and finally the server sends back "OK, you've got '192.168.xxx.xxx', the gateway is '192.168.ggg.ggg', the DNS servers are '192.168.ddd.ddd' & '8.8.8.8' (assuming that's what's configured) and your lease expires on Sunday at Midnight" (that's the DHCPACK packet).

Things are a bit different if it's an existing station reconnecting before the lease expires because the DISCOVER and REQUEST packets carry the unexpired IP address and the OFFER packet confirms whether it can be used or whether it's been re-assigned.

When you configure a DHCP server you need to know your network topology. There's two things you need
1. DHCP pool range
2. Gateway address (normally for a SOHO systems DHCP server, DNS server and gateway are the same system)

You can configure other stuff like DNS server address(es), domain name, broadcast address, netbios names, NTP server address(es), timezone.

Re: Made DHCP server. How to clients to my router?

Posted: Sat Jan 30, 2016 1:35 pm
by hormel09
asandford wrote: Althought the OP may know that they have to do it, they may not know *how to* (in which case giving us make & model will help).
(I'm not going to comment on any of the rest of your post :))
If I had any doubt about how to do it before, I don't now! I wound up breaking my network after turning its DHCP service off and the PI's DHCP service couldn't get my clients to connect to the internet. I had to hard reset my modem/router to get everything working again.

I used a MAC address associated with the IP address of my router. I found it using

Code: Select all

arp -a
I plugged the MAC into my dhcpd.conf. Following this I disabled the DHCP service in my router/modem. I plugged the PI directly into my laptop, SSHed into the PI with its static IP address, turned on the DHCP server, and released/renewed my laptop's IP address. It worked. It assigned an IP and passed on the gateway. After the DHCP service was disabled on the router, I turned it off. I connected my laptop and PI into the Ethernet ports on the back of the router then powered the router up. Repeated the release/refresh of the laptop's IP address. SSH still worked, but I couldn't connect to the internet. The LAN switch in the router was clearly working, but something must be wrong with the gateway. I wasn't able to connect to the router's webGUI using the IP I assigned it or the factory default IP after turning off its DHCP. I'm not sure if it's because I'm using the correct MAC address or that something is wrong with my config files. I'm posting them below. Sorry for the wall of text :? I'm sure it's hard to spot the problem with this description and my config files. Are there any diagnostic tests I could run to help narrow my problem? Oh! And lastly my router/modem is a Motorola SBG65800. This is a manual I found for it online https://www.midco.com/contentassets/b44 ... bg6580.pdf. It says the MAC address is on a label at the bottom. There are two: an HFC MAC and a Gateway MGMT MAC. These are both different than the one I found using the method below. The contents of my /etc/dhcp/dhcpd.conf which is where I stored the static IP along with MAC address of my router

Code: Select all

option domain-name "mydebian";
# option definitions common to all supported networks...
option domain-name "mydebian";
option domain-name-servers 122.197.254.7, 122.197.254.10;

# Set up our desired subnet:
subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.101 192.168.1.254;
    option subnet-mask 255.255.255.0;
    option broadcast-address 192.168.1.255;
    option routers 192.168.1.100;
    option domain-name-servers home;
}

#assigned addresses
host router {
  hardware ethernet e8:6d:52:69:de:be;
  fixed-address 192.168.1.100;
}

default-lease-time 600;
max-lease-time 7200;

#only DHCP server in this network:
authoritative;
Contents of my /etc/network/interfaces.

Code: Select all

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 192.168.1.99
        netmask 255.255.255.0
        broadcast 192.168.1.255
        gateway 192.168.1.100

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
and lastly the contents of my /etc/resolv.conf. The DNS servers provided by my ISP.

Code: Select all

# Generated by resolvconf
nameserver 122.197.254.7
nameserver 122.197.254.10