PXE网络安装 debian&&uos

第一种:

DHCP+TFTP

安装DHCP

sudo apt-get install isc-dhcp-server
cp /usr/share/doc/isc-dhcp-server/examples/dhcpd.conf.example /etc/dhcp/
mv /etc/dhcp/dhcpd.conf.examples /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf

    subnet 192.168.10.0 netmask 255.255.255.0 {     ##本地ip的网段和子网掩码
    range 192.168.10.10 192.168.10.20;              ##DHCP服务器ip范围
    option routers 192.168.10.254;                  ##本地网络网关
    option broadcast-address 192.168.10.255;        ##当前网段广播地址
    default-lease-time 600;
    max-lease-time 7200;
    filename "pxelinux.0";             ##tftp目录的引导文件
    next-server 192.168.10.1;        ##TFTP地址
    }

systemctl restart sc-dhcp-server

安装及配置TFTP

sudo apt-get install openbsd-inetd tftpd-hpa
vim /etc/default/tftp-hpa

    TFTP_USERNAME="tftp"
    TFTP_DIRECTORY="/tftpboot"                  ##设置TFTP的根目录为/tftpboot
    TFTP_ADDRESS="0.0.0.0:69"                  ##设置侦听所有网卡的69端口
    TFTP_OPTIONS="--secure"

sudo mkdir /tftpboot
cd /tftpboot
wget http://ftp.nl.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/netboot.tar.gz
tar -zxvf netboot.tar.gz
systemctl restart openbsd-inetd
systemctl restart tftpd-hpa
虚拟机启动
进入引导
测试成功

第二种:dnsmasq

ip addr
查看ip 网卡 mac地址
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

link/ether 00:0c:29:a5:0d:25 brd ff:ff:ff:ff:ff:ff
inet 172.16.130.136/24 brd 172.16.130.255 scope global dynamic noprefixroute ens33
   valid_lft 1155sec preferred_lft 1155sec
inet6 fe80::e7a2:42b5:e749:9da8/64 scope link noprefixroute 
   valid_lft forever preferred_lft forever

网卡ens33
ip 172.16.130.136
MAC地址 00:0c:29:a5:0d:25
sudo apt-get install dnsmasq -y

vim /etc/dnsmasq.conf            
interface=eth0                                          ##网卡接口名
listen-address=127.0.0.1                                
listen-address=172.16.130.136
bind-interfaces
dhcp-range=172.16.130.100,172.16.130.200,12h
dhcp-host=00:0c:29:a5:0d:25,172.16.130.136
dhcp-option=3,172.16.130.136
dhcp-option=6,172.16.130.136
dhcp-option=28,172.16.130.255
dhcp-option=42,172.16.130.136
dhcp-boot=pxelinux.0,pxeserver,172.16.130.136
pxe-prompt="What system shall I netboot?"
pxe-prompt="Press F8 for menu.",1
pxe-prompt="PXE Boot",1
pxe-service=0,"Grub start",pxelinux.0.,172.16.130.136
enable-tftp
tftp-root=/nfs/pxedata                                   ##tftp目录
log-queries

安装nfs

sudo apt install nfs-kernel-server -y
sudo mkdir /data/nfs/ /nfs
sudo mount -B /data/nfs /nfs
sudo chmod 0777 /data/nfs -R

vim /etc/exports
/nfs 172.16.130.0/24(rw,no_subtree_check,async,crossmnt,insecure,fsid=0,no_root_squash)

cd /nfs/pxedata
wget http://ftp.nl.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/netboot.tar.gz
tar -zxvf netboot.tar.gz

sudo systemctl resatrt dnsmasq

虚拟机测试.....###PXE网络安装 debian&&uos

第一种:

DHCP+TFTP

安装DHCP

sudo apt-get install isc-dhcp-server
cp /usr/share/doc/isc-dhcp-server/examples/dhcpd.conf.example /etc/dhcp/
mv /etc/dhcp/dhcpd.conf.examples /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf

    subnet 192.168.10.0 netmask 255.255.255.0 {     ##本地ip的网段和子网掩码
    range 192.168.10.10 192.168.10.20;              ##DHCP服务器ip范围
    option routers 192.168.10.254;                  ##本地网络网关
    option broadcast-address 192.168.10.255;        ##当前网段广播地址
    default-lease-time 600;
    max-lease-time 7200;
    filename "pxelinux.0";             ##tftp目录的引导文件
    next-server 192.168.10.1;        ##TFTP地址
    }

systemctl restart sc-dhcp-server

安装及配置TFTP

sudo apt-get install openbsd-inetd tftpd-hpa
vim /etc/default/tftp-hpa

    TFTP_USERNAME="tftp"
    TFTP_DIRECTORY="/tftpboot"                  ##设置TFTP的根目录为/tftpboot
    TFTP_ADDRESS="0.0.0.0:69"                  ##设置侦听所有网卡的69端口
    TFTP_OPTIONS="--secure"

sudo mkdir /tftpboot
cd /tftpboot
wget http://ftp.nl.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/netboot.tar.gz
tar -zxvf netboot.tar.gz
systemctl restart openbsd-inetd
systemctl restart tftpd-hpa
虚拟机启动
进入引导
测试成功

第二种:dnsmasq

ip addr
查看ip 网卡 mac地址
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

link/ether 00:0c:29:a5:0d:25 brd ff:ff:ff:ff:ff:ff
inet 172.16.130.136/24 brd 172.16.130.255 scope global dynamic noprefixroute ens33
   valid_lft 1155sec preferred_lft 1155sec
inet6 fe80::e7a2:42b5:e749:9da8/64 scope link noprefixroute 
   valid_lft forever preferred_lft forever

网卡ens33
ip 172.16.130.136
MAC地址 00:0c:29:a5:0d:25
sudo apt-get install dnsmasq -y

vim /etc/dnsmasq.conf            
interface=eth0                                          ##网卡接口名
listen-address=127.0.0.1                                
listen-address=172.16.130.136
bind-interfaces
dhcp-range=172.16.130.100,172.16.130.200,12h
dhcp-host=00:0c:29:a5:0d:25,172.16.130.136
dhcp-option=3,172.16.130.136
dhcp-option=6,172.16.130.136
dhcp-option=28,172.16.130.255
dhcp-option=42,172.16.130.136
dhcp-boot=pxelinux.0,pxeserver,172.16.130.136
pxe-prompt="What system shall I netboot?"
pxe-prompt="Press F8 for menu.",1
pxe-prompt="PXE Boot",1
pxe-service=0,"Grub start",pxelinux.0.,172.16.130.136
enable-tftp
tftp-root=/nfs/pxedata                                   ##tftp目录
log-queries

安装nfs

sudo apt install nfs-kernel-server -y
sudo mkdir /data/nfs/ /nfs
sudo mount -B /data/nfs /nfs
sudo chmod 0777 /data/nfs -R

vim /etc/exports
/nfs 172.16.130.0/24(rw,no_subtree_check,async,crossmnt,insecure,fsid=0,no_root_squash)

cd /nfs/pxedata
wget http://ftp.nl.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/netboot.tar.gz
tar -zxvf netboot.tar.gz

sudo systemctl resatrt dnsmasq

虚拟机测试.....

最后修改:2021 年 01 月 25 日
如果觉得我的文章对你有用,请随意赞赏