{"id":287546,"date":"2023-11-19T04:06:14","date_gmt":"2023-11-18T20:06:14","guid":{"rendered":"https:\/\/lrxjmw.cn\/lwqwqglwlxnh.html"},"modified":"2023-11-19T04:06:14","modified_gmt":"2023-11-18T20:06:14","slug":"lwqwqglwlxnh","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lwqwqglwlxnh.html","title":{"rendered":"LinuxBridge\u7f51\u6865\u7f51\u6865\u7ba1\u7406\u7f51\u7edc\u865a\u62df\u5316\u6280\u672f\u7ba1\u7406"},"content":{"rendered":"

\u4e00\u3001Linux<\/a>Bridge\u96c6\u7ebf\u5668\u7ba1\u7406<\/p>\n

\u7f51\u8def\u865a\u62df\u5316\u662f\u865a\u62df\u5316\u6280\u672f\u4e2d\u6700\u590d\u6742\u7684\u90e8\u4efd\uff0c\u4e5f\u662f\u5341\u5206\u91cd\u8981\u7684\u8d44\u6e90\u3002<\/p>\n

\u7b2c\u4e00\u8282\u4e2d\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3abr0\u7684linux-bridge\u96c6\u7ebf\u5668\uff0c\u5047\u5982\u5728\u6b64\u96c6\u7ebf\u5668\u4e0a\u65b0\u5efa\u4e00\u53f0vm\uff0c\u5982\u53f3\u56fe\uff1a<\/p>\n

VM2\u7684\u865a\u62df\u7f51\u5361vnet1\u4e5f\u8054\u63a5\u5230\u4e86br0\u4e0a\u3002\u73b0\u4ecaVM1\u548cVM2\u4e4b\u95f4\u53ef\u4ee5\u901a\u8baf\uff0c\u540c\u65f6VM1\u548cVM2\u4e5f\u90fd\u53ef\u4ee5\u4e0e\u5185\u7f51\u901a\u8baf\u3002<\/p>\n

\u67e5\u770b\u7f51\u8def\u72b6\u6001\uff1a<\/p>\n

\u7528brctlshow\u663e\u793a\u5f53\u524d\u96c6\u7ebf\u5668\u8054\u63a5\u72b6\u6001\uff1a<\/p>\n

brctl\u547d\u4ee4<\/a>\uff1a<\/p>\n

\u4e8c\u3001Vlan\u4ecb\u7ecd<\/p>\n

LAN\u8868\u793aLocalAreaNetwork\uff0c\u672c\u5730\u5c40\u57df\u7f51linux \u7f51\u5361\u865a\u62df\u5316\u547d\u4ee4<\/strong>\uff0c\u4e00\u822c\u4f7f\u7528Hub\u548cSwitch\u6765\u8054\u63a5LAN\u4e2d\u7684\u8ba1\u7b97\u673a\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u4e24\u53f0\u8ba1\u7b97\u673a\u8fde\u5165\u540c\u4e00\u4e2aHub\u6216\u5219Switch\u65f6\uff0c\u5b83\u4eec\u5c31\u5728\u540c\u4e00\u4e2aLAN\u4e2d\u3002<\/p>\n

\u4e00\u4e2aLAN\u8868\u793a\u4e00\u4e2a\u5e7f\u64ad\u57df\u3002\u5176\u6db5\u4e49\u662f\uff1aLAN\u4e2d\u7684\u6240\u6709\u6210\u5458\u5c31\u4f1a\u6536\u5230\u4efb\u610f\u4e00\u4e2a\u6210\u5458\u53d1\u51fa\u7684\u5e7f\u64ad\u5305\u3002<\/p>\n

VLAN\u8868\u793aVirtualLAN\u3002\u4e00\u4e2a\u5e26\u6709VLAN\u529f\u80fd\u7684switch\u624d\u80fd\u5c06\u81ea\u5df1\u7684\u7aef\u53e3\u754c\u5b9a\u51fa\u591a\u4e2aLAN\u3002\u8ba1\u7b97\u673a\u53d1\u51fa\u7684\u5e7f\u64ad\u5305\u53ef\u4ee5\u88ab\u540c\u4e00\u4e2aLAN\u4e2d\u5176\u4ed6\u8ba1\u7b97\u673a\u6536\u5230\uff0c\u4f46\u5750\u843d\u5176\u4ed6LAN\u7684\u8ba1\u7b97\u673a\u5219\u672a\u80fd\u6536\u5230\u3002\u7b80\u5355\u5730\u8bf4\uff0cVLAN\u5c06\u4e00\u4e2a\u4ea4\u6362\u673a\u5206\u6210\u4e86\u591a\u4e2a\u4ea4\u6362\u673a\uff0c\u9650\u5236\u4e86\u5e7f\u64ad\u7684\u8303\u56f4\uff0c\u5728\u4e8c\u5c42\u5c06\u8ba1\u7b97\u673a\u9694\u79bb\u5230\u4e0d\u540c\u7684VLAN\u4e2d\u3002<\/p>\n

\u6bd4\u65b9\u8bf4\uff0c\u6709\u4e24\u7ec4\u673a\u5668\uff0cGroupA\u548cB\uff0c\u6211\u4eec\u60f3\u914d\u7f6e\u6210GroupA\u4e2d\u7684\u673a\u5668\u53ef\u4ee5\u4e92\u76f8\u8bbf\u95ee\uff0cGroupB\u4e2d\u7684\u673a\u5668\u4e5f\u53ef\u4ee5\u4e92\u76f8\u8bbf\u95ee\uff0c\u5e76\u4e14A\u548cB\u4e2d\u7684\u673a\u5668\u96be\u4ee5\u76f8\u4e92\u8bbf\u95ee\u3002\u4e00\u79cd\u65b9\u5f0f\u662f\u4f7f\u7528\u4e24\u4e2a\u4ea4\u6362\u673a\uff0cA\u548cB\u5206\u522b\u63a5\u5230\u4e00\u4e2a\u4ea4\u6362\u673a\u3002\u53e6\u4e00\u79cd\u65b9\u5f0f\u662f\u4f7f\u7528\u4e00\u4e2a\u5e26VLAN\u529f\u80fd\u7684\u4ea4\u6362\u673a\uff0c\u5c06A\u548cB\u7684\u673a\u5668\u5206\u522b\u653e\u5728\u4e0d\u540c\u7684VLAN\u4e2d\u3002<\/p>\n

VLAN\u7684\u9694\u79bb\u662f\u4e8c\u5c42\u4e0a\u7684\u9694\u79bb\uff0cA\u548cB\u96be\u4ee5\u4e92\u76f8\u8bbf\u95ee\u6307\u7684\u662f\u4e8c\u5c42\u5e7f\u64ad\u5305(\u4f8b\u5982arp)\u96be\u4ee5\u8de8\u8d8aVLAN\u7684\u8fb9\u754c\u3002\u4f46\u5728\u4e09\u5c42\u4e0a(\u4f8b\u5982IP)\u662f\u53ef\u4ee5\u901a\u8fc7\u8def\u7531\u5668\u8ba9A\u548cB\u4e92\u901a\u7684\u3002<\/p>\n

\u73b0\u4eca\u7684\u4ea4\u6362\u673a\u51e0\u4e4e\u90fd\u662f\u652f\u6301VLAN\u7684\u3002\u4e00\u822c\u4ea4\u6362\u673a\u7684\u7aef\u53e3\u6709\u4e24\u79cd\u914d\u7f6e\u6a21\u5f0f\uff1aAccess\u548cTrunk\u3002\u5982\u53f3\u56fe<\/p>\n

Access\u53e3<\/p>\n

\u8fd9\u79cd\u7aef\u53e3\u88ab\u6253\u4e0a\u4e86VLAN\u7684\u6807\u7b7e\uff0c\u8868\u660e\u8be5\u7aef\u53e3\u5c5e\u4e8e\u90a3\u4e2aVLAN\u3002\u4e0d\u540cVLAN\u7528VLANID\u6765\u5206\u8fa8\uff0cVLANID\u7684\u8303\u56f4\u662f1-4096\u3002Access\u53e3\u90fd\u662f\u76f4\u63a5\u4e0e\u8ba1\u7b97\u673a\u7f51\u5361\u76f8\u8fde\u7684\uff0c\u8fd9\u6837\u4ece\u8be5\u7f51\u5361\u4e0b\u6765\u7684\u6570\u636e\u5305\u6d41\u5165Access\u53e3\u540e\u5c31\u88ab\u6253\u4e0a\u4e86\u6240\u5728VLAN\u7684\u6807\u7b7e\u3002Access\u53e3\u53ea\u80fd\u5c5e\u4e8e\u4e00\u4e2aVLAN\u3002<\/p>\n

Trunk\u53e3<\/p>\n

\u5047\u5b9a\u6709\u4e24\u4e2a\u4ea4\u6362\u673aA\u548cB\u3002A\u4e0a\u6709VLAN1(\u7ea2)\u3001VLAN2(\u9ec4)\u3001VLAN3(\u84dd)\uff1bB\u4e0a\u4e5f\u6709VLAN1\u30012\u30013\uff0c\u90a3\u600e\u4e48\u8ba9AB\u4e0a\u76f8\u540cVLAN\u4e4b\u95f4\u624d\u80fd\u901a\u8baf\u5462\uff1f<\/p>\n

\u529e\u6cd5\u662f\u5c06A\u548cB\u8fde\u4e0a\u53bb\uff0c\u4f46\u662f\u8054\u63a5A\u548cB\u7684\u7aef\u53e3\u8981\u5bb9\u8bb8VLAN1\u30012\u30013\u4e09\u4e2aVLAN\u7684\u6570\u636e\u90fd\u8fd8\u80fd\u901a\u8fc7\u3002\u8fd9\u6837\u7684\u7aef\u53e3\u5c31\u662fTrunk\u53e3\u4e86\u3002VLAN1,2,3\u7684\u6570\u636e\u5305\u5728\u901a\u8fc7Trunk\u53e3\u62b5\u8fbe\u5bf9\u65b9\u4ea4\u6362\u673a\u7684\u8fc7\u7a0b\u4e2d\u4e00\u76f4\u5e26\u7740\u81ea\u5df1\u7684VLAN\u6807\u7b7e\u3002<\/p>\n

\u4e09\u3001LinuxBridge\u5b9e\u73b0Vlan\u539f\u7406<\/p>\n

KVM\u865a\u62df\u5316\u73af\u5883\u4e0b\u5b9e\u73b0VLAN\u6784\u67b6\uff0c\u5982\u53f3\u56fe<\/p>\n

eth0\u662f\u5bbf\u4e3b\u673a\u4e0a\u7684\u6570\u5b66\u7f51\u5361\uff0c\u6709\u4e00\u4e2a\u547d\u540d\u4e3aeth0.10\u7684\u5b50\u8bbe\u5907\u4e0e\u4e4b\u76f8\u8fde\u3002eth0.10\u5c31\u662fVLAN\u8bbe\u5907\u4e86\uff0c\u5176VLANID\u5c31\u662fVLAN10\u3002eth0.10\u6302\u5728\u547d\u540d\u4e3abrvlan10\u7684LinuxBridge\u4e0a\uff0c\u865a\u673aVM1\u7684\u865a\u62df\u7f51\u5361vent0\u4e5f\u6302\u5728brvlan10\u4e0a\u3002<\/p>\n

\u8fd9\u6837\u7684\u914d\u7f6e\u5176\u7597\u6548\u5c31\u662f\uff1a\u5bbf\u4e3b\u673a\u7528\u8f6f\u4ef6\u5b9e\u73b0\u4e86\u4e00\u4e2a\u4ea4\u6362\u673a(\u5176\u5b9e\u662f\u865a\u62df\u7684)\uff0c\u91cc\u9762\u5b9a\u4e49\u4e86\u4e00\u4e2aVLAN10\u3002eth0.10\uff0cbrvlan10\u548cvnet0\u90fd\u5206\u522b\u63a5\u5230VLAN10\u7684Access\u53e3\u4e0a\u3002\u800ceth0\u5c31\u662f\u4e00\u4e2aTrunk\u53e3\u3002VM1\u901a\u8fc7vnet0\u53d1\u51fa\u6765\u7684\u6570\u636e\u5305\u4f1a\u88ab\u6253\u4e0aVLAN10\u7684\u6807\u7b7e\u3002<\/p>\n

eth0.10\u7684\u4f5c\u7528\u662f\uff1a\u5b9a\u4e49\u4e86VLAN10<\/p>\n

brvlan10\u7684\u4f5c\u7528\u662f\uff1aBridge\u4e0a\u7684\u5176\u4ed6\u7f51\u8def\u8bbe\u5907\u624b\u52a8\u52a0\u5165\u5230VLAN10\u4e2d<\/p>\n

\u964d\u4f4e\u4e00\u4e2aVLAN20\uff0c\u5982\u53f3\u56fe<\/p>\n

\u8fd9\u6837\u865a\u62df\u4ea4\u6362\u673a\u5c31\u6709\u4e24\u4e2aVLAN\u4e86\uff0cVM1\u548cVM2\u5206\u522b\u5c5e\u4e8eVLAN10\u548cVLAN20\u3002<\/p>\n

\u5bf9\u4e8e\u65b0\u521b\u5efa\u7684\u865a\u673a\uff0c\u53ea\u987b\u8981\u5c06\u5176\u865a\u62df\u7f51\u5361\u88c5\u5165\u76f8\u5e94\u7684Bridge\uff0c\u8fd8\u80fd\u63a7\u5236\u5176\u6240\u5c5e\u7684VLAN\u3002<\/p>\n

VLAN\u8bbe\u5907\u603b\u662f\u4ee5\u7236\u5b50\u5173\u7cfb\u51fa\u73b0\uff0c\u7236\u5b50\u8bbe\u5907\u4e4b\u95f4\u662f\u4e00\u5bf9\u591a\u7684\u5173\u7cfb\u3002\u4e00\u4e2a\u6bcd\u8bbe\u5907(eth0)\u53ef\u4ee5\u6709\u591a\u4e2a\u5b50\u8bbe\u5907(eth0.10\uff0ceth0.20\u2026\u2026)\uff0c\u800c\u4e00\u4e2a\u5b50\u8bbe\u5907\u53ea\u6709\u4e00\u4e2a\u6bcd\u8bbe\u5907\u3002<\/p>\n

\u56db\u3001LinuxBridge\u5b9e\u73b0Vlan<\/p>\n

(1)\u67e5\u770b\u6838\u5fc3\u662f\u5426\u63d0\u4f9bVLAN\u529f\u80fd\uff0c\u6267\u884c<\/p>\n

#dmesg|grep-i802<\/p>\n

\u6216\u5219\u68c0\u6d4b\/proc\/net\/vlan\u76ee\u5f55\u662f\u5426\u5b58\u5728\u3002<\/p>\n

\u5047\u5982\u6c92\u6709\u63d0\u4f9bVLAN\u529f\u80fd\uff0c\/proc\/net\/vlan\u76ee\u5f55\u662f\u4e0d\u5b58\u5728\u7684\u3002<\/p>\n

\u5047\u59828021q\u6a21\u5757\u6ca1\u6709\u8f7d\u5165\u7cfb\u7edf<\/a>\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528modprobe\u6a21\u7ec4\u547d\u4ee4\u8f7d\u5165802.1q\u6a21\u7ec4\uff0c\u4e26\u4e14\u501f\u52a9lsmod\u547d\u4ee4\u786e\u8ba4\u6a21\u7ec4\u662f\u5426\u65e9\u5df2\u8f7d\u5165\u5230\u6838\u5fc3\u5185\u3002<\/p>\n

#modprobe8021q<\/p>\n

#lsmod|grep8021q<\/p>\n

\u8bbe\u7f6e\u5f00\u673a\u8f7d\u51658021q\u6a21\u5757(\u53ef\u9009)<\/p>\n

\u5728\/etc\/sysconfig\/modules\u4e0b\u964d\u4f4e\u4e00\u4e2a8021q.modules\u6587\u4ef6\uff0c\u6587\u4ef6\u5185\u5bb9\u4e3amodprobe8021q<\/p>\n

#vi\/etc\/sysconfig\/modules\/8021q.modules<\/p>\n

modprobe8021q<\/p>\n

(2)\u5b89\u88c5\u67e5\u770b\u7528\u4e8e\u67e5\u770bVlan\u914d\u7f6e\u7684\u5de5\u5177\u2014\u2014\u2014\u2014vconfig<\/p>\n

\u63d0\u65e9\u6b66\u5668\u597dvconfig-1.9-16.el7.x86_64.rpm<\/p>\n

#rpm-ivhvconfig-1.9-16.el7.x86_64.rpm<\/p>\n

#rpm-qavconfig<\/p>\n

(3)\u521b\u5efavlan\u63d2\u53e3<\/p>\n

\u521b\u5efavlan\u63d2\u53e3\u524d\uff0c\u5728\u8bbe\u5907\u4e0a\u6dfb\u52a0\u4e00\u5757\u7f51\u5361ens34\uff0c<\/p>\n

\u7f51\u8def\u914d\u7f6e\u5982\u4e0b\u56fe\uff1a<\/p>\n

\u6ce8\u610f\uff1a<\/p>\n

\u5c06BOOTPROTO=static<\/p>\n

\u57fa\u4e8e\u7f51\u5361ens34\u6784\u5efavlan10linux \u7f51\u5361\u865a\u62df\u5316\u547d\u4ee4<\/strong>\uff0cvlan20\u63d2\u53e3\uff1aens34.10\uff0cens34.20\uff1a<\/p>\n

#vconfigaddens3410<\/p>\n

#vconfigaddens3420<\/p>\n

#cd\/etc\/sysconfig\/network-scripts\/<\/p>\n

linux \u7f51\u5361\u865a\u62df\u5316\u547d\u4ee4_linux\u865a\u62df\u673a\u7f51\u5361\u600e\u4e48\u8bbe\u7f6e_linux\u865a\u62df\u7f51\u5361mac\u5730\u5740<\/p>\n

#cpifcfg-ens34ifcfg-ens34.10--\u521b\u5efaens33.10\u63d2\u53e3\u914d\u7f6e\u6587\u4ef6<\/p>\n

\u7f16\u8f91ifcfg-ens34.10\u6587\u4ef6linux\u547d\u4ee4ls\uff0c\u964d\u4f4e\/\u66f4\u6539\u4e0b\u8fb9\u5185\u5bb9\uff1a<\/p>\n

#vimifcfg-ens34.10<\/p>\n

VLAN=yes<\/p>\n

TYPE=vlan<\/p>\n

PHYSDEV=ens34<\/p>\n

VLAN_ID=10<\/p>\n

NAME=ens34.10<\/p>\n

ONBOOT=yes<\/p>\n

ZONE=trusted<\/p>\n

DEVICE=ens34.10<\/p>\n

BRIDGE=brvlan-10<\/p>\n

#cpifcfg-ens34.10ifcfg-ens34.20<\/p>\n

\u7f16\u8f91ifcfg-ens34.20\u6587\u4ef6\uff0c\u964d\u4f4e\/\u66f4\u6539\u4e0b\u8fb9\u5185\u5bb9\uff1a<\/p>\n

#vimifcfg-ens34.20<\/p>\n

VLAN=yes<\/p>\n

TYPE=vlan<\/p>\n

PHYSDEV=ens34<\/p>\n

VLAN_ID=20<\/p>\n

NAME=ens34.20<\/p>\n

ONBOOT=yes<\/p>\n

ZONE=trusted<\/p>\n

DEVICE=ens34.20<\/p>\n

BRIDGE=brvlan-20<\/p>\n

(4)\u5206\u522b\u6784\u5efa\u96c6\u7ebf\u5668brvlan-10\uff0cbrvlan-20<\/p>\n

#brctladdbrbrvlan-10<\/p>\n

#brctladdbrbrvlan-20<\/p>\n

(5)\u7f16\u8f91\u96c6\u7ebf\u5668brvlan-10\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n

#vimifcfg-brvlan-10<\/p>\n

TYPE=bridge<\/p>\n

BOOTPROTO=static<\/p>\n

NAME=brvlan-10<\/p>\n

linux\u865a\u62df\u673a\u7f51\u5361\u600e\u4e48\u8bbe\u7f6e_linux\u865a\u62df\u7f51\u5361mac\u5730\u5740_linux \u7f51\u5361\u865a\u62df\u5316\u547d\u4ee4<\/p>\n

DEVICE=brvlan-10<\/p>\n

ONBOOT=yes<\/p>\n

\u7f16\u8f91\u96c6\u7ebf\u5668brvlan-20\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n

#vimifcfg-brvlan-20<\/p>\n

TYPE=bridge<\/p>\n

BOOTPROTO=static<\/p>\n

NAME=brvlan-20<\/p>\n

DEVICE=brvlan-20<\/p>\n

ONBOOT=yes<\/p>\n

(6)\u5c06\u96c6\u7ebf\u5668brvlan-10\u63a5\u5230\u7f51\u53e3ens34.10\uff0cbrvlan-20\u63a5\u5230\u7f51\u53e3ens34.20<\/p>\n

#brctladdifbrvlan-10ens34.10<\/p>\n

#brctladdifbrvlan-20ens34.20<\/p>\n

(7)\u91cd\u65b0\u542f\u52a8\u7f51\u8def\u670d\u52a1<\/p>\n

#systemctlrestartnetwork<\/p>\n

\u4e94\u3001Vlan\u6a21\u5f0f\u6d4b\u8bd5\u865a\u673a<\/p>\n

\u5148\u5c06NetworkManager\u670d\u52a1\u5173\u6389<\/p>\n

(1)\u5728\u5bbf\u4e3b\u673a\u4e2d\u65e9\u5df2\u63d0\u65e9\u521b\u5efa\u597d\u4e86\u865a\u673aVM1<\/p>\n

\u5728virt-manager\u4e0a\u5c06VM1\u7684\u865a\u62df\u7f51\u5361\u6302\u5230brvlan-10\u4e0a<\/p>\n

(2)\u4eceVM1\u514b\u9686\u4e00\u53f0\u865a\u673aVM2<\/p>\n

virst-clone-ovm1-nvm2-f\/var\/lib\/libvirt\/images\/vm2.qcow2<\/p>\n

(3)\u542f\u52a8VM1\u548cVM2\uff0c\u5e76\u914d\u7f6eip<\/p>\n

(4)\u67e5\u770bBridge\uff0c\u53d1\u89c9brvlan10\u65e9\u5df2\u8054\u63a5\u4e86vnet0vnet1\u8bbe\u5907\u3002<\/p>\n

\u516d\u3001\u7f51\u5361\u914d\u7f6ebond(\u7ed1\u5b9a)<\/p>\n

(1)\u7f51\u5361bond(\u7ed1\u5b9a)\uff0c\u4e5f\u53eb\u505a\u7f51\u5361\u6346\u7ed1\u3002\u5c31\u662f\u5c06\u4e24\u4e2a\u6216\u5219\u66f4\u591a\u7684\u5316\u5b66\u7f51\u5361\u7ed1\u5b9a\u6210\u4e00\u4e2a\u865a\u62df\u7f51\u5361\u3002\u7f51\u5361\u662f\u901a\u8fc7\u628a\u591a\u5f20\u7f51\u5361\u7ed1\u5b9a\u4e3a\u4e00\u4e2a\u903b\u8f91\u7f51\u5361\uff0c\u5b9e\u73b0\u672c\u5730\u7f51\u5361\u7684\u5197\u4f59\uff0c\u5e26\u5bbd\u6269\u5bb9\u548c\u8d1f\u8f7d\u5747\u8861\uff0c\u5728\u5e94\u7528\u5e03\u7f72\u4e2d\u662f\u4e00\u79cd\u5e38\u7528\u7684\u6280\u672f\u3002<\/p>\n

\u591a\u7f51\u5361\u7ed1\u5b9a\u5b9e\u9645\u4e0a\u987b\u8981\u63d0\u4f9b\u4e00\u4e2a\u989d\u5916\u7684\u8f6f\u4ef6\u7684bond\u9a71\u52a8\u7a0b\u5e8f\u5b9e\u73b0\u3002\u901a\u8fc7\u9a71\u52a8\u7a0b\u5e8f\u53ef\u4ee5\u5c06\u591a\u5757\u7f51\u5361\u5c4f\u853d\u3002\u5bf9TCP\/IP\u5408\u540c\u5c42\u53ea\u5b58\u5728\u4e00\u4e2aBond\u7f51\u5361\uff0c\u5728Bond\u7a0b\u5e8f\u4e2d\u5b9e\u73b0\u7f51\u8def\u6d41\u91cf\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u5c06\u8981\u4e00\u4e2a\u7f51\u8def\u6073\u6c42\u91cd\u5b9a\u4f4d\u5230\u4e0d\u540c\u7684\u7f51\u5361\u4e0a\uff0c\u6765\u63d0\u5347\u603b\u4f53\u7f51\u8def\u7684\u53ef\u7528\u6027\u3002<\/p>\n

(2)\u7f51\u5361\u7ed1\u5b9a\u7684\u76ee\u7684\uff1a<\/p>\n

1.\u63d0\u5347\u7f51\u5361\u7684\u541e\u5410\u91cf\u3002<\/p>\n

2.\u63d0\u9ad8\u7f51\u8def\u7684\u9ad8\u53ef\u7528\uff0c\u540c\u65f6\u4e5f\u80fd\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n

(3)\u7f51\u5361\u914d\u7f6ebond(\u7ed1\u5b9a)bond\u6a21\u5f0f\uff1a<\/p>\n

1\u3001Mode=0(balance-rr)\u8868\u793a\u8d1f\u8f7d\u5206\u62c5round-robin\uff0c\u5e73\u8861\u534f\u7a0b\u7b56\u7565\uff0c\u5177\u6709\u8d1f\u8f7d\u5e73\u8861\u548c\u5bb9\u9519\u529f\u80fd<\/p>\n

bond\u7684\u7f51\u5361MAC\u4e3a\u5f53\u524d\u6d3b\u52a8\u7684\u7f51\u5361\u7684MAC\u5730\u5740\uff0c\u987b\u8981\u4ea4\u6362\u673a\u8bbe\u7f6e\u805a\u5408\u6a21\u5f0f\uff0c\u5c06\u591a\u4e2a\u7f51\u5361\u7ed1\u5b9a\u4e3a\u4e00\u6761\u94fe\u8def\u3002<\/p>\n

2\u3001Mode=1(active-backup)\u8868\u793a\u4e3b\u5907\u6a21\u5f0f\uff0c\u5177\u6709\u5bb9\u9519\u529f\u80fd\uff0c\u53ea\u6709\u4e00\u5757\u7f51\u5361\u662factive,\u53e6\u5916\u4e00\u5757\u662f\u5907\u7684standby\uff0c\u8fd9\u65f6\u5047\u82e5\u4ea4\u6362\u673a\u914d\u7684\u662f\u6346\u7ed1\uff0c\u5c06\u4e0d\u80fd\u6b63\u5e38\u5de5\u4f5c\uff0c\u7531\u4e8e\u4ea4\u6362\u673a\u5f80\u4e24\u5757\u7f51\u5361\u5206\u5305\uff0c\u6709\u4e00\u534a\u5305\u662f\u9057\u5f03\u7684\u3002<\/p>\n

3\u3001Mode=2(balance-xor)\u8868\u793aXORHash\u8d1f\u8f7d\u5206\u62c5(\u5f02\u6216\u5e73\u8861\u7b56\u7565)\uff0c\u5177\u6709\u8d1f\u8f7d\u5e73\u8861\u548c\u5bb9\u9519\u529f\u80fd<\/p>\n

\u6bcf\u4f4dslave\u63d2\u53e3\u4f20\u8f93\u6bcf\u4f4d\u6570\u636e\u5305\u548c\u4ea4\u6362\u673a\u7684\u805a\u5408\u5f3a\u5236\u4e0d\u534f\u5546\u5f62\u5f0f\u914d\u5408\u3002(\u987b\u8981xmit_hash_policy)\u3002<\/p>\n

4\u3001Mode=3(broadcast)\u8868\u793a\u6240\u6709\u5305\u4ece\u6240\u6709interface\u53d1\u51fa\uff0c\u5e7f\u64ad\u7b56\u7565\uff0c\u5177\u6709\u5bb9\u9519\u80fd\u529b\uff0c\u8fd9\u4e2a\u4e0d\u5747\u8861\uff0c\u53ea\u6709\u5197\u4f59\u673a\u5236...\u548c\u4ea4\u6362\u673a\u7684\u805a\u5408\u5f3a\u5236\u4e0d\u534f\u5546\u5f62\u5f0f\u914d\u5408\u3002<\/p>\n

5\u3001Mode=4(802.3ad)\u8868\u793a\u652f\u6301802.3ad\u5408\u540c(IEEE802.3ad\u52a8\u6001\u94fe\u63a5\u805a\u5408)\u548c\u4ea4\u6362\u673a\u7684\u805a\u5408LACP\u65b9\u6cd5\u914d\u5408(\u987b\u8981xmit_hash_policy)\u3002<\/p>\n

6\u3001Mode=5(balance-tlb)\u9002\u914d\u5668\u4f20\u8f93\u8d1f\u8f7d\u5747\u8861\uff0c\u5e76\u884c\u53d1\u9001\uff0c\u96be\u4ee5\u5e76\u884c\u63a5\u6536\uff0c\u89e3\u51b3\u4e86\u6570\u636e\u53d1\u9001\u7684\u56f0\u5c40\u3002\u662f\u6309\u7167\u6bcf\u4f4dslave\u7684\u8d1f\u8f7d\u60c5\u51b5\u9009\u62e9slave\u8fdb\u884c\u53d1\u9001\uff0c\u63a5\u6536\u65f6\u4f7f\u7528\u5f53\u540e\u8f6e\u5230\u7684slave\u3002<\/p>\n

7\u3001Mode=6(balance-alb)\u57285\u7684tlb\u57fa\u7840\u4e0a\u964d\u4f4e\u4e86rlb\u3002\u9002\u914d\u5668\u8d1f\u8f7d\u5747\u8861\u6a21\u5f0f\u5e76\u884c\u53d1\u9001\uff0c\u5e76\u884c\u63a5\u6536\u6570\u636e\u5305\u3002<\/p>\n

5\u548c6\u4e0d\u987b\u8981\u4ea4\u6362\u673a\u7aef\u7684\u8bbe\u7f6e\uff0c\u7f51\u5361\u80fd\u624b\u52a8\u805a\u5408\u30024\u987b\u8981\u652f\u6301802.3ad\u30020\uff0c2\u548c3\u7406\u8bba\u4e0a\u987b\u8981\u9759\u6001\u805a\u5408\u65b9\u6cd5\uff0c\u4f46\u5b9e\u6d4b\u4e2d0\u53ef\u4ee5\u901a\u8fc7mac\u5730\u5740\u8bef\u5bfc\u7684\u5f62\u5f0f\u5728\u4ea4\u6362\u673a\u4e0d\u8bbe\u7f6e\u7684\u60c5\u51b5\u4e0b\u4e0d\u592a\u5747\u8861\u5730\u8fdb\u884c\u63a5\u6536\u3002<\/p>\n

\u5e38\u7528\u7684\u6709\u4e09\u79cd\uff1a<\/p>\n

mode=0\uff1a\u5e73\u8861\u8d1f\u8f7d\u6a21\u5f0f\uff0c\u6709\u624b\u52a8\u5907\u63f4\uff0c\u4f46\u987b\u8981\u201dSwitch\u201d\u652f\u63f4\u53ca\u8bbe\u5b9a\u3002<\/p>\n

mode=1\uff1a\u624b\u52a8\u5907\u63f4\u6a21\u5f0f\uff0c\u5176\u4e2d\u4e00\u6761\u7ebf\u82e5\u65ad\u7ebf\uff0c\u5176\u4ed6\u7ebf\u8def\u5c06\u4f1a\u624b\u52a8\u5907\u63f4\u3002<\/p>\n

mode=6\uff1a\u5e73\u8861\u8d1f\u8f7d\u6a21\u5f0f\uff0c\u6709\u624b\u52a8\u5907\u63f4\uff0c\u4f55\u5fc5\u201dSwitch\u201d\u652f\u63f4\u53ca\u8bbe\u5b9a\u3002<\/p>\n

(4)\u7f51\u5361\u914d\u7f6ebond(\u7ed1\u5b9a)<\/p>\n

1\u3001eth1\uff0ceth2\uff0ceth3\u90fd\u914d\u7f6e\u7ed1\u5b9a\u4e3abond0linux\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u6bd4\u5982\uff1a<\/p>\n

#catifcfg-eth1<\/p>\n

TYPE=Ethernet<\/p>\n

BOOTPROTO=none<\/p>\n

DEVICE=eth1<\/p>\n

ONBOOT=yes<\/p>\n

MASTER=bond0<\/p>\n

SLAVE=yes<\/p>\n

\u8f7d\u5165bond\u6a21\u5757\uff1a<\/p>\n

#modprobebonding<\/p>\n

2\u3001\u67e5\u770bbond0\uff0c\u5e76\u6865\u63a5\u5230br1<\/p>\n

#catifcfg-bond0<\/p>\n

DEVICE=bond0<\/p>\n

TYPE=Bond<\/p>\n

NAME=bond0<\/p>\n

BONDING_MASTER=yes<\/p>\n

BOOTPROTO=static<\/p>\n

USERCTL=no<\/p>\n

ONBOOT=yes<\/p>\n

#IPADDR=192.168.10.10<\/p>\n

#PREFIX=24<\/p>\n

#GATEWAY=192.168.10.19<\/p>\n

BONDING_OPTS=\"mode=6miimon=100\"<\/p>\n

BRIDGE=br1<\/p>\n

3\u3001\u67e5\u770b\u96c6\u7ebf\u5668br0<\/p>\n

catifcfg-br1<\/p>\n

TYPE=Bridge<\/p>\n

DEVICE=br1<\/p>\n

ONBOOT=yes<\/p>\n

IPADDR=192.168.10.1<\/p>\n

IPADDR1=192.168.20.1<\/p>\n

IPADDR2=192.168.30.1<\/p>\n

IPADDR3=192.168.40.1<\/p>\n

IPADDR4=192.168.50.1<\/p>\n

PREFIX3=24<\/p>\n

PREFIX4=24<\/p>\n

#GATEWAY=172.16.0.1<\/p>\n

#DNS1=172.16.254.251<\/p>\n

#DNS2=223.5.5.5<\/p>\n

4\u3001\u91cd\u542f\u7cfb\u7edf<\/p>\n

\u67e5\u770b\u7f51\u5361\u4fe1\u606f\uff1a<\/p>\n

#ethtoolbond0<\/p>\n

\u4e03\u3001\u7f51\u5361\u914d\u7f6ebond+vlan\u5b9e\u8df5<\/p>\n

(1)\u521b\u5efabond0\uff0c\u5e76\u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/p>\n

(2)\u5c06bond0\u6865\u63a5\u5230br1\uff0c\u5e76\u521b\u5efabr1\u914d\u7f6e\u6587\u4ef6\uff0c\u91cd\u542f\u7f51\u8def\u670d\u52a1<\/p>\n

(3)\u5728br1\u4e0a\uff0c\u521b\u5efa\u865a\u62dfvlan\u7f51\u53e3\uff1abr1.10\uff0cbr1.20\uff0c\u5e76\u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/p>\n

(4)\u521b\u5efabrvlan-10\uff0cbrvlan-10\uff0c\u5e76\u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/p>\n

(5)\u5c06\u96c6\u7ebf\u5668\u4e0e\u865a\u62dfvlan\u7f51\u53e3\u8054\u63a5<\/p>\n

brctladdifbrvlan-10br1.10<\/p>\n

brctladdifbrvlan-20br1.20<\/p>\n

(6)\u91cd\u542f\u7f51\u8def\u670d\u52a1<\/p>\n","protected":false},"excerpt":{"rendered":"

\u521b\u5efavlan\u63a5\u53e3\u524d\uff0c\u5728\u8bbe\u5907\u4e0a\u6dfb\u52a0\u4e00\u5757\u7f51\u5361ens34\uff0c\u591a\u7f51\u5361\u7ed1\u5b9a\u5b9e\u9645\u4e0a\u9700\u8981\u63d0\u4f9b\u4e00\u4e2a\u989d\u5916\u7684\u8f6f\u4ef6\u7684bond\u9a71\u52a8\u7a0b\u5e8f\u5b9e\u73b0\u3002\u901a\u8fc7\u9a71\u52a8\u7a0b\u5e8f\u53ef\u4ee5\u5c06\u591a\u5757\u7f51\u5361\u5c4f\u853d\u3002\u5bf9TCP\/IP\u534f\u8bae\u5c42\u53ea\u5b58\u5728\u4e00\u4e2aBond\u7f51\u5361\uff0c\u5728Bond\u7a0b\u5e8f\u4e2d\u5b9e\u73b0\u7f51\u7edc\u6d41\u91cf\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u5373\u5c06\u4e00\u4e2a\u7f51\u7edc\u8bf7\u6c42\u91cd\u5b9a\u4f4d\u5230\u4e0d\u540c\u7684\u7f51\u5361\u4e0a\uff0c\u6765\u63d0\u9ad8\u603b\u4f53\u7f51\u7edc\u7684\u53ef\u7528\u6027\u3002<\/p>\n","protected":false},"author":1,"featured_media":287547,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-287546","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/287546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=287546"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/287546\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/287547"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=287546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=287546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=287546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}