Community discussions

MikroTik App
 
saphir
just joined
Topic Author
Posts: 10
Joined: Sun May 02, 2021 2:37 pm

Setup Wireguard but NAT does not work with outgoing packet through WAN

Fri Apr 15, 2022 4:14 pm

Hello,

I've setup wireguard on my Mikrotik to pass all the traffic from my LAN to this interface and it works well.
I've used this doc : http://littlefool.de/posts/mullvad-wire ... outeros-7/
However, my NAT rules (port forwarding) are not working properly anymore. I mean, the traffic on the WAN interface (not wireguard) is incoming well, however as I've got a masquerade rule telling the whole traffic have to go through the wireguard interface, I do think something is wrong here.

Therefore, how can I "mark" the traffic that is incoming on my WAN interface and have to go out still through my WAN interface and not the wireguard one.

Hope it's clear enough! Thanks for your help.
 
msatter
Forum Guru
Forum Guru
Posts: 2912
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN  [SOLVED]

Fri Apr 15, 2022 5:02 pm

Where you mark traffic for WireGuard exclude dst-nat traffic.

add connection-nat-state=!dstnat in section 3 of the manual
/ip/firewall/mangle/add chain=prerouting in-interface=ether2 action=mark-routing new-routing-mark=mullvad passthrough=no connection-nat-state=!dstnat
 
saphir
just joined
Topic Author
Posts: 10
Joined: Sun May 02, 2021 2:37 pm

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Fri Apr 15, 2022 5:57 pm

I've tried so many "complicated" things before and your answer solves it simply. Thank you very much!
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19321
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Fri Apr 15, 2022 6:03 pm

Why is mangling required at all??
Can you explain more clearly how external traffic is entering your router (for presumably some work, lets say to reach a server on a lan subnet) is not able to then go out the same WAN in response.
How the heck does this have anything to do with traffic originating from the LAN going out the wireguard tunnel.

Nothing makes sense...

A diagram would be helpful but is it fair to assume you have a MT device at home and want to use mullvad VPN for either
one of the lan subnets behind your router, or some specific IPs on subnets behind the router FOR INTERNET TRAFFIC.

If this is the case mangling is NOT required.
There should be no interference from external users coming into the router to access servers and your use of the VPN for internet traffic.

Also is there a reason that the MT router could not also be a server (to allow you to connect to the router remotely and securely for example)?
 
msatter
Forum Guru
Forum Guru
Posts: 2912
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Fri Apr 15, 2022 8:33 pm

When you use the same ether port or/and source address then you need to split traffic again.

When you have your internal network in the same subnet as the gateway of the WG tunnel then you would not need NAT. I explained that before that the internet does not know which internal network sits behind which router.

I have a router on a stick and then I can cheat by NATting on the inner router to the WG subnet and get away with a routing rule. Works great an not needing double NAT...however the WG provider does double NAT to hide my public addres.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19321
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Fri Apr 15, 2022 10:14 pm

you answering OP or me. its his config, I want his responses so I can understand his network. your input just confuses me further.
 
msatter
Forum Guru
Forum Guru
Posts: 2912
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Fri Apr 15, 2022 11:57 pm

I know. ;-)
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19321
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Sat Apr 16, 2022 12:42 am

Diagrams please.........
 
saphir
just joined
Topic Author
Posts: 10
Joined: Sun May 02, 2021 2:37 pm

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Sat Apr 16, 2022 4:02 pm

Why is mangling required at all??
Can you explain more clearly how external traffic is entering your router (for presumably some work, lets say to reach a server on a lan subnet) is not able to then go out the same WAN in response.
How the heck does this have anything to do with traffic originating from the LAN going out the wireguard tunnel.

Nothing makes sense...

A diagram would be helpful but is it fair to assume you have a MT device at home and want to use mullvad VPN for either
one of the lan subnets behind your router, or some specific IPs on subnets behind the router FOR INTERNET TRAFFIC.

If this is the case mangling is NOT required.
There should be no interference from external users coming into the router to access servers and your use of the VPN for internet traffic.

Also is there a reason that the MT router could not also be a server (to allow you to connect to the router remotely and securely for example)?
Hello,

If I simply deactivate the mangle rule, I just cannot browse the Internet at all.
I'm not a networking expert, therefore I found this guide very helpful in my case http://littlefool.de/posts/mullvad-wire ... outeros-7/ ; I guess, the mangle rule is correlated to the routing rules added which are required to route the traffic through the Wireguard Interface as Mullvad/ProtonVPN is giving some IP address to use on the interface created previously.

If there is another way to do the same, without mangle rule, why not, in my case it's now working well. I just want to pass my Internet traffic from my LAN through a wireguard Interface. However I still want to have my server hosted on the LAN reachable from the Internet using the dedicated IP my ISP gave to me. That's it :-)

There is no need to be "rude" or anything like this. Thank you.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19321
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Sat Apr 16, 2022 7:02 pm

Hi Saphir,
Yes this can be done without mangling and the "tone" is not towards you LOL, its for msatter.....but he is used to it. :-)
Post your config
/export hide-sensitive file=anynameyouwish

Just be sure NOT to post actual public IPs or gateway IPs.

++++++++++++++++++++++++++++++++++++++++++++++++

Its quite simple actually, but to be clear do you want to pass ALL your LAN traffic to mulvad for internet access or just one subnet out of ?????
If you have just one subnet thats fine.
Also, what happens if the wireguard tunnel is not available for some reason, do you want the option of allowing your LAN users to go out the regular ISP for internet??
 
msatter
Forum Guru
Forum Guru
Posts: 2912
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Sat Apr 16, 2022 7:07 pm

Hi Saphir,
Yes this can be done without mangling and the "tone" is not towards you LOL, its for msatter.....but he is used to it. :-)
Post your config
/export hide-sensitive file=anynameyouwish

Just be sure NOT to post actual public IPs or gateway IPs.
The hars tone was not directed at me! It is your trade to be rude.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19321
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Sat Apr 16, 2022 7:12 pm

Hi Saphir,
Yes this can be done without mangling and the "tone" is not towards you LOL, its for msatter.....but he is used to it. :-)
Post your config
/export hide-sensitive file=anynameyouwish

Just be sure NOT to post actual public IPs or gateway IPs.
The hars tone was not directed at me! It is your trade to be rude.
Once again, either have something useful to assist the OP or bug off.
 
Sob
Forum Guru
Forum Guru
Posts: 9120
Joined: Mon Apr 20, 2009 9:11 pm

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Sat Apr 16, 2022 7:24 pm

Yes this can be done without mangling ...
Good luck. It's sort of useful post, right? ;)
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19321
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Sat Apr 16, 2022 9:21 pm

Absolutely! and how astute of you! Cookie for Sob. :-)
Because I am clairvoyant, I know that the OP wants to
a. have a clean config
b. have an efficient config
c. have a fast config
Conclusion, if mangling can be removed requirements of a, b, c can be met.

But since you and msatter think otherwise.
I will leave this thread, buh bye........
 
Sob
Forum Guru
Forum Guru
Posts: 9120
Joined: Mon Apr 20, 2009 9:11 pm

Re: Setup Wireguard but NAT does not work with outgoing packet through WAN

Sun Apr 17, 2022 8:36 pm

Don't give up so easily, if you invent some solution I didn't think about, you can then be extra proud of it.

Who is online

Users browsing this forum: Ahrefs [Bot], intania, jmszuch1, k6ccc and 40 guests