{"id":269,"date":"2009-06-15T01:11:31","date_gmt":"2009-06-15T06:11:31","guid":{"rendered":"http:\/\/yourlinuxguy.com\/?p=269"},"modified":"2009-06-12T14:43:36","modified_gmt":"2009-06-12T19:43:36","slug":"how-do-i-set-up-dhcp-failover","status":"publish","type":"post","link":"https:\/\/yourLinuxGuy.com\/?p=269","title":{"rendered":"How do I set up DHCP failover?"},"content":{"rendered":"<p>There are lots of ways to design and run your dhcp server and environment.\u00a0 Over the years, I&#8217;ve kinda&#8217; fallen in-and-out of love with DHCP clustering;\u00a0 I&#8217;ve just come to the conclusion that it is more trouble than it&#8217;s worth.\u00a0 I stumbled on this &#8220;peering&#8221; or &#8220;fail-over&#8221; method of running dhcpd when I was preparing for a Novell Practicum (believe it or not) and have recommended doing it this way from then on.\u00a0 So on with the show then;\u00a0 here&#8217;s my dhcpd failover cheat sheet.<\/p>\n<p><span style=\"color: #888888;\">Note that although the following examples were all done on a Suse machine, they should work with some alterations on most Linux Distros, basically wherever the standard <code>dhcpd<\/code> package is installed and running.<\/span><\/p>\n<p>The logic behind this is this:\u00a0 You have two Linux servers.\u00a0 Both have the dhcpd software installed.\u00a0 You want to run dhcpd on both of them simultaneously, but you understand that without some special configuration modification, this will cause havoc on your network.<\/p>\n<p>In order to accomplish that, you basically move the traditional <code>dhcpd.conf<\/code> to a secondary file <code>dhcpd.conf.master<\/code>, and &#8220;include&#8221; that file from a &#8220;new&#8221; <code>dhcpd.conf<\/code> that will include the failover instructions.\u00a0 This is because the failover stuff must come first in sequence, and is unique to each of the two machines.\u00a0 And the old, standard stuff is the same on both machines and can come second.<\/p>\n<p>Also, the <code>dhcpd.conf.master<\/code> file must be copied into the chroot environment in order to work. You can do this manually, or on Suse, set the <code>DHCPD_CONF_INCLUDE_FILES=\"\/etc\/dhcpd.conf.master\"<\/code> variable in <code>\/etc\/sysconfig\/dhcpd<\/code>.\u00a0 Don&#8217;t forget to run <code>SuSEconfig<\/code> when done making changes, to have the files copied over for you.<\/p>\n<p>Of course, you could just cram all this stuff into one file, but with the separate files it is easier to maintain the static content (and copy it across as needed).\u00a0 But I don&#8217;t like to do this.\u00a0 I like to keep them separate for ease of copying, tracking, etc.<\/p>\n<p>Anyway, here are examples of the conf files:<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nPrimary server <code>dhcp.conf<\/code>:<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n<code>failover peer \"yourlinuxguy\"<br \/>\n{<br \/>\nprimary;<br \/>\naddress 192.168.1.5;<br \/>\nport 847;<br \/>\npeer address 192.168.1.6;<br \/>\npeer port 647;<br \/>\nmax-response-delay 180;<br \/>\nmclt 1800;<br \/>\nsplit 128;<br \/>\nload balance max seconds 3;<br \/>\n}<br \/>\n# Now include the master config file from both machines<br \/>\n# Don't forget to copy it into the chroot section!<br \/>\ninclude \"\/etc\/dhcpd.conf.master\";<\/code><br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>Secondary server <code>dhcpd.conf<\/code>:<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n<code>failover peer \"yourlinuxguy\"<br \/>\n{<br \/>\nsecondary;<br \/>\naddress 192.168.1.6;<br \/>\nport 647;<br \/>\npeer address 192.168.1.5;<br \/>\npeer port 847;<br \/>\nmax-response-delay 180;<br \/>\nload balance max seconds 3;<br \/>\n}<br \/>\n# Now include the master config file from both machines<br \/>\n# Don't forget to copy it into the chroot section!<br \/>\ninclude \"\/etc\/dhcpd.conf.master\";<\/code><br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>The <code>dhcpd.conf.master<\/code> on both hosts:<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n<code>ddns-update-style none;<br \/>\ndefault-lease-time 86400;<br \/>\nmax-lease-time 86400;<br \/>\noption domain-name \"yourlinuxguy.com\";<br \/>\noption domain-name-servers 192.168.1.3, 192.168.1.4;<br \/>\noption routers 192.168.1.1;<br \/>\nsubnet 192.168.1.0 netmask 255.255.255.0<br \/>\n{<br \/>\npool<br \/>\n{<br \/>\nfailover peer \"yourlinuxguy\";<br \/>\ndeny dynamic bootp clients;<br \/>\nrange 192.168.1.50 192.168.1.100;<br \/>\n}<br \/>\n}<\/code><br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>And that&#8217;s it!\u00a0 Now, you&#8217;ve got dhcp running on both servers, splitting hte work, sharing the running leases database, so that if one fails, the other takes over.\u00a0 When the failed one comes back, they re-share all the changed information and pick up where they left off.\u00a0 Big props to the man pages, and please see them for further explanation of any of the options in my examples above.\u00a0 This is just a cheat sheet folks!<\/p>\n<p>Brilliant!<\/p>\n<p>\ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are lots of ways to design and run your dhcp server and environment.\u00a0 Over the years, I&#8217;ve kinda&#8217; fallen in-and-out of love with DHCP clustering;\u00a0 I&#8217;ve just come to the conclusion that it is more trouble than it&#8217;s worth.\u00a0&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/yourLinuxGuy.com\/?p=269\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12,70,47],"tags":[],"class_list":["post-269","post","type-post","status-publish","format-standard","hentry","category-advanced","category-dhcpd","category-linuxgeneral"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnjn1-4l","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=269"}],"version-history":[{"count":3,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/269\/revisions"}],"predecessor-version":[{"id":271,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/269\/revisions\/271"}],"wp:attachment":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}