vim /etc/network/interfaces //修改interface配置文件
nface eth0 inet static 設置 eth0 網卡爲靜態地址/DHCP爲動態
address 192.168.1.66IP地址
gateway 192.168.1.2 默認網關
netmask 255.255.255.0 子網掩碼
vim /etc/resolv.conf //設置dns
nameserver 設置dns
/etc/init.d/networking restart //重啓網卡即可
如果遇到這種報錯執行一下命令。
ip addr flush dev eth0 && /etc/init.d/networking restart
//這個命令會讓你斷開遠程連接,然後在重啓網卡