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

43 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ubuntu 网卡间桥接
目的是对ubuntu的两个网卡进行桥接使得连接在连个不同的网卡的设备进行互通。首先保证设备有两个网卡
# 配置网卡信息
## 临时配置网卡
* eth0
```
ifconfig eth0 192.168.10.100/24
```
* eth1
```
ifconfig eth1 192.168.20.100/24
```
## 长期有效
* 通过ubuntu桌面配置
* nmcli配置[参考链接](https://blog.csdn.net/u013012082/article/details/149013734?fromshare=blogdetail&sharetype=blogdetail&sharerId=149013734&sharerefer=PC&sharesource=u013012082&sharefrom=from_link)
* 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
```