{"id":18191,"date":"2014-02-15T06:45:18","date_gmt":"2014-02-14T22:45:18","guid":{"rendered":"https:\/\/2blog.ilc.edu.tw\/25793\/2014\/02\/15\/%e5%bf%ab%e9%80%9f%e7%94%a2%e7%94%9f-dhcp-server-%e7%9a%84-dhcpd-conf-%e6%a0%bc%e5%bc%8f%e6%aa%94\/"},"modified":"2014-02-15T06:45:18","modified_gmt":"2014-02-14T22:45:18","slug":"%e5%bf%ab%e9%80%9f%e7%94%a2%e7%94%9f-dhcp-server-%e7%9a%84-dhcpd-conf-%e6%a0%bc%e5%bc%8f%e6%aa%94","status":"publish","type":"post","link":"https:\/\/2blog.ilc.edu.tw\/25793\/2014\/02\/15\/%e5%bf%ab%e9%80%9f%e7%94%a2%e7%94%9f-dhcp-server-%e7%9a%84-dhcpd-conf-%e6%a0%bc%e5%bc%8f%e6%aa%94\/","title":{"rendered":"\u5feb\u901f\u7522\u751f DHCP Server \u7684 dhcpd.conf \u683c\u5f0f\u6a94"},"content":{"rendered":"<p>\u5f9e \/var\/lib\/dhcpd\/dhcpd.leases\u00a0\u53d6\u51fa\u8981\u7684\u7db2\u8def\u5361\u5361\u865f<br \/># <span style=\"color: #ff0000;\">cat \/var\/lib\/dhcpd\/dhcpd.leases | grep hard | awk &#8216;{print $3}&#8217;<\/span><br \/><span style=\"color: #0000ff;\">d0:df:c7:f9:5c:ef;<\/span><br \/><span style=\"color: #0000ff;\">00:26:51:0d:53:40;<\/span><br \/><span style=\"color: #0000ff;\">00:11:93:88:7a:00;<\/span><br \/><span style=\"color: #0000ff;\">00:15:58:6b:7d:da;<\/span><br \/><span style=\"color: #0000ff;\">00:15:58:6b:7d:da;<\/span><br \/><span style=\"color: #0000ff;\">00:15:58:6b:7d:da;<\/span><br \/><span style=\"color: #0000ff;\">00:15:58:6b:7d:da;<\/span><\/p>\n<p>\u7d93\u904e\u8655\u7406\uff0c\u53ea\u53d6\u51fa\u60f3\u8981\u7684\u90e8\u5206<br \/># <span style=\"color: #ff0000;\">cat \/var\/lib\/dhcpd\/dhcpd.leases | grep hard | awk &#8216;{print $3}&#8217; | sed &#8216;s\/.$\/\/&#8217; | sort | uniq<\/span><br \/><span style=\"color: #0000ff;\">00:11:93:88:7a:00<\/span><br \/><span style=\"color: #0000ff;\">00:15:58:6b:7d:da<\/span><br \/><span style=\"color: #0000ff;\">00:26:51:0d:53:40<\/span><br \/><span style=\"color: #0000ff;\">d0:df:c7:f9:5c:ef<\/span><\/p>\n<p>\u6574\u7406\u5b8c\u7684\u8cc7\u6599\u6a94<br \/># <span style=\"color: #ff0000;\">cat \/root\/mac<\/span><br \/><span style=\"color: #0000ff;\">server1,00:11:93:88:7a:00,192.168.1.11<\/span><br \/><span style=\"color: #0000ff;\">server2,00:15:58:6b:7d:da,192.168.1.12<\/span><br \/><span style=\"color: #0000ff;\">server3,00:26:51:0d:53:40,192.168.1.13<\/span><br \/><span style=\"color: #0000ff;\">server4,d0:df:c7:f9:5c:ef,192.168.1.14<\/span><br \/>[@more@]<br \/>\u4f7f\u7528 awk<br \/># <span style=\"color: #ff0000;\">cat \/usr\/local\/bin\/mkdhcpd<\/span><br \/><span style=\"color: #0000ff;\">#!\/bin\/bash<\/span><br \/><span style=\"color: #0000ff;\">cat \/root\/mac | awk -F&#8221;,&#8221; &#8216;BEGIN{OFS=&#8221; &#8220;}{print $1,$2,$3 }&#8217; | while read i j k<\/span><br \/><span style=\"color: #0000ff;\">do<\/span><br \/><span style=\"color: #0000ff;\">\u00a0\u00a0 echo &#8220;host $i {&#8220;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0\u00a0 echo &#8221;\u00a0 hardware ethernet $j;&#8221;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0\u00a0 echo &#8221;\u00a0 fixed-address $k;&#8221;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0\u00a0 echo &#8220;}&#8221;<\/span><br \/><span style=\"color: #0000ff;\">done<\/span><\/p>\n<p>\u4f7f\u7528 sed<br \/># <span style=\"color: #ff0000;\">cat \/usr\/local\/bin\/mkdhcpd<\/span><br \/><span style=\"color: #0000ff;\">#!\/bin\/bash<\/span><br \/><span style=\"color: #0000ff;\">cat \/root\/mac | sed &#8216;s\/,\/ \/g&#8217; | while read i j k<\/span><br \/><span style=\"color: #0000ff;\">do<\/span><br \/><span style=\"color: #0000ff;\">\u00a0\u00a0 echo &#8220;host $i {&#8220;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0\u00a0 echo &#8221;\u00a0 hardware ethernet $j;&#8221;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0\u00a0 echo &#8221;\u00a0 fixed-address $k;&#8221;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0\u00a0 echo &#8220;}&#8221;<\/span><br \/><span style=\"color: #0000ff;\">done<\/span><\/p>\n<p>\u6e2c\u8a66<br \/># <span style=\"color: #ff0000;\">sh \/usr\/local\/bin\/mkdhcpd<\/span><br \/><span style=\"color: #0000ff;\">host server1 {<\/span><br \/><span style=\"color: #0000ff;\">\u00a0 hardware ethernet 00:11:93:88:7a:00;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0 fixed-address 192.168.1.11;<\/span><br \/><span style=\"color: #0000ff;\">}<\/span><br \/><span style=\"color: #0000ff;\">host server2 {<\/span><br \/><span style=\"color: #0000ff;\">\u00a0 hardware ethernet 00:15:58:6b:7d:da;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0 fixed-address 192.168.1.12;<\/span><br \/><span style=\"color: #0000ff;\">}<\/span><br \/><span style=\"color: #0000ff;\">host server3 {<\/span><br \/><span style=\"color: #0000ff;\">\u00a0 hardware ethernet 00:26:51:0d:53:40;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0 fixed-address 192.168.1.13;<\/span><br \/><span style=\"color: #0000ff;\">}<\/span><br \/><span style=\"color: #0000ff;\">host server4 {<\/span><br \/><span style=\"color: #0000ff;\">\u00a0 hardware ethernet d0:df:c7:f9:5c:ef;<\/span><br \/><span style=\"color: #0000ff;\">\u00a0 fixed-address 192.168.1.14;<\/span><br \/><span style=\"color: #0000ff;\">}<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f9e \/var\/lib\/dhcpd\/dhcpd.leases\u00a0\u53d6\u51fa\u8981\u7684\u7db2\u8def\u5361\u5361\u865f# cat \/var\/lib\/d &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/2blog.ilc.edu.tw\/25793\/2014\/02\/15\/%e5%bf%ab%e9%80%9f%e7%94%a2%e7%94%9f-dhcp-server-%e7%9a%84-dhcpd-conf-%e6%a0%bc%e5%bc%8f%e6%aa%94\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008\u5feb\u901f\u7522\u751f DHCP Server \u7684 dhcpd.conf \u683c\u5f0f\u6a94\u3009<\/span><\/a><\/p>\n","protected":false},"author":55,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[133,134,107,109,110],"tags":[],"class_list":["post-18191","post","type-post","status-publish","format-standard","hentry","category-c-78478","category-c-78479","category-c-72382","category-c-72384","category-c-72494"],"meta_key":{"_encloseme":["1"],"lt_post_id":["470952"]},"_links":{"self":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18191"}],"collection":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/comments?post=18191"}],"version-history":[{"count":0,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18191\/revisions"}],"wp:attachment":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/media?parent=18191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/categories?post=18191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/tags?post=18191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}