
MikroTik, Part 3: WireGuard — remote employees and VPNs between offices
🌐 Machine-translated from Russian. Show original
In this part:
WireGuard in RouterOS 7#
Starting with RouterOS 7, WireGuard is built into the system. It is a fast and simple VPN — the general principles are described in the "Small Business Infrastructure" series.
Interface on the central router#
/interface wireguard add name=wg-office listen-port=13231
/ip address add address=10.10.0.1/24 interface=wg-office
# скопируйте public-key роутера из вывода
/interface wireguard print
Port 13231/UDP must be enabled in the input chain (part 2.
Remote employee#
On a laptop or phone — the WireGuard app, keys are generated there. On the router, add a peer:
/interface wireguard peers add interface=wg-office public-key="ключ_клиента" allowed-address=10.10.0.2/32 comment="Айгерим, ноутбук"
Client configuration:
[Interface]
PrivateKey = <приватный ключ клиента>
Address = 10.10.0.2/32
DNS = 192.168.10.1
[Peer]
PublicKey = <публичный ключ роутера>
Endpoint = внешний-IP-или-домен:13231
AllowedIPs = 10.10.0.0/24, 192.168.10.0/24
PersistentKeepalive = 25
Allow VPN access to the local network in Forward (or add wg-office to the LAN list if employees need full access).
Office — office#
Office networks must not overlap: central 192.168.10.0/24, branch 192.168.20.0/24.
Center:
/interface wireguard peers add interface=wg-office public-key="ключ_филиала" allowed-address=10.10.0.10/32,192.168.20.0/24
/ip route add dst-address=192.168.20.0/24 gateway=wg-office
Branch:
/interface wireguard add name=wg-hq listen-port=13231
/ip address add address=10.10.0.10/24 interface=wg-hq
/interface wireguard peers add interface=wg-hq public-key="ключ_центра" endpoint-address=внешний-IP-центра endpoint-port=13231 allowed-address=10.10.0.0/24,192.168.10.0/24 persistent-keepalive=25s
/ip route add dst-address=192.168.10.0/24 gateway=wg-hq
Verification#
# last-handshake должен обновляться
/interface wireguard peers print detail
/ping 192.168.20.1 src-address=192.168.10.1
No handshake — check keys to see if the port on the connected side is open and if UDP is blocking the provider.
Key Management#
- One feast — one device, with a comment on whose it is.
- Upon dismissal — remove the feast on the same day.
- Keep a list of peers and their addresses in the network documentation.
Comments · 0
No comments yet.Sign in to comment, rate and see all comments.