GrabBag/Tools/ubuntu桥接.md
2026-01-16 01:04:43 +08:00

1.1 KiB
Raw Permalink Blame History

ubuntu 网卡间桥接

目的是对ubuntu的两个网卡进行桥接使得连接在连个不同的网卡的设备进行互通。首先保证设备有两个网卡

配置网卡信息

临时配置网卡

  • eth0
    ifconfig eth0 192.168.10.100/24
    
  • eth1
    ifconfig eth1 192.168.20.100/24
    

长期有效

  • 通过ubuntu桌面配置

  • nmcli配置参考链接

  • nmtui 配置

    备注:

    # 查看IP 
    ifconfig
    # 查看路由
    route
    

创建桥接网卡

  • 创建桥接点
    sudo nmcli connection add type bridge ifname br0 stp no
    
  • 物理网卡连接桥接
    sudo nmcli connection add type bridge-slave ifname eth0 master br0
    sudo nmcli connection add type bridge-slave ifname eth1 master br0
    

启动桥接

sudo nmcli connection up bridge-br0
sudo nmcli connection up bridge-slave-eth0
sudo nmcli connection up bridge-slave-eth1