网上的方法经常不成功,在装n次之后终于总结出一套行之有效的方法
1
sudo vim /etc/network/interfaces
别漏了s 是interfaces 而不是interface ,这里失败了n次
2这里的ip根据自己需要设置
auto lo
iface lo inet loopback
auto ens33
iface ens33 inet static
address 192.168.0.121
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameserver 8.8.8.8
3!
3 :wq! 保存退出 root状态下可以不用 ' ! '
4 重启网络
sudo /etc/init.d/networking restart
5 输入 ifconfig 查看ip
基本上这里不会改变 需要shutdown一下
大功告成