我这才用的是Ubuntu的
netplan
网络管理,当然也可以采用systemd-network
网络管理。未测试通过,所以下操作均建立在netplan
管理方式上。
设置桥接
- 安装
bridge-utils
apt install bridge-utils -y
- 创建名为
br0
桥接虚拟网卡
brctl addbr br0
- 设置桥接
# 查看一下宿主机网卡名,网卡名为:enp3s0f0
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp3s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
link/ether 38:c9:86:11:11:e4 brd ff:ff:ff:ff:ff:ff
inet 172.19.14.27/24 brd 172.19.14.255 scope global enp3s0f0
valid_lft forever preferred_lft forever
# 修改yaml配置文件,配置如下
cat /etc/netplan/00-installer-config.yaml
# 配置网卡信息,我这里设置的静态IP
network:
version: 2
renderer: networkd
ethernets:
enp3s0f0:
# 开启dhcp则改为yes
dhcp4: no
# 如果是dhcp则注释以下
addresses:
- 172.19.14.27/24
routes:
- to: 0.0.0.0/0
via: 172.19.14.254
metric: 100
nameservers:
addresses:
- 10.18.8.17
- 172.19.43.151
#注释结束
# 绑定桥接
bridges:
br0:
interfaces: [enp3s0f0]
dhcp4: true # 或者配置静态 IP,根据需要选择
# 重启服务,让配置生效
netplan apply
番外篇
采用
systemd-network
网络管理,未测试通过。先记一下!
- 删除
netplan
服务
rm -rf /etc/netplan/
- 写配置文件
cd /etc/systemd/network
cat enp3s0f0.network
[Match]
Name=enp3s0f0
[Network]
Address=10.1.1.10/19
Gateway=10.1.1.254
DNS=223.5.5.5
DNS=223.6.6.6
Bridge=br0
cat br0.netdev
[NetDev]
Name=br0
Kind=bridge
cat br0.network
[Match]
Name=br0
[Network]
Address=10.37.96.171/20
ConfigureWithoutCarrier=yes
[Route]
Destination=0.0.0.0/0
Gateway=10.37.96.1
标签:00,lft,桥接,创建,netplan,br0,enp3s0f0,Ubuntu
From: https://www.cnblogs.com/98record/p/ubuntu-chuang-jian-qiao-jie-wang-luo.html