首页
视频
资源
登录
原
Linux Bridge 实现VLAN
4854
人阅读
2022/10/20 15:04
总访问:
2589813
评论:
0
收藏:
0
手机
分类:
网络
![](https://img.tnblog.net/arcimg/hb/2853cbe291c54ef1b69c344a838a3f61.png) ```bash # 查看内核 uname -r ip netns list # 如果有虚拟网卡对就删除 # ip netns delete xxx clear ``` ```bash # 加载vlan模块和必要的工具 apt-get install vlan modprobe 8021q sh -c 'grep -q 8021q /etc/modules || echo 8021q >> /etc/modules' # 创建网桥 # 如果存在可以先删除 #ifconfig br-test-vlan down #brctl delbr br-test-vlan brctl addbr br-test-vlan brctl list brctl show # 创建veth对 ip link add veth01 type veth peer name veth10 ip link add veth03 type veth peer name veth30 # 将veth对的一段添加到网桥 brctl addif br-test-vlan veth01 brctl addif br-test-vlan veth03 # 启动设备 ip link set dev br-test-vlan up ip link set dev veth01 up ip link set dev veth03 up ip link set dev veth10 up ip link set dev veth30 up # 创建网络名字空间 ip netns add ns1 ip netns add ns3 # 将设备对儿的另一端添加到两个名字空间 ip link set veth10 netns ns1 ip link set veth30 netns ns3 # 配置vlan 3001和vlan 3003 ip netns exec ns1 bash vconfig add veth10 3001 vconfig add veth10 3003 # 启动两个vlan的设备 ifconfig veth10 up ip link set veth10.3001 up ip link set veth10.3003 up # 分别在两个vlan上配置ip ip a add 172.16.30.1/24 dev veth10.3001 ip a add 172.16.30.3/24 dev veth10.3003 # 配置名称空间ns3 ip netns exec ns3 bash # 配置vlan 3001 和 vlan 3003 vconfig add veth30 3001 vconfig add veth30 3003 # 启动两个vlan的设备 ifconfig veth30 up ip link set veth30.3001 up ip link set veth30.3003 up # 分别在两个vlan上配置ip ip a add 172.16.30.21/24 dev veth30.3001 ip a add 172.16.30.22/24 dev veth30.3003 ``` tn2>测试 ![](https://img.tnblog.net/arcimg/hb/353783d56b50405b9578e8b010f24eae.png) tn2>通过抓包测试 ```bash tcpdump -i any -w vlan.cap ``` ![](https://img.tnblog.net/arcimg/hb/f4e4c888b964407bafe4ea38e627825c.png)
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}
尘叶心繁
这一世以无限游戏为使命!
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
.net后台框架
168篇
linux
17篇
linux中cve
1篇
windows中cve
0篇
资源分享
10篇
Win32
3篇
前端
28篇
传说中的c
4篇
Xamarin
9篇
docker
15篇
容器编排
101篇
grpc
4篇
Go
15篇
yaml模板
1篇
理论
2篇
更多
Sqlserver
4篇
云产品
39篇
git
3篇
Unity
1篇
考证
2篇
RabbitMq
23篇
Harbor
1篇
Ansible
8篇
Jenkins
17篇
Vue
1篇
Ids4
18篇
istio
1篇
架构
2篇
网络
7篇
windbg
4篇
AI
18篇
threejs
2篇
人物
1篇
嵌入式
2篇
python
13篇
HuggingFace
8篇
pytorch
9篇
opencv
6篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2024
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
欢迎加群
欢迎加群交流技术