臨時配置IP地址
首先 ifconfig eth0 192.168.0.53/24 #24代表子網255.255.255.0 臨時配置IP
其次 route add default gw 192.168.0.1 #配置默認路由
ping 192.168.0.1

當然這時ping 不通百度,DNS沒配 vim /etc/resolv.conf #配置DNS服務器
編輯 nameserver 8.8.8.8 (谷歌公用服務器) nameserver 114.114.114.114 (電信)
永久配置IP地址
vim /etc/network/interfaces 使用橋接網絡根據宿主機IP地址修改,編輯中加入 auto eth0 #iface eth0 inet dhcp #把原文件中的這一行注釋掉
iface eth0 inet static address 192.168.0.53 netmask 255.255.255.0 gateway 192.168.0.1 如果想看自己編輯的是哪一行 按Esc ,然后:set number 顯示行 #這里的地址和網關根據你自己的網段進行配置


之后 systemctl restart networking #重啟網絡服務
/etc/init.d/networking restart 也可以