Community discussions

MikroTik App
 
adamfcameron
just joined
Topic Author
Posts: 4
Joined: Mon Aug 14, 2023 10:46 pm

Basic Wireguard Setup

Tue Aug 15, 2023 3:20 am

Reference viewtopic.php?p=899406&sid=934b9d7f6ce5 ... 2fce93ba87

My actually goal is RoadWarrior Setup
eth1 to be my WAN
eth2 to be my Admin LAN <=== Wireguard server to access this LAN
eth3 to be my Client LAN <=== Wireguard server to access this LAN
eth 4 to be my Wifi LAN

I don't want any communications between the LANs, but all exit on the WAN
I can get LANs setup but my main goal is to create a wireguard VPN for my client LAN and Admin LAN. No matter what I try the wireguard client will connect and lose access to internet.

So I started from scratch (default conf) attempting to only setup wireguard according to the above link to see if I can get clients connected and still have internet.
When they connect I cannot even ping the gateway for wireguard server.

I have walked through so many simple tutorials but a route or something is missing.
Steps:
1) Create Wireguard Interface
2) Assign address to wireguard interface 192.168.199.1/24
3) Add Peers 192.168.199.3/32
4) Connect - Successful - No internet

I know it must be a route but nothing seems to work.

Client Example:
[Interface]
PrivateKey = uD0000000000000000000000mE=
Address = 192.168.199.10/32
DNS = 8.8.8.8

[Peer]
PublicKey = 311u000000000000000000000003kKCE=
AllowedIPs = 0.0.0.0/0
Endpoint = myserver.net:13231
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19628
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Basic Wireguard Setup

Tue Aug 15, 2023 2:07 pm

Config please!

/export file=anynameyouwish ( minus router serial number, public WANIP information, keys etc.)
 
adamfcameron
just joined
Topic Author
Posts: 4
Joined: Mon Aug 14, 2023 10:46 pm

Re: Basic Wireguard Setup

Tue Aug 15, 2023 8:41 pm

So is default config and only modifications are adding the wireguard interface, assigning ip to the wireguard interface, setting up wireguard server and adding a peer.

The results are that my client connects but I cannot ping the 192.168.199.1 of the wireguard interface or get to anything else.

Thank you for having a look.

/interface bridge
add admin-mac=00:MAC:00 auto-mac=no comment=defconf name=bridge
/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard1
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=hotspot
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=default-dhcp interface=bridge lease-time=10m name=defconf
/port
set 0 name=serial0
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=sfp1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/interface wireguard peers
add allowed-address=192.168.199.3/32 interface=wireguard1 public-key=\
"KEY"
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=\
192.168.88.0
add address=192.168.199.1/24 interface=wireguard1 network=192.168.199.0
/ip dhcp-client
add comment=defconf interface=ether1
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=\
192.168.88.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall filter
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
"defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
connection-state=established,related hw-offload=yes
add action=accept chain=forward comment=\
"defconf: accept established,related, untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
ipsec-policy=out,none out-interface-list=WAN
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 firewall filter
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=\
33434-33534 protocol=udp
add action=accept chain=input comment=\
"defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\
udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \
protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=input comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=input comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
add action=accept chain=forward comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop packets with bad src ipv6" src-address-list=bad_ipv6
add action=drop chain=forward comment=\
"defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \
hop-limit=equal:1 protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=\
500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=forward comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=forward comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
/system note
set show-at-login=no
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN

====CLIENT TUNNEL PROFILE====
[Interface]
PrivateKey = XKEYX
Address = 192.168.199.3/32
DNS = 8.8.8.8

[Peer]
PublicKey = XKEYX
AllowedIPs = 0.0.0.0/0
Endpoint = server:13231
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19628
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Basic Wireguard Setup

Tue Aug 15, 2023 11:05 pm

/interface bridge
add admin-mac=00:MAC:00 auto-mac=no comment=defconf name=bridge
/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard1
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=hotspot
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=default-dhcp interface=bridge lease-time=10m name=defconf
/port
set 0 name=serial0
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=sfp1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN

add interface=wireguard1 list=LAN
/interface wireguard peers
add allowed-address=192.168.199.3/32 interface=wireguard1 public-key=\
"KEY"
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=\
192.168.88.0
add address=192.168.199.1/24 interface=wireguard1 network=192.168.199.0
/ip dhcp-client
add comment=defconf interface=ether1
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=\
192.168.88.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall filter
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
"defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1

add action=accept chain=input dst-port=13231 protococol=udp comment="wireguard handshake"
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
connection-state=established,related hw-offload=yes
add action=accept chain=forward comment=\
"defconf: accept established,related, untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid

add action=accept chain=forward comment="internet" in-interface-list=LAN out-interface-list=WAN
add action=accept chain=forward comment="wg to LAN" in-interface=wireguard1 dst-address=192.168.88.0/.24
add action=accept drop chain=forward comment="port forwarding" connection-nat-state=dstnat { error: remove drop }
add action=drop chain=forward comment="drop all else"

/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
ipsec-policy=out,none out-interface-list=WA
/ipv6 firewall filter DISABLE IPV6 if not using it.
/system note
set show-at-login=no
/tool mac-server

set allowed-interface-list=NONE
/tool mac-server mac-winbox
set allowed-interface-list=LAN
Last edited by anav on Mon Aug 21, 2023 5:06 pm, edited 1 time in total.
 
adamfcameron
just joined
Topic Author
Posts: 4
Joined: Mon Aug 14, 2023 10:46 pm

Re: Basic Wireguard Setup

Mon Aug 21, 2023 4:53 pm

