Ubuntu网卡更改名称:ens3=>eth0
步骤1:首先切换到 root 账号,然后 vi /etc/default/grub;
步骤2:修改参数 GRUB_CMDLINE_LINUX 添加 net.ifnames=0 biosdevname=0;
步骤3:然后保存文件,执行命令update-grub
步骤4:编辑文件 /etc/network/interface 保存后重启ubuntu
步骤5:最后验证是否修改成功
网卡配置文件:/etc/network/interface
修改方式:
1.切换到root用户修改
2.使用sudo命令授权
默认配置文件内容:
cheng@ubuntu:~$ sudo cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
修改,添加静态地址:
cheng@ubuntu:~$ sudo vi /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.40.14
gateway 192.168.40.1
netmask 255.255.255.0
重启网络:
cheng@ubuntu:~$ sudo /etc/init.d/networking --help
Usage: /etc/init.d/networking {start|stop|reload|restart|force-reload}
cheng@ubuntu:~$ sudo /etc/init.d/networking restart
[ ok ] Restarting networking (via systemctl): networking.service.
添加一块网卡eth1
auto eth1
iface eth1 inet static
address 192.168.40.15
netmask 255.255.255.0
gateway 192.168.40.1