Is it possible to block-non vpn traffic on specific device (MAC address)

Yup; it’s just a matter of a toggle. GL GUI → VPN → VPN Dashboard → VPN Client → Global Options

I’m wondering if there is a way to block all non-vpn traffic at the MAC address level or if that’s a feature that’s being looked into?

That’d be an optional policy for you to apply:

Be sure to test that your expectations are met, of course!

But if for some reason my VPN server isn’t connecting, like today, I don’t know till I check my IP in browser. (Not the best solution)

Consider splitting this off into a new thread; there’s other details to gather before troubleshooting & having this thread get muddled wouldn’t help keeping it all straight.


Are you referring to this?

Toggling this blocks all non-vpn traffic and on all devices connected to the router even if those devices are not set to use the VPN.

I have 3 devices connected to the router, 1 device has a MAC address device policy set to use the VPN. The other 2 devices are not set to use the VPN. If I toggle block all non-vpn traffic, that is a global option, it will block my 2 devices not using the VPN.

My question was is there a way to block non-vpn traffic for the 1 device that is set to use the VPN via MAC filter?

The verbiage confuses me. If you want to only have specific MACs use the VPN that is a policy. If you do not set Block Non-VPN Traffic the other MACs will continue using clearnet as they’re not whitelisted to use the VPN. The MAC for the device on the whitelist/use VPN policy should, by default, be shunting all traffic through the VPN.

Check the results of ipleak.net from ea. of your devices to confirm.

Sorry about that, let me rephrase.

I want my other devices to access the internet normally, without the VPN (clearnet). When I toggle block non-vpn traffic policy, which is a global option, the devices intended for clearnet lose internet access.

So my question is: can I configure the router so that my work devices strictly use VPN while allowing my other devices to access the internet directly without the VPN? If there’s no direct way, is there any workaround? Is there any development planned for this kind of setup?

Understood.

As is the intent of that toggle.

Put its MAC into the VPN policy to do so.

That would be the default expectation unless Block Non-VPN was toggled.

I think this is a matter of it takes longer to describe than it is to do/‘easier done than said.’

Throw the work device MAC into a VPN MAC whitelist under VPN Client → Global Policy & test all your devices via ipleak.net to confirm the results:

That doesn’t really solve my issue though. The way you are explaining how to set up my router is exactly how it’s set up.

The issue is if the VPN loses connection now that VPN MAC address whitelisted device will then fallback to using clearnet.

I want the functionality of block non-vpn traffic but at the MAC address level.

I’m totally 100% able to set my work device to use the VPN and my other devices to use clearnet.

The issue is when the VPN goes offline for whatever reasons there’s no way to block that clearnet traffic reaching the MAC address white listed device.

Toggling block non VPN traffic would kill the internet on my work device if the VPN were down, good, but I won’t be able to use my clear net devices if I did that, bad. :sweat_smile:

Now I got it: when the GL GUI → VPN → VPN Dashboard → VPN Client tunnel/link drops for whatever reason, the VPN-only policy whitelisted device’s MAC (eg: work mobile) drops back to using clearnet. Yeah, that’s a problem.

Let’s do a quick little experiment:

  • Ensure Global Options → Block Non-VPN Traffic is not enabled
  • Throw a ‘work device’ (or stand-in $device) MAC into the Based on the Client Device policy
  • Enable the GL GUI VPN Client, confirm active & operating as expected (as you do)
  • Block $device from WAN access (GL GUI → Clients → $device.MAC → Block WAN)
  • Test $device for VPN connectivity via ipleak.net (expectation: your VPN Server’s IP)
  • Disable the GL GUI VPN Client
  • Test $device for WAN connectivity via ipleak.net (expectation: blocked from clearnet)

Rational: I want to see if stock tools can do what you require. Under the hood, WAN is a different network interface (technically in this case a firewall zone forward) than WG Glient (wgclient zone/fwd).

Lemme know your results. I’d rather not get into custom firewall rules but… if we must…

  • Ensure Global Options → Block Non-VPN Traffic is not enabled

:white_check_mark: Done

  • Throw a ‘work device’ (or stand-in $device) MAC into the Based on the Client Device policy

Done

  • Enable the GL GUI VPN Client, confirm active & operating as expected (as you do)

Works as usual, I’m on the VPN address

  • Block $device from WAN access (GL GUI → Clients → $device.MAC → Block WAN)

Easy enough

  • Test $device for VPN connectivity via ipleak.net (expectation: your VPN Server’s IP)

:x: No internet, blocking WAN supersedes VPN support

  • Disable the GL GUI VPN Client

:x: Connection is blocked, blocking WAN supersedes the VPN

  • Test $device for WAN connectivity via ipleak.net (expectation: blocked from clearnet)

Well there’s no internet lol but no VPN either.
I appreciate the try, but yeah WAN block is superseding anything else.

I’m hoping they could maybe make add feature to the roadmap :raised_hands:

Dammit! It looks like we’ll have to get into some custom firewall rules then. Okay, give me a day or two. In the meantime you’re going to need to install LuCI… & we should make a backup before making any unsupported changes to your firewall. See the below link.

I’m going to need a day or two to dig up some references from the OpenWrt Wiki. It’s been longer than I care to remember since I had to resort custom firewall rules.

1 Like

Got it working! chatgpt + this thread + your direction to use custom firewall rules.
I have a working iptables rule that drops the device when wgclient fails/is offline.

iptables -I FORWARD -m mac --mac-source 66:2D:BF:64:EA:62 ! -o wgclient -j DROP

It would of been nice to see it in the GUI but hey it works now, I’m not complaining anymore!
Thanks for the help!

2 Likes

You magnificent bastard!

A heads up: the upcoming GL firmware, 4.3, is most likely going to be based on OpenWrt 22.03. Upstream switched to nftables. You may have to adapt accordingly.

1 Like

Do you toggle on this option at VPN dashboard - Global Options
image

and VPN Policy Based On The Client Device

I’ve been testing leaks these days. But I failed to reproduce the issue.
Can you help to export debug info?

Anyone know how we can do this in reverse? I would like to whitelist Mac addresses to bypass VPN and sending everything else though VPN and drop Internet if VPN fails.

At VPN dashboard:
Modify Proxy Mode to: Based on the Client Device - add Mac address to “Do Not Use VPN”
Global Options - Block Non-VPN Traffic - off

Thanks for your response. Yes, ideally that would be the solution.

Unfortunately, as discussed earlier in this thread, you are not protected if your VPN fails…

Edit: I wonder if this issue may have been fixed on Brume 2 firmware 4.5.0. I am testing with a purposefully invalid Wireguard configuration and the device does not fall back to clearnet, but rather has no connection. Not sure if this a valid or best test for this.

You can try this firmware 4.4.6.
http://download.gl-inet.com.s3.amazonaws.com/firmware/mt2500/testing/openwrt-mt2500-4.4.6-0908-1694151358.bin

4.5 is not stable it introduces a lot of changes.

I have not yet encountered any issues yet with 4.5.0. If I do roll back to 4.4.6 will I have any issues keeping my configuration?

It will report errors on muti-wan and clients page for firmware 4.5.
Not recommended to downgrade firmware with keeping configuration.

1 Like