/etc/network/interfaces
里:
# enp0s2 是网卡名称
auto enp0s2
iface enp0s2 inet static
address 10.249.44.127
netmask 255.255.248.0
gateway 10.249.40.1
dns-nameserver 10.248.98.30
网卡名字和当前子网掩码可以通过ip addr
看。
当前网关可以通过route -n
查看。
当前dns服务器的IP在/etc/resolv.conf
里。
重启网络:
sudo /etc/init.d/networking restart
如果失败了,就直接重启机器吧。