查看ip地址 ifconfig
首先 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 (电信)
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 也可以