Ubuntu双网卡配置
Ubuntu 17.10双网卡配置
Ubuntu网络配置多年来一直在用NetworkManager,ifupdown等工具. 17.10引入netplan作为在Ubuntu中配置接口的标准声明性YAML语法
Ubuntu 17.10版本修改网络固定IP的方法跟其他版本不一样 不需要修改/etc/network/interfaces
文件,而是通过在/etc/netplan/
下创建一个自定义YAML配置文件来实现
创建一个YAML文件
sudo vim /etc/netplan/01-netcfg.yaml
以我的配置为例,我的第二个网卡名称是enp0s8
,设置成固定IP方便宿主机SSH远程
YAML内容:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp0s8:
dhcp4: no
addresses: [192.168.56.2/24]
确认配置并重启
sudo netplan apply
sudo init 6
Ubuntu 17.10以下双网卡配置
修改Ubuntu的网络配置文件
sudo vim /etc/network/interfaces
配置如下
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
#the second eth1
auto eth1
iface eth1 inet static
address 192.168.56.2
netmask 255.255.255.0
- eth0为NAT模式的网卡,eth1为Host-only的网卡
- 主机和虚拟机通信用192.168.56.*这个网段
重启虚拟机
参考
Copyright © 2015 Powered by MWeb, Theme used GitHub CSS.