ubuntu配置IP地址

使用ubuntu 16.04 server版本
ubuntu server版本只用这个文件作为网卡配置。
1、编辑网卡文件
sudo vim /etc/network/interfaces

2、添加参数
动态:
auto eth0
iface eth0 inet dhcp
静态:
auto eth0
iface eth0 inet static
address 192.168.199.61
netmask 255.255.255.0
gateway 192.168.199.1
dns-nameservers 114.114.114.114
#pre-up ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx(要改成的MAC)
#从udev中查看

3、服务重启
sudo /etc/init.d/networking restart

4、ping dns测试
ping 114.114.114.114

原文地址:https://www.cnblogs.com/yujiebin/p/10053163.html