Skip to content

Instantly share code, notes, and snippets.

@yradunchev
Last active April 30, 2023 13:20
Show Gist options
  • Save yradunchev/2dd505e19a5cc6fb29a390a9b13fe80a to your computer and use it in GitHub Desktop.
Save yradunchev/2dd505e19a5cc6fb29a390a9b13fe80a to your computer and use it in GitHub Desktop.
mikrotik wg vpn
/interface wireguard add listen-port=51820 mtu=1420 name=vpn
/interface wireguard peers add allowed-address=0.0.0.0/0 comment=vpn-peer endpoint-address=<replace_with_vpn_server_ip> \
endpoint-port=51820 interface=vpn persistent-keepalive=25s \
public-key="<replace_with_endpoint_public_key>"
/ip address \
add address=<replace_with_vpn_client_address> interface=vpn network=<replace_with_vpn_client_address>
/ip firewall nat \
add action=masquerade chain=srcnat out-interface=vpn
/routing table add name=wg-vpn fib
/ip firewall mangle \
add action=mark-routing chain=prerouting comment="Device based VPN" \
new-routing-mark=wg-vpn passthrough=yes src-address-list=device-based-vpn
/ip firewall address-list \
add address=192.168.88.72 list=device-based-vpn
/ip route
add check-gateway=none comment="wg-vpn mark" disabled=no distance=10 \
dst-address=0.0.0.0/0 gateway=vpn pref-src="" routing-table=wg-vpn \
scope=30 suppress-hw-offload=no target-scope=10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment