1. 程式人生 > >第二十章linux~高階網路配置

第二十章linux~高階網路配置

一 ,網路橋接brod bond網路

什麼是Bond

簡單的說,bonding就是把多個物理網路介面繫結到一起,使它們就像一個網路介面那樣執行。   通過Bonding技術,可以實現網口冗餘,負載均衡,從而達到高可用高可靠的目的 bond的主要三種策略模式 平衡掄迴圈策略 主-備份策略 平衡策略

1.一臺虛擬機器共需要兩個網絡卡。首先新增網絡卡(NIC) nm-connection-editor 清除裡面的網絡卡資訊 nmcli connection add con-name bond0 ifname bond0 type bond mode active-backupip4 ip/24 建立bond0並指定ip 在這裡插入圖片描述

nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0 nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 在這裡插入圖片描述 上述時給bond0新增eth0和eth1網絡卡 watch -n 1 cat /proc/net/bonding/bond0 監控變化 在這裡插入圖片描述 新增網絡卡之後就可以網路ping通自己真機ip 在這裡插入圖片描述 ifconfig eth0 down 停止這個網絡卡 ifconfig eth0 up 啟用這個網絡卡 2.用配置檔案配備bond nm-connection-editor 清除裡面的網絡卡資訊 在這裡插入圖片描述

cd /etc/sysconfig/network-scripts vim ifcfg-bond0 編輯bond0 在這裡插入圖片描述 systemctl restart network 重啟網路 在這裡插入圖片描述 vim ifcfg-eth0 編輯網絡卡 在這裡插入圖片描述 systemctl restart network 在這裡插入圖片描述 cp ifcfg-eth0 ifcfg-eth1 在這裡插入圖片描述 vim ifcfg-eth1 在這裡插入圖片描述 systemctl restart network systemctl restart NetworkManager 在這裡插入圖片描述 watch -n 1 cat /proc/net/bonding/bond0 監控變化 在這裡插入圖片描述 3.team 命令方式 nm-connection-editor 清除裡面的網絡卡資訊 nmcli connection ad con-name team0 ifname team0 type team config’{“runner”:{“name”:“activebackup”}}’ ip4 ip/24 新增team0 ifconfig檢視是否編輯成功 在這裡插入圖片描述
在這裡插入圖片描述 nmcli connection add con-name eth0 ifname eth0 type team-slave master team0 新增網絡卡eth0 nmcli connection add con-name eth1 ifname eth1 type team-slave master team0 新增網絡卡eth1 teamdctl team0 stat 檢視變化 在這裡插入圖片描述 ifconfig eth0 down 停止這個網絡卡 ifconfig eth0 up 啟用這個網絡卡 在這裡插入圖片描述 4,team配置檔案 nm-connection-editor 清除裡面的網絡卡資訊 cd /etc/sysconfig/network-scripts vim ifcfg-team0 編輯team0 在這裡插入圖片描述 systemctl restart network 重啟網路 vim ifcfg-eth0 編輯網絡卡 在這裡插入圖片描述 systemctl restart network cp ifcfg-eth0 ifcfg-eth1 因為eth0和eth1編輯內容一樣 所以複製過來進去將eth0改為eth1 vim ifcfg-eth1 在這裡插入圖片描述 systemctl restart network systemctl restart NetworkManager teamdctl team0 stat 檢視 在這裡插入圖片描述 5.配置網路橋接 網橋就是網路橋接,用來連線不同的網段

可以使虛擬機器的網絡卡直接連線到真機的真實網絡卡,使上網速度更快 備份ifcfg-br0,ifcfg-enp3s0 在這裡插入圖片描述

清除網絡卡多餘資訊 在這裡插入圖片描述 reboot 重啟 在這裡插入圖片描述 新建網路檔案 在這裡插入圖片描述 在這裡插入圖片描述 在這裡插入圖片描述 重新啟動網路 在這裡插入圖片描述 在虛擬機器中 brctl show 檢視橋接

brctl addbr br0 新增br0 在這裡插入圖片描述 brctl show 檢視橋接 ifconfig br0 ip 新增ip 在這裡插入圖片描述 此時未新增網絡卡還ping不通真機 在這裡插入圖片描述給br0新增網絡卡就可ping通真機了 在這裡插入圖片描述 刪除橋接 在這裡插入圖片描述 在這裡插入圖片描述