Ubuntu 16.04 Bridge配置
一、安裝網橋拓展包 bridge-utils
root@ubuntu:~# apt-get install bridge-utils
二、創建網橋設備
//安裝網橋拓展包會安裝 brctl 命令,使用該命令創建網橋設備
root@ubuntu:~# brctl addbr br1 # br1是網橋設備名,類似網卡名稱;也可以創建多個網橋設備
//可以在 /proc/sys/net/ipv4/conf/ 目錄下查看創建的和已經存在的網卡設備文件
root@ubuntu:~# ls /proc/sys/net/ipv4/conf/
all br0 default eth0 eth1 eth2 eth3 eth4 lo # br0 就是剛剛創建的網橋名稱
三、配置 bridge-utils
root@ubuntu:~# vim /etc/network/interfaces
# network interface settings; autogenerated
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
auto eth1
iface eth1 inet manual
auto eth2
iface wth2 inet manual
auto eth3
iface eth3 inet manual
auto br0
iface br0 inet static
address 192.168.121.24
netmask 255.255.255.0
gateway 211.91.165.129
bridge_ports eth0
bridge_stp off
bridge_fd 0
auto br1
iface br1 inet manual
bridge_ports eth1
bridge_stp off
bridge_fd 0
auto br2
iface br2 inet manual
bridge_ports eth2
bridge_stp off
bridge_fd 0
auto br3
iface br3 inet manual
bridge_ports eth3
bridge_stp off
bridge_fd 0
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
auto eth1
iface eth1 inet manual
auto eth2
iface wth2 inet manual
auto eth3
iface eth3 inet manual
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_ports eth1
bridge_ports eth2
bridge_ports eth3
bridge_stp off
bridge_fd 0
四、開啟路由轉發
//網橋設置好后,需要設置路由轉發功能
root@ubuntu:~# /etc/sysctl.conf
......
net.ipv4.ip_forward=1 # 添加或者去掉注釋這一行
......
//讓轉發路由生效
root@ubuntu:~# sysctl -p
五、重啟網絡服務
root@ubuntu:~# systemctl restart networking.service