使用方法<p style="margin-right: 0cm; margin-left: 0cm;font-size:14px; font-family: 宋体; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span> </span>1.将正常机与问题机网线直连</p><p style="margin-right: 0cm; margin-left: 0cm;font-size:14px; font-family: 宋体; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"> 2.将附件考入u盘,插入正常机,root运行脚本。它会报问题机的ip和通断情况。</p><p style="margin-right: 0cm; margin-left: 0cm;font-size:14px; font-family: 宋体; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"> 3.若通,ssh即可</p>
#!/bin/bash
###先确保在网卡服务已经开启
#安装dhcp服务
sudo dpkg -i isc-dhcp-server*.deb
#配置DHCP网卡
sed -i 's/INTERFACES=""/INTERFACES="eth0"/g' /etc/default/isc-dhcp-server
#改配置文件
(
cat <<EOF
ddns-update-style none;
option domain-name "tagpt.mtn";
default-lease-time 14400;
#最小租约14400秒=4小时
max-lease-time 36000;
#最大租约36000秒=10小时
subnet 192.168.7.0 netmask 255.255.255.0 {
#IP地址起止范围
range 192.168.7.190 192.168.7.199;
option subnet-mask 255.255.255.0;
#子网掩码 255.255.255.0
option routers 192.168.7.254;
#默认网关 192.168.7.254
option broadcast-address 192.168.7.255;
#广播地址 192.168.7.255
}
EOF
) >/etc/dhcp/dhcpd.conf
#重启服务
sudo service isc-dhcp-server restart
#现场使用
sudo ifconfig eth0 192.168.7.110 netmask 255.255.255.0
sudo route add default gw 192.168.7.254
if [ ! -n "`ping 192.168.7.190 -i 0.2 -c 10 | grep error`" ]; then
echo
echo 通 192.168.7.190
echo
else
echo 不通 192.168.7.190
fi
附件:1、本脚本工具
2、dhcpsever软件,可根据自己的机器下载,以ubuntu为例http://packages.ubuntu.com/xenial/isc-dhcp-server