1.查看所有可用网卡
$ ifconfig -a
# -a display all interfaces which are currently available, even if down
2.编辑配置文件
$ sudo vim /etc/network/interfaces
3.添加可用网卡信息
# 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 enp0s3
iface enp0s3 inet dhcp
# Host-Only network interface
auto enp0s8
iface enp0s8 inet static
address 192.168.56.100
netmask 255.255.255.0
gateaway 192.168.56.1
在VBox中安装虚拟机时,网卡enp0s8默认是没有配置的,这里手动配置一下。
4.重启网络服务
$ sudo systemctl restart networking
# 或
$ sudo /etc/init.d/networking restart
5.查看网卡信息
$ ifconfig