Community discussions

MikroTik App
 
costel
newbie
Topic Author
Posts: 29
Joined: Sat May 05, 2012 6:05 pm

[solved] Restrict IPv6 access

Fri Dec 27, 2024 11:55 am

Hello,

What is the best way to restrict access to IPv6 clients to Mikrotik router and, obviously, Internet ?
Setup:
All LAN interfaces have ARP set to reply-only, IPv4 DHCP-Server has AddressPool set to static-only and IPV4 ARP list is populated with allowed mac addresses.
But a new, "rogue" device connected to the network get a valid IPv6 address (invalid/non-routable 169.x.y.z IPv4 address) and can access most of the Internet.
How can I prevent that, other that using IPv6 firewall MAC rules ? Not so many rules, but seems to be the slowest method.
Thank you!
Last edited by costel on Sat Dec 28, 2024 3:37 pm, edited 1 time in total.
 
User avatar
panisk0
Frequent Visitor
Frequent Visitor
Posts: 74
Joined: Sun Mar 06, 2016 10:36 pm
Location: Cracow
Contact:

Re: Restrict IPv6 access

Fri Dec 27, 2024 12:51 pm

/ipv6 firewall raw add action=drop chain=prerouting
 
costel
newbie
Topic Author
Posts: 29
Joined: Sat May 05, 2012 6:05 pm

Re: Restrict IPv6 access

Fri Dec 27, 2024 9:22 pm

I'm afraid I don't understand, that rule will block all IPv6 trafic, including for legitimate devices.
Are you suggesting rules like:
/ipv6 firewall raw
add action=accept chain=prerouting src-mac-address=x0:y0:x0:y0:x0:y0
add action=accept chain=prerouting src-mac-address=x0:y0:x0:y0:x0:y1
...
add action=drop chain=prerouting
Was thinking about rules like that:
/ipv6 firewall filter
add action=accept chain=input comment="..." src-mac-address=x0:y0:x0:y0:x0:y0
add action=accept chain=forward comment="..." src-mac-address=x0:y0:x0:y0:x0:y0

which double the rules and maintenance involved, so your solution is more elegant.
What I don't understand: why reply-only work for IPv4, but not for IPv6 ?
Is there a better approach other than IPv6 firewall rules ?

Thank you!
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 13072
Joined: Thu Mar 03, 2016 10:23 pm

Re: Restrict IPv6 access

Sat Dec 28, 2024 1:00 pm

What I don't understand: why reply-only work for IPv4, but not for IPv6 ?

Because address acquisition for IPv6 works very differently than for IPv4. For starters there's SLAAC (which is based on RAs and those are elementary for getting routing working) and networked devices assign addresses them selves. Further more, they use multiple IPv6 addresses, one permanent and others intermittently (during certain period of time). Then there's DHCPv6, ROS implementation of server until recently didn't support handing out addresses, it handled only prefixes. And not every client supports DHCPv6, e.g. Android devices only use SLAAC. And while mentioning Android devices, you're probably aware of MAC address anonymity stuff going on with most modern smart phones (they are picking up random MAC addresses unless configured not to).

So while blocking devices by MAC address might be the only way of keeping rogue devices out of your network, it's a tedious job ... due to randomizing MAC addresses it's best to white list allowed devices and block all others. But be aware that you can't secure your network if you can't control physical access to it ...
 
costel
newbie
Topic Author
Posts: 29
Joined: Sat May 05, 2012 6:05 pm

Re: Restrict IPv6 access

Sat Dec 28, 2024 2:49 pm

Yes, mobile phones are configured to use real MAC addressees, randomization is disabled.
Don't know much about SLAAC only that is not DHCP in a regular way and is stateless, does not keep evidence of who's who or who received previously a specific address (leases). Regardless, RA-SLAAC are layer 2 and should be based on MAC which is also layer 2, that's why I didn't understand.

It is all about my home devices, all under my management, under 20 devices.
Security is needed because I don't want that occasionally used devices like Raspberry Pico, ESP32, generally IoT ones, to get IPv6 and be directly exposed on Internet or to not be able to access Internet at all.
Also, on ND I disabled MAC based UID for IPv6:
/ipv6 nd set advertise-mac-address=no
Thank you for your support!
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11262
Joined: Mon Dec 04, 2017 9:19 pm

Re: Restrict IPv6 access

Sat Dec 28, 2024 3:28 pm

Simplifying SLAAC to the bare bone: the router advertises the upper 64 bits of the address, the device uses its own, slightly mangled, MAC address as the lower 64 bits, and the combination of those two makes the 128 bits of the device's own IPv6 address. So the router does not even know the address of the device in advance.

If single rules have to match on individual addresses of devices, MAC or IP, the CPU consumption is about the same regardless whether they are /bridge filter or /ipv6 firewall filter rules; what does make difference, though, is the fact that the ip(v6) firewall can be stateful so you only have to deal with individual addresses when handling the initial packet of each connection. So somewhere between the "accept established or related" rule and "drop the rest" one (which contains an exception for LAN->WAN packets in the default configuration so you have to modify it), place a bunch of action=accept src-mac-address=xx:xx:xx:xx:xx:xx rules that will let the initial packets from the "privileged devices" to initiate new connections. The "drop the rest" rule will prevent non-privileged devices from doing the same.
 
costel
newbie
Topic Author
Posts: 29
Joined: Sat May 05, 2012 6:05 pm

[solved] Re: Restrict IPv6 access

Sat Dec 28, 2024 3:37 pm

I just reading about SLAAC :) first local auto-generated address (fe80::/64), check for duplication (DAD), get the prefix from the router and construct the address via mechanism you describe.
Already wrote the rules and it is working fine.
Thank you!
 
CGGXANNX
Member Candidate
Member Candidate
Posts: 260
Joined: Thu Dec 21, 2023 6:45 pm

Re: Restrict IPv6 access

Sat Dec 28, 2024 4:29 pm

It is all about my home devices, all under my management, under 20 devices.
Security is needed because I don't want that occasionally used devices like Raspberry Pico, ESP32, generally IoT ones, to get IPv6 and be directly exposed on Internet or to not be able to access Internet at all.

Put those devices in different VLANs + give them ULA addresses + don't implement NAT = No internet access for them.