首页 > 其他分享 >ros7+wireguard配置

ros7+wireguard配置

时间:2022-12-07 15:24:29浏览次数:45  
标签:10.1 24 配置 add wireguard wireguard1 address interface ros7

原文:

https://help.mikrotik.com/docs/display/ROS/WireGuard

Application examples

Site to Site WireGuard tunnel

Consider setup as illustrated below. Two remote office routers are connected to the internet and office workstations are behind NAT. Each office has its own local subnet, 10.1.202.0/24 for Office1 and 10.1.101.0/24 for Office2. Both remote offices need secure tunnels to local networks behind routers.

WireGuard interface configuration

First of all, WireGuard interfaces must be configured on both sites to allow automatic private and public key generation. The command is the same for both routers:

/interface/wireguard add listen-port=13231 name=wireguard1

Now when printing the interface details, both private and public keys should be visible to allow an exchange.

Any private key will never be needed on the remote side device - hence the name private.

Office1

/interface/wireguard print Flags: X - disabled; R - running  0  R name="wireguard1" mtu=1420 listen-port=13231 private-key="yKt9NJ4e5qlaSgh48WnPCDCEkDmq+VsBTt/DDEBWfEo="       public-key="u7gYAg5tkioJDcm3hyS7pm79eADKPs/ZUGON6/fF3iI="

Office2

/interface/wireguard/print Flags: X - disabled; R - running  0  R name="wireguard1" mtu=1420 listen-port=13231 private-key="KMwxqe/iXAU8Jn9dd1o5pPdHep2blGxNWm9I944/I24="       public-key="v/oIzPyFm1FPHrqhytZgsKjU7mUToQHLrW+Tb5e601M="

Peer configuration

Peer configuration defines who can use the WireGuard interface and what kind of traffic can be sent over it. To identify the remote peer, its public key must be specified together with the created WireGuard interface.

Office1

/interface/wireguard/peers add allowed-address=10.1.101.0/24 endpoint-address=192.168.80.1 endpoint-port=13231 interface=wireguard1 \ public-key="v/oIzPyFm1FPHrqhytZgsKjU7mUToQHLrW+Tb5e601M="

Office2

/interface/wireguard/peers add allowed-address=10.1.202.0/24 endpoint-address=192.168.90.1 endpoint-port=13231 interface=wireguard1 \ public-key="u7gYAg5tkioJDcm3hyS7pm79eADKPs/ZUGON6/fF3iI="

IP and routing configuration

Lastly, IP and routing information must be configured to allow traffic to be sent over the tunnel.

Office1

/ip/address add address=10.255.255.1/30 interface=wireguard1 /ip/route add dst-address=10.1.101.0/24 gateway=wireguard1

Office2

/ip/address add address=10.255.255.2/30 interface=wireguard1 /ip/route add dst-address=10.1.202.0/24 gateway=wireguard1

Firewall considerations

The default RouterOS firewall will block the tunnel from establishing properly. The traffic should be accepted in the "input" chain before any drop rules on both sites.

Office1

/ip/firewall/filter add action=accept chain=input dst-port=13231 protocol=udp src-address=192.168.80.1

Office2

/ip/firewall/filter add action=accept chain=input dst-port=13231 protocol=udp src-address=192.168.90.1

Additionally, it is possible that the "forward" chain restricts the communication between the subnets as well, so such traffic should be accepted before any drop rules as well.

Office1

/ip/firewall/filter add action=accept chain=forward dst-address=10.1.202.0/24 src-address=10.1.101.0/24 add action=accept chain=forward dst-address=10.1.101.0/24 src-address=10.1.202.0/24

Office2

/ip/firewall/filter add action=accept chain=forward dst-address=10.1.101.0/24 src-address=10.1.202.0/24 add action=accept chain=forward dst-address=10.1.202.0/24 src-address=10.1.101.0/24

标签:10.1,24,配置,add,wireguard,wireguard1,address,interface,ros7
From: https://www.cnblogs.com/itfat/p/16963145.html

相关文章

  • firewalld使用与配置
    #永久添加指定的端口策略firewall-cmd--zone=public--add-port=80/tcp--permanent#永久删除指定的端口策略firewall-cmd--zone=public--remove-port=80/tcp--pe......
  • SpringBoot pom.xml配置文件详解
    <?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:sch......
  • Docker For Windows 安装配置及常用维护
    1.简介容器技术最早是从Linux环境产生并持续发展,Windows是在新的CEO上台后才开始转向开源并拥抱Linux。容器相对虚拟化更轻量,资源占用更少。虽然Linux环境有Mono组件......
  • 微服务跨域配置
    有时候,我们需要对所有微服务跨域请求进行处理.跨域的说明:哪些场景是跨域:不同的系统进行AJAX的请求的时候属于跨域的。跨域的请求一般是不被允许的。1.www.jd.com---->www.t......
  • DataX源码分配三:配置加载
    【1】入口ConfigParser::parse   方法参数为命令行中指定的作业配置文件。 【2】配置保存方式datax使用Configuration类保存作业配置,保存方式简单粗暴。Config......
  • springmvc零配置项目开发流程
    最后更新日期:2022-12-071.概述本篇主要介绍使用springmvc零配置开发项目的过程。参考博客:《SpringMVC学习(五)——零配置实现SrpingMVC》博客内容简洁不全,其源码托......
  • 为什么Git远程仓库中要配置公钥?
    最近在使用阿里云效平台代码管理,首次使用新建仓库,使用SSH时需要配置公钥。之前也在GitHub、Gitee上配置过,每次都能正常使用,也没有思考过为什么要配置公钥。这次记录一下其......
  • centos在VMware的net配置与静态ip
    centos在VMware的net配置与静态ip关键字:vmware;CentOS7最小安装;NAT网络模式,静态IP本机操作,1.查看本机ip并记录,假如为192.168.194.2312.修改虚拟机网络配置3.保......
  • 配置redis遇到Could not resolve placeholder 'redis.maxIdle' in string value "${re
    这个错误是读取不到我们自己redis.properties文件,因为我们在配置数据库链接时已经配置过一次  “Spring容器是采用反射扫描的发现机制,通过标签的命名空间实例化实例,......
  • 各开发语言DNS缓存配置建议
    作者:翟贺龙一、背景在计算机领域,涉及性能优化动作时首先应被考虑的原则之一便是使用缓存,合理的数据缓存机制能够带来以下收益:1.缩短数据获取路径,热点数据就近缓存以便后......