{"id":43152,"date":"2024-10-04T19:01:30","date_gmt":"2024-10-04T11:01:30","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43152\/"},"modified":"2024-10-04T19:01:31","modified_gmt":"2024-10-04T11:01:31","slug":"centos-7-%e9%85%8d%e7%bd%ae-dhcp","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43152\/","title":{"rendered":"CentOS 7 \u914d\u7f6e DHCP"},"content":{"rendered":"<h1 id=\"centos-7-%e9%85%8d%e7%bd%ae-dhcp-HPPMCprzCy\">CentOS 7 \u914d\u7f6e DHCP<\/h1>\n<p>\u5728\u7db2\u7d61\u7ba1\u7406\u4e2d\uff0cDHCP\uff08\u52d5\u614b\u4e3b\u6a5f\u914d\u7f6e\u5354\u8b70\uff09\u662f\u4e00\u500b\u81f3\u95dc\u91cd\u8981\u7684\u6280\u8853\uff0c\u5b83\u80fd\u5920\u81ea\u52d5\u70ba\u7db2\u7d61\u4e2d\u7684\u8a2d\u5099\u5206\u914dIP\u5730\u5740\u53ca\u5176\u4ed6\u7db2\u7d61\u914d\u7f6e\u53c3\u6578\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728CentOS 7\u4e0a\u914d\u7f6eDHCP\u670d\u52d9\u5668\uff0c\u5e6b\u52a9\u7528\u6236\u66f4\u6709\u6548\u5730\u7ba1\u7406\u5176\u7db2\u7d61\u74b0\u5883\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9ddhcp%e6%9c%8d%e5%8b%99%e5%99%a8-HPPMCprzCy\">\u5b89\u88ddDHCP\u670d\u52d9\u5668<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u60a8\u7684CentOS 7\u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u66f4\u65b0\uff1a<\/p>\n<pre><code>sudo yum update<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88ddDHCP\u670d\u52d9\u5668\u8edf\u4ef6\u5305\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo yum install dhcp<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%aedhcp%e6%9c%8d%e5%8b%99%e5%99%a8-HPPMCprzCy\">\u914d\u7f6eDHCP\u670d\u52d9\u5668<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u7de8\u8f2fDHCP\u914d\u7f6e\u6587\u4ef6\uff0c\u8a72\u6587\u4ef6\u4f4d\u65bc \/etc\/dhcp\/dhcpd.conf\u3002\u4f7f\u7528\u60a8\u559c\u6b61\u7684\u6587\u672c\u7de8\u8f2f\u5668\u6253\u958b\u8a72\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/dhcp\/dhcpd.conf<\/code><\/pre>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u60a8\u9700\u8981\u8a2d\u7f6e\u4ee5\u4e0b\u5e7e\u500b\u4e3b\u8981\u53c3\u6578\uff1a<\/p>\n<ul>\n<li><strong>\u7db2\u6bb5\u914d\u7f6e\uff1a<\/strong>\u6307\u5b9aDHCP\u670d\u52d9\u5668\u5c07\u8981\u5206\u914d\u7684IP\u5730\u5740\u7bc4\u570d\u3002<\/li>\n<li><strong>\u5b50\u7db2\u63a9\u78bc\uff1a<\/strong>\u5b9a\u7fa9\u7db2\u7d61\u7684\u5b50\u7db2\u63a9\u78bc\u3002<\/li>\n<li><strong>\u9ed8\u8a8d\u8def\u7531\u5668\uff1a<\/strong>\u8a2d\u7f6e\u7db2\u7d61\u7684\u9ed8\u8a8d\u7db2\u95dc\u3002<\/li>\n<li><strong>DNS\u4f3a\u670d\u5668\uff1a<\/strong>\u6307\u5b9a\u7528\u6236\u7aef\u4f7f\u7528\u7684DNS\u4f3a\u670d\u5668\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u793a\u4f8b\u914d\u7f6e\uff1a<\/p>\n<pre><code>subnet 192.168.1.0 netmask 255.255.255.0 {\n    range 192.168.1.100 192.168.1.200;\n    option routers 192.168.1.1;\n    option domain-name-servers 8.8.8.8, 8.8.4.4;\n    option domain-name \"example.com\";\n}<\/code><\/pre>\n<p>\u5728\u9019\u500b\u793a\u4f8b\u4e2d\uff0cDHCP\u670d\u52d9\u5668\u5c07\u5728192.168.1.100\u5230192.168.1.200\u4e4b\u9593\u5206\u914dIP\u5730\u5740\uff0c\u4e26\u8a2d\u7f6e\u9ed8\u8a8d\u8def\u7531\u5668\u548cDNS\u4f3a\u670d\u5668\u3002<\/p>\n<h2 id=\"%e5%95%9f%e5%8b%95dhcp%e6%9c%8d%e5%8b%99-HPPMCprzCy\">\u555f\u52d5DHCP\u670d\u52d9<\/h2>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u555f\u52d5DHCP\u670d\u52d9\u4e26\u8a2d\u7f6e\u5176\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u555f\u52d5DHCP\u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start dhcpd<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8a2d\u7f6eDHCP\u670d\u52d9\u5728\u555f\u52d5\u6642\u81ea\u52d5\u904b\u884c\uff1a<\/p>\n<pre><code>sudo systemctl enable dhcpd<\/code><\/pre>\n<h2 id=\"%e6%aa%a2%e6%9f%a5dhcp%e6%9c%8d%e5%8b%99%e7%8b%80%e6%85%8b-HPPMCprzCy\">\u6aa2\u67e5DHCP\u670d\u52d9\u72c0\u614b<\/h2>\n<p>\u8981\u6aa2\u67e5DHCP\u670d\u52d9\u7684\u904b\u884c\u72c0\u614b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo systemctl status dhcpd<\/code><\/pre>\n<p>\u5982\u679c\u670d\u52d9\u904b\u884c\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u6703\u770b\u5230\u985e\u4f3c\u65bc\u201cactive (running)\u201d\u7684\u72c0\u614b\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e9%98%b2%e7%81%ab%e7%89%86%e8%a8%ad%e7%bd%ae-HPPMCprzCy\">\u9632\u706b\u7246\u8a2d\u7f6e<\/h2>\n<p>\u78ba\u4fdd\u60a8\u7684\u9632\u706b\u7246\u5141\u8a31DHCP\u6d41\u91cf\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u958b\u653eDHCP\u7aef\u53e3\uff1a<\/p>\n<pre><code>sudo firewall-cmd --permanent --add-service=dhcp<\/code><\/pre>\n<p>\u7136\u5f8c\u91cd\u65b0\u52a0\u8f09\u9632\u706b\u7246\u914d\u7f6e\uff1a<\/p>\n<pre><code>sudo firewall-cmd --reload<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-HPPMCprzCy\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u7d93\u6210\u529f\u5728CentOS 7\u4e0a\u914d\u7f6e\u4e86DHCP\u670d\u52d9\u5668\u3002\u9019\u5c07\u4f7f\u60a8\u80fd\u5920\u66f4\u6709\u6548\u5730\u7ba1\u7406\u7db2\u7d61\u4e2d\u7684IP\u5730\u5740\u5206\u914d\uff0c\u6e1b\u5c11\u624b\u52d5\u914d\u7f6e\u7684\u5de5\u4f5c\u91cf\u3002\u5982\u679c\u60a8\u9700\u8981\u9032\u4e00\u6b65\u7684\u652f\u6301\u6216\u5c0b\u627e\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\u4f86\u63d0\u5347\u60a8\u7684\u7db2\u7d61\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to configure DHCP on CentOS 7 with step-by-step instructions for setting up a reliable network service.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-43152","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=43152"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43152\/revisions"}],"predecessor-version":[{"id":43153,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43152\/revisions\/43153"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}