So I believe I added what you suggested but still no communications on the wireguard connection. However in my previous config I didn't have it physically connected to the WAN port, I plugged ether 1 (WAN) into my home router and it added the 192.168.0.0 network with IP of 192.168.0.18 to the address list on ether1. I couldn't ping anything but just wanted to clarify.

Address List:
D 192.168.0.18/24 192.168.0.0 ether1
192.168.88.1/24 192.168.88.0 bridge
192.168.199.1/24 192.168.199.0 wireguard1

/interface bridge
add admin-mac=MAC auto-mac=no comment=defconf name=bridge
/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard1
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=hotspot
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=default-dhcp interface=bridge lease-time=10m name=defconf
/port
set 0 name=serial0
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=sfp1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
add interface=wireguard1 list=LAN
/interface wireguard peers
add allowed-address=192.168.199.3/32 interface=wireguard1 public-key=\
"KEY="
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=\
192.168.88.0
add address=192.168.199.1/24 interface=wireguard1 network=192.168.199.0
/ip dhcp-client
add comment=defconf interface=ether1
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=\
192.168.88.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall filter
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
"defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
connection-state=established,related hw-offload=yes
add action=accept chain=forward comment=\
"defconf: accept established,related, untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
connection-state=new in-interface-list=WAN
add action=accept chain=input comment="wireguard handshake" dst-port=13231 \
protocol=udp
add action=accept chain=forward comment=internet in-interface-list=LAN \
out-interface-list=WAN
add action=accept chain=forward comment="wg to LAN" dst-address=\
192.168.88.0/24 in-interface=wireguard1
add action=drop chain=forward comment="port forwarding" connection-nat-state=\
dstnat
add action=drop chain=forward comment="drop all else"
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
ipsec-policy=out,none out-interface-list=WAN
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 firewall filter
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=\
33434-33534 protocol=udp
add action=accept chain=input comment=\
"defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\
udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \
protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=input comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=input comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
add action=accept chain=forward comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop packets with bad src ipv6" src-address-list=bad_ipv6
add action=drop chain=forward comment=\
"defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \
hop-limit=equal:1 protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=\
500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=forward comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=forward comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
/system clock
set time-zone-name=America/Halifax
/system note
set show-at-login=no
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19628
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Basic Wireguard Setup

Mon Aug 21, 2023 4:59 pm

HOLD ON,
Your router is behind another Router? Your router gets an IP address of 192.168.0.18 ???
THen you need to forward the wireguard port from the upstream router to your MT router.
Then you will have a chance at success.
Assumes your upstream router gets a reachable public IP of course.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19628
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Basic Wireguard Setup

Mon Aug 21, 2023 5:02 pm

NOT QUITE, DELETE THIS RULE its an old default, which I didnt include, you should be able to pick out why its no good based on firewall rule logic!!

add action=drop chain=forward comment=\
"defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
connection-state=new in-interface-list=WAN


my Mistake on this one
add action=accept drop chain=forward comment="port forwarding" connection-nat-state=\ {forgot to remove drop}
dstnat


Should be
add action=accept chain=forward comment="port forwarding" connection-nat-state=\
dstnat
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19628
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Basic Wireguard Setup

Thu Aug 24, 2023 5:40 pm

In any case, what makes you think you can get a wireguard connection if you get a private WANIP??
You need to forward the wireguard port on the upstream router........ to your MT.
 
adamfcameron
just joined
Topic Author
Posts: 4
Joined: Mon Aug 14, 2023 10:46 pm

Re: Basic Wireguard Setup

Thu Aug 31, 2023 3:28 pm

I am currently testing with this setup. I did have my providers router in pass through mode so the MT was the external router. Because of my failed attempt I am just testing internally until I think I have something I can test with again and will supply it with a public IP. I do have the wire guard port forwarded currently to the internal MT. I do appreciate the responses and will reconfigure it today.

Thanks
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19628
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Basic Wireguard Setup

Thu Aug 31, 2023 3:57 pm

Okay, just relooking at this, the attention to detail................

What did I say to add to the input chain???
add action=accept chain=input dst-port=13231 protococol=udp comment="wireguard handshake"

On your latest config this rule was still missing and thus wg is not possible. Add this and it will work just fine!
 
sebus46
Frequent Visitor
Frequent Visitor
Posts: 56
Joined: Sat Jun 17, 2023 4:59 pm

Re: Basic Wireguard Setup

Tue Mar 26, 2024 9:45 pm

deleted
Last edited by sebus46 on Wed Mar 27, 2024 8:36 am, edited 1 time in total.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19628
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Basic Wireguard Setup

Wed Mar 27, 2024 12:12 am

What is your point? Your post has no context as you were not in the prior discussion, if you have issues please start a new thread.
 
rarlup
just joined
Posts: 3
Joined: Wed Mar 27, 2024 7:40 am

Re: Basic Wireguard Setup

Thu Mar 28, 2024 6:49 pm

Do you by any chance have multiple WANs?
I might be way off but my plan is the same with Road Warrior VPN. I don't know much about mikrotik configs to assist you but I ran into the same issue - wireguard handshake ok, lost internet access on client and it was due to the pfsense default gateway being set to a WAN1 and NAT done on WAN2 only (WAN2 has static ip, used for incoming wireguard connections, WAN1 used for default traffic, like a IoT out, thus default)
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19628
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Basic Wireguard Setup

Thu Mar 28, 2024 7:09 pm

To fix a dual wan situation where one wants to use WAN2 (backup etc.) for wireguard then one needs to mangle a bit..

Who is online

Users browsing this forum: No registered users and 8 guests