🐧 Configurar 🖥 servidor DHCP en Ubuntu Server 22.04
How to Configure a DHCP Server on Ubuntu Server
Introduction to DHCP
- The video introduces the concept of configuring a DHCP server on Ubuntu Server, explaining its purpose in assigning IP addresses to devices within an internal network.
Setting Up the Environment
- The presenter outlines the setup involving two virtual machines: one running Ubuntu Desktop and another running Ubuntu Server, which will act as a router for internet access.
- The goal is to configure the server so that it automatically assigns IP addresses, subnet masks, and gateways to all client devices connecting to the internal network.
Initial Configuration Requirements
- It is emphasized that proper configuration of gateway settings (192.168.188.x) is crucial for clients to access the internet through the server.
- A DNS configuration will be addressed later after setting up DHCP.
Network Setup Details
- The presenter specifies that the Ubuntu Server must have two network adapters: one set to NAT mode and another configured for internal networking.
- An example is given where an existing machine has been manually configured with an IP address (192.168.17.x), demonstrating prior setup knowledge.
Installing DHCP Service
- The initial step involves updating package repositories using
sudo apt updatebefore installing the ISC DHCP server package withsudo apt-get install isc-dhcp-server.
Configuring DHCP Settings
- After installation, configuration begins by editing
/etc/dhcp/dhcpd.conf, where various parameters such as domain name and default lease time are specified.
Defining Network Parameters
- Key configurations include defining subnet details like network ID (192.168.1.x), netmask (255.255.255.0), and ensuring clarity on valid IP ranges within this subnet.
Grouping Configuration Elements
- A comment section is added in the configuration file for better organization, followed by defining a group named "asir" for managing related settings effectively.
Subnet Declaration
DHCP Server Configuration Steps
Setting Up the IP Address Range
- The configuration begins with defining the range of IP addresses for the DHCP server, specifically from 192.168.1.100 to 192.168.1.150, totaling 51 usable addresses.
Domain Name and DNS Settings
- The next step involves specifying the domain name and DNS server settings, where the DNS is set to 192.168.1.8, which is identified as the server's IP address.
Subnet Mask Configuration
- The subnet mask is defined using
option subnet-mask, set to 255.255.0, ensuring proper network segmentation.
Gateway and Broadcast Address
- The gateway (router) option is configured to point to the server's IP (192.168.1.8), allowing internet access through this address.
- Additionally, a broadcast address is specified using
option broadcast-address, which will be set based on previous configurations.
Time Settings for DHCP Lease
- Default lease time settings are reviewed; custom values can be added within the specific group configuration for clarity and control over lease durations.
Error Checking in Configuration
Syntax Check Command Execution
- After completing initial configurations, a syntax check command (
sudo dhcpd -t) is executed to ensure there are no errors in the setup.
Identifying Errors in Configuration
- An error related to
option name-serverarises during checking; it indicates that a required field was omitted in earlier steps.
Finalizing DHCP Server Setup
Correcting Configuration Mistakes
- Upon identifying missing elements like
domain-name, corrections are made before saving changes again with Control + X.
Restarting DHCP Service
- After confirming no errors remain, the service is restarted using
sudo service isc-dhcp-server restartto apply all new configurations effectively.
Network Adapter Specification
Configuring Network Adapter for DHCP
- It’s essential to specify which network adapter will serve as default for assigning IP addresses; adjustments are made accordingly in
/etc/default/isc-dhcp-server.
Verifying Successful Setup
- Finally, after setting up both adapters correctly and restarting services, verification confirms that everything operates smoothly without issues.
DHCP Configuration and IP Address Management
Understanding IP Address Assignment
- The need for a specific range of IP addresses (100 to 150) is established, with the first device connecting to the network assigned the address 100.
- A manual configuration on a machine leads to an automatic assignment of IP address 101 instead of 100 due to another device occupying that address.
- The gateway is set at 192.168.1.8, and DNS remains at 8.8.8.8, allowing continued access to Google via ping commands.
DNS Configuration Challenges
- Removing the static DNS setting results in loss of domain name resolution, preventing access to Google due to lack of configured DNS server.
- The speaker plans to configure DNS settings in a subsequent practice session for proper functionality.
Static IP Assignment for Specific Devices
- Discussion on assigning a fixed IP (e.g., 192.168.1.105) for devices like printers that require consistent addressing within a network.
- To achieve this, modifications are made in the server's configuration file by adding host details and ensuring correct syntax.
Utilizing MAC Addresses for Fixed Assignments
- Identification of the device's hostname (e.g., "asir") is necessary for configuring static assignments in DHCP settings.
- The MAC address is crucial; it uniquely identifies the network adapter and allows specific devices to be assigned predetermined IP addresses.
Troubleshooting Configuration Issues
- An error occurs during service activation due to misconfiguration in the DHCP settings file, highlighting common pitfalls such as missing semicolons.
- After correcting errors and restarting services, successful assignment of static IP (105), demonstrating effective DHCP setup.
Finalizing DHCP Setup
- With successful configuration, any new device connecting will receive an available IP from the defined range while ensuring fixed assignments remain intact based on MAC addresses.