{"id":31836,"date":"2014-08-04T10:32:18","date_gmt":"2014-08-04T15:32:18","guid":{"rendered":"http:\/\/webirix.com\/?p=31836"},"modified":"2014-08-04T10:32:18","modified_gmt":"2014-08-04T15:32:18","slug":"como-configurar-un-servidor-dhcp-en-una-lan-en-linux","status":"publish","type":"post","link":"https:\/\/webirix.com\/en\/como-configurar-un-servidor-dhcp-en-una-lan-en-linux\/","title":{"rendered":"How to configure a DHCP server on a LAN in Linux"},"content":{"rendered":"<h2 style=\"color: #1c1c1c;\"><a href=\"http:\/\/webirix.com\/wp-content\/uploads\/2014\/08\/linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31838 aligncenter\" src=\"http:\/\/webirix.com\/wp-content\/uploads\/2014\/08\/linux.png\" alt=\"linux\" width=\"500\" height=\"275\" srcset=\"https:\/\/webirix.com\/wp-content\/uploads\/2014\/08\/linux.png 500w, https:\/\/webirix.com\/wp-content\/uploads\/2014\/08\/linux-300x165.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/h2>\n<h2 style=\"color: #1c1c1c;\">Introduction.<\/h2>\n<p style=\"color: #333333;\"><b>DHCP<\/b>\u00a0(acronym for\u00a0<b>D<\/b>ynamic Host\u00a0<b>C<\/b>onfiguration\u00a0<b>P<\/b>rotocol which translates Dynamic Server Configuration Protocol) is a protocol that allows individual devices on a network of IP addresses to obtain their own network configuration information (IP address; subnet mask, gateway, etc.) from a DHCP server. Its main purpose is to make large networks easier to manage.\u00a0<b>DHCP<\/b>\u00a0It has existed since 1993 as a standard protocol and is described in detail in the\u00a0<a style=\"color: #2b96f1;\" href=\"http:\/\/www.ietf.org\/rfc\/rfc2131.txt\">RFC 2131<\/a>.<\/p>\n<p style=\"color: #333333;\">Without the help of a server\u00a0<b>DHCP<\/b>, each IP address of each host that belongs to a Local Area Network would have to be configured manually. If a host moves to another location where there is another Local Area Network, a different IP address will have to be configured in order to join this new Local Area Network. A server\u00a0<b>DHCP<\/b>it then monitors and distributes the IP addresses of a Local Area Network by assigning an IP address to each host that joins the Local Area Network. When, for example, a laptop is configured to use\u00a0<b>DHCP<\/b>, it will be assigned an IP address and other network parameters necessary to join each Local Area Network where it is located.<\/p>\n<p style=\"color: #333333;\">There are three allocation methods in the protocol\u00a0<b>DHCP<\/b>:<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">\n<tbody>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\"><b>Manual assignment<\/b>: The mapping uses a table with addresses\u00a0<b>MAC<\/b>\u00a0(acronym for\u00a0<b>M<\/b>edia<b>TO<\/b>ccess\u00a0<b>C<\/b>ontrol\u00a0<b>TO<\/b>ddress, which translates to Media Access Control address). Only hosts with one address\u00a0<b>MAC<\/b>\u00a0defined in said table will receive the IP assigned in the same table. This is done through the parameters\u00a0<b>ethernet hardware<\/b>\u00a0Y\u00a0<b>fixed-address<\/b>.<\/td>\n<\/tr>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\"><b>Automatic assignment<\/b>: An available IP address within a certain range is permanently assigned to the host that requires it.<\/td>\n<\/tr>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\"><b>Dynamic allocation<\/b>: A range of IP addresses is arbitrarily determined and each host connected to the network is configured to request its IP address from the server when the network device starts,\u00a0<b>using a controllable time interval<\/b>\u00a0(parameters\u00a0<b>default-lease-time<\/b>\u00a0Y\u00a0<b>max-lease-time<\/b>) so that IP addresses are not permanent and are dynamically reused.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<h2 style=\"color: #1c1c1c;\">Necessary logical support.<\/h2>\n<p style=\"color: #333333;\">It is required to install the dhcp package which should be included in the installation disks of most distributions.<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#e6e6e6\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"100%\">\n<pre style=\"color: #333333;\">yum -y install dhcp<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<p style=\"color: #333333;\">If you are using Red Hat \u2122 Enterprise Linux, all you need to do is do the following to install or update the necessary software:<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#e6e6e6\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"100%\">\n<pre style=\"color: #333333;\">up2date -i dhcp<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<h2 style=\"color: #1c1c1c;\">Configuration file.<\/h2>\n<p style=\"color: #333333;\">Considering as an example that you have a local network with the following characteristics:<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">\n<tbody>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\">Network number 192.168.0.0<\/td>\n<\/tr>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\">Subnet mask: 255.255.255.0<\/td>\n<\/tr>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\">Gateway: 192.168.0.1<\/td>\n<\/tr>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\">Name server: 192.168.0.1, 148.240.241.42 and 148.240.241.10<\/td>\n<\/tr>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\">Wins Server: 192.168.0.1<\/td>\n<\/tr>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\">Time servers: 66.187.224.4 and 66.187.233.4<\/td>\n<\/tr>\n<tr>\n<td align=\"left\" valign=\"top\" width=\"10\"><b>\u2022\u00a0<\/b><\/td>\n<td align=\"left\" valign=\"top\">Range of IP addresses to be assigned dynamically: 192.168.0.11-192.168.0.199<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<p style=\"color: #333333;\"><b>NOTE:<\/b>\u00a0It&#039;s essential\u00a0<b>know and understand perfectly<\/b>\u00a0all of the above in order to continue with this manual.<\/p>\n<p style=\"color: #333333;\">You can use the following content\u00a0<b>to create from scratch<\/b>\u00a0the file\u00a0<b>\/etc\/dhcpd.conf<\/b>.<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">\n<tbody>\n<tr>\n<td valign=\"top\" bgcolor=\"#e6e6e6\" width=\"100%\">\n<pre style=\"color: #333333;\">ddns-update-style interim; ignore client-updates; shared-network miredlocal {subnet 192.168.0.0 netmask 255.255.255.0 {option routers 192.168.0.1; option subnet-mask 255.255.255.0; option broadcast-address 192.168.0.255; option domain-name &quot;<b>redlocal.net<\/b>&quot;; option domain-name-servers 192.168.0.1, 148.240.241.42, 148.240.241.10; option netbios-name-servers 192.168.0.1; option ntp-servers 66.187.224.4, 66.187.233.4; range 192.168.0.11 192.168.0.199; default-lease-time 21600; max-lease-time 43200;} host m253 {option host-name &quot;m253.redlocal.net&quot;; hardware ethernet 00: 50: BF: 27: 1C: 1C; fixed-address 192.168.0.253 ;} host m254 {option host-name &quot;m254.redlocal.net&quot;; hardware ethernet 00: 01: 03: DC: 67: 23; fixed-address 192.168.0.254;}}<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<p style=\"color: #333333;\">A good security measure is to make the dhcpd service only work through the network interface used by the LAN, this in the case of having multiple network devices. Edit the file\u00a0<b>\/ etc \/ sysconfig \/ dhcpd<\/b>\u00a0and add as parameter argument\u00a0<b>DHCPDARGS<\/b>\u00a0the value\u00a0<b>eth0<\/b>,\u00a0<b>eth1<\/b>,\u00a0<b>eth2<\/b>, etc., or whatever applies. Example, considering that\u00a0<b>eth0<\/b>\u00a0is the interface corresponding to the LAN:<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#e6e6e6\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"100%\">\n<pre style=\"color: #333333;\"># Command line options here DHCPDARGS = eth0<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<p style=\"color: #333333;\">To run the service for the first time, run:<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#e6e6e6\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"100%\">\n<pre style=\"color: #333333;\">\/ sbin \/ service dhcpd start<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<p style=\"color: #333333;\">To make the changes made to the configuration take effect, run:<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#e6e6e6\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"100%\">\n<pre style=\"color: #333333;\">\/ sbin \/ service dhcpd restart<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<p style=\"color: #333333;\">To stop the service, run:<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#e6e6e6\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"100%\">\n<pre style=\"color: #333333;\">\/ sbin \/ service dhcpd stop<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<p style=\"color: #333333;\">To add\u00a0<b>dhcpd<\/b>\u00a0at system boot, run:<\/p>\n<div style=\"color: #000000;\" align=\"center\"><center><\/p>\n<table style=\"width: 85%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#e6e6e6\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"100%\">\n<pre style=\"color: #333333;\">\/ sbin \/ chkconfig dhcpd on<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/center><\/div>\n<p style=\"color: #333333;\">Once this is done, it will only be enough to configure the workstations that are necessary as DHCP interfaces, regardless of the operating system they use.<\/p>\n<p style=\"color: #333333;\">Fountain:<\/p>\n<p style=\"color: #333333;\">http:\/\/unidadlocal.com\/<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction. DHCP (acronym for Dynamic Host Configuration Protocol which translates to Dynamic Server Configuration Protocol) is a protocol that allows individual devices on a network of IP addresses to obtain their own network configuration information (IP address; subnet mask, gateway, etc.) from a DHCP server. Its main purpose is to do ...<\/p>","protected":false},"author":20,"featured_media":31838,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2024,1947],"tags":[],"class_list":["post-31836","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-preguntas-frecuentes-categoria"],"jetpack_featured_media_url":"https:\/\/webirix.com\/wp-content\/uploads\/2014\/08\/linux.png","_links":{"self":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts\/31836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/comments?post=31836"}],"version-history":[{"count":1,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts\/31836\/revisions"}],"predecessor-version":[{"id":31839,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts\/31836\/revisions\/31839"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/media\/31838"}],"wp:attachment":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/media?parent=31836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/categories?post=31836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/tags?post=31836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}