{"id":43008,"date":"2024-10-04T13:01:54","date_gmt":"2024-10-04T05:01:54","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43008\/"},"modified":"2024-10-04T13:01:54","modified_gmt":"2024-10-04T05:01:54","slug":"centos-7-4-%e7%84%a1%e4%ba%ba%e5%80%bc%e5%ae%88%e5%ae%89%e8%a3%9d%e7%92%b0%e5%a2%83%e6%90%ad%e5%bb%ba%ef%bc%88pxe-dhcp-tftp-kickstart-ftp%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43008\/","title":{"rendered":"CentOS 7.4 \u7121\u4eba\u503c\u5b88\u5b89\u88dd\u74b0\u5883\u642d\u5efa\uff08PXE + DHCP + TFTP + Kickstart + FTP\uff09"},"content":{"rendered":"<h1 id=\"centos-7-4-%e7%84%a1%e4%ba%ba%e5%80%bc%e5%ae%88%e5%ae%89%e8%a3%9d%e7%92%b0%e5%a2%83%e6%90%ad%e5%bb%ba%ef%bc%88pxe-dhcp-tftp-kickstart-ftp%ef%bc%89-WBUfVKLYvg\">CentOS 7.4 \u7121\u4eba\u503c\u5b88\u5b89\u88dd\u74b0\u5883\u642d\u5efa\uff08PXE + DHCP + TFTP + Kickstart + FTP\uff09<\/h1>\n<p>\u5728\u4f3a\u670d\u5668\u7ba1\u7406\u4e2d\uff0c\u7121\u4eba\u503c\u5b88\u5b89\u88dd\u662f\u4e00\u500b\u975e\u5e38\u5be6\u7528\u7684\u6280\u8853\uff0c\u7279\u5225\u662f\u5728\u9700\u8981\u6279\u91cf\u5b89\u88dd\u64cd\u4f5c\u7cfb\u7d71\u7684\u60c5\u6cc1\u4e0b\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7.4 \u74b0\u5883\u4e2d\u642d\u5efa\u4e00\u500b\u7121\u4eba\u503c\u5b88\u5b89\u88dd\u7684\u74b0\u5883\uff0c\u4f7f\u7528 PXE\u3001DHCP\u3001TFTP\u3001Kickstart \u548c FTP \u7b49\u6280\u8853\u3002<\/p>\n<h2 id=\"%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%99-WBUfVKLYvg\">\u74b0\u5883\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u6e96\u5099\u4ee5\u4e0b\u74b0\u5883\uff1a<\/p>\n<ul>\n<li>\u4e00\u53f0 CentOS 7.4 \u4f3a\u670d\u5668<\/li>\n<li>\u4e00\u53f0\u5ba2\u6236\u7aef\u6a5f\u5668\uff08\u53ef\u4ee5\u662f\u865b\u64ec\u6a5f\u6216\u5be6\u9ad4\u6a5f\uff09<\/li>\n<li>\u7db2\u8def\u9023\u63a5<\/li>\n<\/ul>\n<h2 id=\"%e5%ae%89%e8%a3%9d%e5%bf%85%e8%a6%81%e7%9a%84%e8%bb%9f%e9%ab%94-WBUfVKLYvg\">\u5b89\u88dd\u5fc5\u8981\u7684\u8edf\u9ad4<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88dd DHCP\u3001TFTP \u548c HTTP \u4f3a\u670d\u5668\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo yum install dhcp tftp-server vsftpd<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-dhcp-%e4%bc%ba%e6%9c%8d%e5%99%a8-WBUfVKLYvg\">\u914d\u7f6e DHCP \u4f3a\u670d\u5668<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e DHCP \u4f3a\u670d\u5668\uff0c\u4ee5\u4fbf\u70ba\u5ba2\u6236\u7aef\u5206\u914d IP \u5730\u5740\u3002\u7de8\u8f2f DHCP \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/dhcp\/dhcpd.conf<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>subnet 192.168.1.0 netmask 255.255.255.0 {\n    range 192.168.1.10 192.168.1.100;\n    option routers 192.168.1.1;\n    option domain-name-servers 8.8.8.8;\n    option broadcast-address 192.168.1.255;\n    option tftp-server-name \"192.168.1.2\";\n    option bootfile-name \"pxelinux.0\";\n}<\/code><\/pre>\n<p>\u8acb\u6839\u64da\u60a8\u7684\u7db2\u8def\u74b0\u5883\u8abf\u6574 IP \u5730\u5740\u548c\u7db2\u6bb5\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%ae-tftp-%e4%bc%ba%e6%9c%8d%e5%99%a8-WBUfVKLYvg\">\u914d\u7f6e TFTP \u4f3a\u670d\u5668<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e TFTP \u4f3a\u670d\u5668\u3002\u7de8\u8f2f TFTP \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/xinetd.d\/tftp<\/code><\/pre>\n<p>\u5c07\u4ee5\u4e0b\u5167\u5bb9\u6dfb\u52a0\u6216\u4fee\u6539\uff1a<\/p>\n<pre><code>service tftp\n{\n    socket_type     = dgram\n    protocol        = udp\n    wait            = yes\n    user            = root\n    server          = \/usr\/sbin\/in.tftpd\n    server_args     = -s \/var\/lib\/tftpboot\n    disable         = no\n}<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u91cd\u555f xinetd \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart xinetd<\/code><\/pre>\n<h2 id=\"%e8%a8%ad%e7%bd%ae-pxe-%e5%95%9f%e5%8b%95%e6%96%87%e4%bb%b6-WBUfVKLYvg\">\u8a2d\u7f6e PXE \u555f\u52d5\u6587\u4ef6<\/h2>\n<p>\u5728 TFTP \u6839\u76ee\u9304\u4e2d\u5275\u5efa\u5fc5\u8981\u7684\u76ee\u9304\u548c\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo mkdir \/var\/lib\/tftpboot\/pxelinux.cfg\nsudo cp \/usr\/share\/syslinux\/pxelinux.0 \/var\/lib\/tftpboot\/<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5275\u5efa\u4e00\u500b PXE \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/var\/lib\/tftpboot\/pxelinux.cfg\/default<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>DEFAULT linux\nLABEL linux\n    KERNEL vmlinuz\n    APPEND initrd=initrd.img ks=http:\/\/192.168.1.2\/ks.cfg<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-kickstart-%e6%96%87%e4%bb%b6-WBUfVKLYvg\">\u914d\u7f6e Kickstart \u6587\u4ef6<\/h2>\n<p>Kickstart \u6587\u4ef6\u7528\u65bc\u81ea\u52d5\u5316\u5b89\u88dd\u904e\u7a0b\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u4e00\u500b\u57fa\u672c\u7684 Kickstart \u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo system-config-kickstart<\/code><\/pre>\n<p>\u751f\u6210\u7684\u6587\u4ef6\u901a\u5e38\u4f4d\u65bc \/root\/ks.cfg\u3002\u5c07\u5176\u8907\u88fd\u5230 FTP \u4f3a\u670d\u5668\u7684\u6839\u76ee\u9304\uff1a<\/p>\n<pre><code>sudo cp \/root\/ks.cfg \/var\/ftp\/html\/<\/code><\/pre>\n<h2 id=\"%e5%95%9f%e5%8b%95-ftp-%e4%bc%ba%e6%9c%8d%e5%99%a8-WBUfVKLYvg\">\u555f\u52d5 FTP \u4f3a\u670d\u5668<\/h2>\n<p>\u78ba\u4fdd FTP \u4f3a\u670d\u5668\u6b63\u5728\u904b\u884c\uff0c\u4e26\u4e14\u53ef\u4ee5\u8a2a\u554f Kickstart \u6587\u4ef6\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 FTP \u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code>sudo systemctl start vsftpd<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e7%84%a1%e4%ba%ba%e5%80%bc%e5%ae%88%e5%ae%89%e8%a3%9d-WBUfVKLYvg\">\u6e2c\u8a66\u7121\u4eba\u503c\u5b88\u5b89\u88dd<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u53ef\u4ee5\u555f\u52d5\u5ba2\u6236\u7aef\u6a5f\u5668\uff0c\u4e26\u5f9e\u7db2\u8def\u555f\u52d5\u3002\u78ba\u4fdd\u5ba2\u6236\u7aef\u7684 BIOS \u8a2d\u7f6e\u70ba\u5f9e\u7db2\u8def\u555f\u52d5\u3002\u7576\u5ba2\u6236\u7aef\u555f\u52d5\u6642\uff0c\u5b83\u61c9\u8a72\u80fd\u5920\u901a\u904e PXE \u7372\u53d6 IP \u5730\u5740\uff0c\u4e26\u958b\u59cb\u7121\u4eba\u503c\u5b88\u5b89\u88dd\u904e\u7a0b\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-WBUfVKLYvg\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u7d93\u6210\u529f\u642d\u5efa\u4e86\u4e00\u500b CentOS 7.4 \u7684\u7121\u4eba\u503c\u5b88\u5b89\u88dd\u74b0\u5883\u3002\u9019\u7a2e\u65b9\u6cd5\u4e0d\u50c5\u63d0\u9ad8\u4e86\u5b89\u88dd\u6548\u7387\uff0c\u9084\u80fd\u6e1b\u5c11\u4eba\u70ba\u932f\u8aa4\u3002\u5c0d\u65bc\u9700\u8981\u5927\u91cf\u90e8\u7f72\u4f3a\u670d\u5668\u7684\u4f01\u696d\u4f86\u8aaa\uff0c\u9019\u662f\u4e00\u500b\u975e\u5e38\u6709\u7528\u7684\u6280\u8853\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5c0d\u65bc\u4f3a\u670d\u5668\u7ba1\u7406\u6709\u66f4\u591a\u9700\u6c42\uff0c\u6b61\u8fce\u4e86\u89e3\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u63d0\u4f9b\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u670d\u52d9\uff0c\u52a9\u60a8\u8f15\u9b06\u7ba1\u7406\u4f3a\u670d\u5668\u74b0\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn to set up a CentOS 7.4 unattended installation environment using PXE, DHCP, TFTP, Kickstart, and FTP for efficient deployment.<\/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-43008","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43008","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=43008"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43008\/revisions"}],"predecessor-version":[{"id":43009,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43008\/revisions\/43009"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}