遠程調試沒配網絡的電腦

使用方法<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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章