标签:网关 子网 systemctl pre end 关闭防火墙 emc 增强功能 image
#!/bin/bash
yum install dhcp -y //安装DHCP服务
yum install expect -y //安装expect工具
/usr/bin/expect <<-EOF
spawn cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
//spawn追踪后面的命令
expect{ //匹配
"cp*" //用“*”代表后面一长串命令
{send "yes\r"} //交互式输入yes ‘\r’代表回车
}
expect eof
EOF
cat <<-EOF >> /etc/dhcp/dhcpd.conf //在DHCP配置文件中写入命令
subnet 192.168.100.0 netmask 255.255.255.0 { //网段,子网掩码
range 192.168.100.20 192.168.100.200; //网段范围
option routers 192.168.100.1; //网关
EOF
}
EOF
systemctl stop firewalld.service //关闭防火墙
setenforce 0 //关闭增强功能
systemctl start dhcpd //开启DHCP服务
标签:网关 子网 systemctl pre end 关闭防火墙 emc 增强功能 image
原文地址:https://blog.51cto.com/14449524/2441608