

Openwrt 跨网实现二层实验
source link: https://blog.51cto.com/u_3138583/5818530
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Openwrt 跨网实现二层实验
精选 原创由于公司项目需要跨网实现二层通信,在咨询大量的大神后他们推荐的方案是vxlan方案。于是就有了下面的实验。
网络拓扑:

网络环境:
192.168.220.254/24 | 192.168.0.92/24 | openwrt 19.07 | |
主机(R1测) | 192.168.220.224/24 | centos7.9 | |
192.168.222.254/24 | 192.168.0.136/24 | openwrt 19.07 | |
主机(R2测) | 192.168.220.8/24 | ubuntu 16.04 |
一、安装前准备:
1.安装缺失的包
由于openwrt x86版默认带的ip命令不全也没有vxlan的默认支持,因此需要安装完整的ip包和vxlan的支持包,使用ssh连接安装或者在web页面安装,安装好后重启R1、R2
命令如下:
opkg install ip-full vxlan
web安装好后


2.打开防护墙规则

3.关闭R2上的dhcp功能



二、vxlan的配置
1.R1的配置:



在脚本exit 0前插入如下内容:
ip link set vxlan100 up
ip addr add 10.1.1.2/24 dev vxlan100
route add -net 10.1.1.0/24 gw 192.168.0.92
2.R2插入如下代码:
ip link set vxlan100 up
ip addr add 10.1.1.1/24 dev vxlan100
route add -net 10.1.1.0/24 gw 192.168.0.136

重启R1和R2
3.测试vxlan是否建立成功(可选)
如果出现问题应该是rc.local中的route没有执行(经测试vxlan2端不通二层也是可以正常用的)
R1上执行:
R2上执行:
4.为了保证arp包能发给将vxlan100添加到lan口中
三、测试是否能连接192.168.220.8的主机

到此这个实验就完成了。
192.168.220.0/24中的主机可以在2个网之间相互漂移切ip地址都是192.168.220段,记录一下以备以后再次用到,也给需要这样实验的伙伴们。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK