How to install and configure DHCP server on Ubuntu

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • In this post, I would like to show you how to configure an Ubuntu machine as a DHCP server.
    Table of Contents
    Search for DHCP software
    Install DHCP server
    Confirm that DHCP is up and running
    Change the default configuration
    Stop and start the DHCP server
    Test the DHCP server
    If you prefer to read, you can find the written form of this video here:
    gulian.uk/how-...
    CONNECT WITH ME:
    LinkedIn: / petru-gulian
    Support my work: www.buymeacoff...

Комментарии • 26

  • @StudioSWATcraftCZ
    @StudioSWATcraftCZ 8 месяцев назад +1

    Hi! I passed your video step by step but my client computer did not get ip address from dhcp server. The problem is that client cant listening on port 68. I used command: sudo netstat -ulnp | grep 68 but I could not see that ... :( Do you have any idea? I use Virtual box for both devices (dhcp and client) I have Ubuntu 22.4.3

    • @GulianTechnology
      @GulianTechnology  8 месяцев назад

      Make sure that the dhclient is running on the client machine. Otherwise, you will not find UDP port 68 in a listening state.
      Output from my machine.
      petru@petru-ubuntu:~$ ps aux | grep dhclient
      petru 3428 0.0 0.0 9072 2304 pts/0 S+ 14:41 0:00 grep --color=auto dhclient
      petru@petru-ubuntu:~$ sudo dhclient
      petru@petru-ubuntu:~$ ps aux | grep dhclient
      root 3650 0.0 0.0 4060 3072 ? Ss 14:44 0:00 dhclient
      petru 3745 0.0 0.0 9072 2304 pts/0 S+ 14:44 0:00 grep --color=auto dhclient
      petru@petru-ubuntu:~$ sudo netstat -ulnp | grep dhclient
      udp 0 0 0.0.0.0:68 0.0.0.0:* 3650/dhclient
      petru@petru-ubuntu:~$

    • @StudioSWATcraftCZ
      @StudioSWATcraftCZ 8 месяцев назад +1

      Alright I will try it. Do I have to change something in virtual box? Like adapter or something like that? @@GulianTechnology

    • @GulianTechnology
      @GulianTechnology  8 месяцев назад

      @@StudioSWATcraftCZ As far as I know, you do not need to change anything.

  • @cseiter
    @cseiter Месяц назад

    Thank you for this guide. Just got an offline network up and running with clients getting DHCP from the server. The only issue I ran in to was I was trying for a class B subnet and the conf file didn't like it. Once I ran "journalctl -n 50 -u isc-dhcp-server.service" it showed in the config file what I did wrong.

    • @GulianTechnology
      @GulianTechnology  Месяц назад

      You're welcome, @cseiter! I'm glad it was helpful to you. :)

  • @user-sw3tk6og9b
    @user-sw3tk6og9b 8 месяцев назад +1

    When checking the server status. My own showed Active: failed. I'm trying to exit this page to go back to the page where I can start inputting commands but the command u used to exit isn't doing it. I'm sure it's that ESC :x

    • @GulianTechnology
      @GulianTechnology  8 месяцев назад

      You need to press the 'q' on your keyboard and you will be able to exit from the command systemctl status isc-dhcp-server. To have the DHCPd server in an active state you need to have an interface with an IP address from the CIDR range defined in the dhpd.conf file.
      petru@petru-ubuntu:~$ systemctl status isc-dhcp-server
      × isc-dhcp-server.service - ISC DHCP IPv4 server
      Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; preset: e>
      Active: failed (Result: exit-code) since Thu 2024-01-11 11:48:24 GMT; 9min ago
      Duration: 56ms
      Docs: man:dhcpd(8)
      Main PID: 1786 (code=exited, status=1/FAILURE)
      CPU: 19ms
      Jan 11 11:48:24 petru-ubuntu sh[1786]: bugs on either our web page at www.isc.org or>
      Jan 11 11:48:24 petru-ubuntu dhcpd[1786]: before submitting a bug. These pages expl>
      Jan 11 11:48:24 petru-ubuntu sh[1786]: before submitting a bug. These pages explain>
      Jan 11 11:48:24 petru-ubuntu dhcpd[1786]: process and the information we find helpfu>
      Jan 11 11:48:24 petru-ubuntu sh[1786]: process and the information we find helpful f>
      Jan 11 11:48:24 petru-ubuntu dhcpd[1786]:
      Jan 11 11:48:24 petru-ubuntu dhcpd[1786]: exiting.
      Jan 11 11:48:24 petru-ubuntu sh[1786]: exiting.
      Jan 11 11:48:24 petru-ubuntu systemd[1]: isc-dhcp-server.service: Main process exite>
      Jan 11 11:48:24 petru-ubuntu systemd[1]: isc-dhcp-server.service: Failed with result>
      lines 1-18/18 (END)

    • @GulianTechnology
      @GulianTechnology  8 месяцев назад

      After configuring the IP address on the interface from the same CIDR range defined in the dhpd.conf file.
      petru@petru-ubuntu:~$ systemctl status isc-dhcp-server
      ● isc-dhcp-server.service - ISC DHCP IPv4 server
      Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; preset: e>
      Active: active (running) since Thu 2024-01-11 12:01:31 GMT; 3min 0s ago
      Docs: man:dhcpd(8)
      Main PID: 3270 (dhcpd)
      Tasks: 1 (limit: 4557)
      Memory: 3.7M
      CPU: 12ms
      CGroup: /system.slice/isc-dhcp-server.service
      └─3270 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.>
      Jan 11 12:01:31 petru-ubuntu dhcpd[3270]: in your dhcpd.conf file for the network>
      Jan 11 12:01:31 petru-ubuntu dhcpd[3270]: to which interface ens37 is attached. **
      Jan 11 12:01:31 petru-ubuntu dhcpd[3270]:
      Jan 11 12:01:31 petru-ubuntu dhcpd[3270]: Listening on LPF/ens33/00:0c:29:cf:9c:36/1>
      Jan 11 12:01:31 petru-ubuntu sh[3270]: Listening on LPF/ens33/00:0c:29:cf:9c:36/172.>
      Jan 11 12:01:31 petru-ubuntu sh[3270]: Sending on LPF/ens33/00:0c:29:cf:9c:36/172.>
      Jan 11 12:01:31 petru-ubuntu sh[3270]: Sending on Socket/fallback/fallback-net
      Jan 11 12:01:31 petru-ubuntu dhcpd[3270]: Sending on LPF/ens33/00:0c:29:cf:9c:36/1>
      Jan 11 12:01:31 petru-ubuntu dhcpd[3270]: Sending on Socket/fallback/fallback-net
      petru@petru-ubuntu:~$

  • @user-jy1ps1lb2n
    @user-jy1ps1lb2n 10 месяцев назад +1

    Is there a way I can contact you to discuss more?

    • @GulianTechnology
      @GulianTechnology  10 месяцев назад

      You can find me here: www.linkedin.com/in/petru-gulian/ or here: office@gulian.uk

  • @user-jy1ps1lb2n
    @user-jy1ps1lb2n 10 месяцев назад +1

    Helo, I have followed all your steps but still get an error.

    • @GulianTechnology
      @GulianTechnology  10 месяцев назад

      What error do you see? You can share it in a comment. If we manage to solve this issue, others will also benefit from it.

    • @user-jy1ps1lb2n
      @user-jy1ps1lb2n 10 месяцев назад +1

      @@GulianTechnology I receive and error stating that it's not configured to any interfaces, now just to give you some perspective, I'm running a LTE modem/router on WiFi but trying to get DHCP on the Gigabit Port, the LTE router is providing DHCP itself, but I disconnect from it when I try to run the Ubuntu machine as server

    • @user-jy1ps1lb2n
      @user-jy1ps1lb2n 10 месяцев назад +1

      I release that I have nothing plugged in on the LAN port, should I connect a small switch?? Also the whole idea is- I want to decommission my windows server and move the firewall traffic from the windows to the Linux machine which will act as a server

    • @GulianTechnology
      @GulianTechnology  10 месяцев назад

      Please share the output of these 3 commands:
      1. ip add show
      2. systemctl status isc-dhcp-server
      3. cat /etc/dhcp/dhcpd.conf

    • @GulianTechnology
      @GulianTechnology  10 месяцев назад

      "I release that I have nothing plugged in on the LAN port, should I connect a small switch??" - Of course, you need to have something connected to the port on which DHCP will be running.