Skip to content

Instantly share code, notes, and snippets.

@bczhc
Created January 29, 2026 07:26
Show Gist options
  • Select an option

  • Save bczhc/aae0a6f2e8b831816ade84f2cc8d8ca6 to your computer and use it in GitHub Desktop.

Select an option

Save bczhc/aae0a6f2e8b831816ade84f2cc8d8ca6 to your computer and use it in GitHub Desktop.
Linux创建桥接网卡 #network
# 1. 创建网桥设备
sudo ip link add name br0 type bridge
sudo ip link set br0 up

# 2. 将物理网卡 enp47s0 的 IP 清除(此时会断网)
sudo ip addr flush dev enp47s0

# 3. 将物理网卡挂载到网桥上
sudo ip link set enp47s0 master br0
sudo ip link set enp47s0 up

# 4. 让网桥通过 dhclient 获取 IP
sudo dhclient br0

现在的br0等于是个虚拟二层交换机。在virt-manager中可用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment