Community discussions

MikroTik App
 
User avatar
omega-00
Forum Guru
Forum Guru
Topic Author
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

(Draft) IPv6 Authentication for Hotspots

Thu Jun 10, 2010 7:34 pm

Quick start guide - prerequisite setup - updated on my blog: http://www.mikrotik-routeros.com/?p=65

Hey All,

Been slaving away on some fancy scripts to allow the use of IPv6 on RouterOS hotspots.
Please note this is an alpha release, I've confirmed it works (90% of the time) with Window 7 but have built some checks in to help it along.

I welcome any feedback/suggestions on the scripting/improvements or if you have any questions feel free to post them here.

Here's a dump of my default config for this
Note you'll need to:
1. change interface names from 'hotspot' to match your own
2. change your own hotspot user profile to include the "on login" and "on logout" scripts.

This is running on v4.10 however I DO NOT recommend using this in any production environments.
/ipv6 nd
add advertise-dns=yes advertise-mac-address=yes disabled=no hop-limit=unspecified interface=hotspot managed-address-configuration=yes mtu=unspecified other-configuration=no ra-delay=3s ra-interval=3m20s-10m ra-lifetime=30m reachable-time=1m retransmit-interval=10s

/system scheduler
add comment="Check for any new addresses" disabled=no interval=30s name=run-ipv6-auth-check on-event="/system script run ipv6-auth-check" policy=read,write start-date=jan/01/1970 start-time=00:00:00

/system script
add name=ipv6-auth-check policy=read,write,winbox source="#IPv6 authentication script for RouterOS\r\
    \n#Tested on v4.10\r\
    \n\r\
    \n:local line\r\
    \n:local maccheck\r\
    \n:local mac\r\
    \n:local ipv6\r\
    \n:local mapping\r\
    \n\r\
    \n#Loop through each ipv6 address line in the hotspot-auth list\r\
    \n#  Get the pre-stored mac address variable from the comment\r\
    \n#  If an active hotspot listing doesn't exist for this mac address:\r\
    \n#    Remove the address-list line\r\
    \n#  End of if segement\r\
    \n#End of foreach segment\r\
    \n\r\
    \n:foreach line in=[/ipv6 firewall address-list find list=\"hotspot-auth\"] do={\r\
    \n  :set maccheck [/ipv6 firewall address-list get \$line comment]\r\
    \n  :if ([/ip hotspot active find mac-address=\$maccheck] =\"\") do={\r\
    \n    /ipv6 firewall address-list remove \$line\r\
    \n  }\r\
    \n}\r\
    \n\r\
    \n#Loop through active hotspot user lines\r\
    \n#  Set mac varible to match currently selected lines mac-address value\r\
    \n#  For each listing in neighbour discovery table with the same mac address\r\
    \n#    Set ipv6 variable to match currently selected lines address value\r\
    \n#    If no listing exists in the \"hotspot-auth\" list with the same ip address:\r\
    \n#      Create a new \"hotspot-auth\" address list entry with the ipv6 address variable and comment set to the mac address\r\
    \n#    End of if segment\r\
    \n#  End of foreach segment\r\
    \n#End of foreach segment\r\
    \n\r\
    \n:foreach line in=[/ip hotspot active find] do={\r\
    \n  :set mac [/ip hotspot active get \$line mac-address]\r\
    \n  :foreach mapping in=[/ipv6 neighbor find mac-address=\$mac] do={\r\
    \n    :set ipv6 [/ipv6 neighbor get \$mapping address]\r\
    \n    if ([/ipv6 firewall address-list find list=\"hotspot-auth\" address=\"\$ipv6/128\"]= \"\") do={\r\
    \n      /ipv6 firewall address-list add address=\$ipv6 list=hotspot-auth comment=\"\$mac\"\r\
    \n    }\r\
    \n  }\r\
    \n}"

/ipv6 firewall filter
add action=accept chain=forward comment="Accept local to local connections on link-local or public address range" disabled=no in-interface=hotspot out-interface=hotspot
add action=accept chain=forward comment="Allow outbound traffic from any IPv6 address on the \"hotspot-auth\" list" disabled=no in-interface=hotspot src-address-list=hotspot-auth
add action=reject chain=forward comment="Reject traffic not in \"hotspot-auth\" list" disabled=no in-interface=hotspot

/ip hotspot user profile
set default idle-timeout=none keepalive-timeout=2m name=default on-login="/system script run ipv6-auth-check" on-logout="/system script run ipv6-auth-check" shared-users=1 status-autorefresh=1m transparent-proxy=no
Edit: fixed one of the address-lists being incorrect in this post.
 
User avatar
omega-00
Forum Guru
Forum Guru
Topic Author
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: (Draft) IPv6 Authentication for Hotspots

Mon Jun 14, 2010 9:17 pm

Updated version of the code:
/ipv6 nd
add advertise-dns=yes advertise-mac-address=yes disabled=no hop-limit=unspecified interface=hotspot managed-address-configuration=yes mtu=unspecified other-configuration=no ra-delay=3s ra-interval=3m20s-10m ra-lifetime=30m reachable-time=1m retransmit-interval=10s

/system scheduler
add comment="Check for any new addresses" disabled=no interval=30s name=run-ipv6-auth-check on-event="/system script run ipv6-auth-check" policy=read,write start-date=jan/01/1970 start-time=00:00:00

/system script
add name=ipv6-auth-check policy=ftp,read,write,winbox source="#IPv6 authentication script for RouterOS\r\
    \n#Tested on v4.10\r\
    \n#Last updated: 15/06/2010\r\
    \n\r\
    \n:local line\r\
    \n:local linecomment\r\
    \n:local maccheck\r\
    \n:local mac\r\
    \n:local username\r\
    \n:local ipv6\r\
    \n:local mapping\r\
    \n:local localcheck\r\
    \n\r\
    \n#Loop through each ipv6 address line in the hotspot-auth list\r\
    \n#  Set linecomment variable to the comment of the current line\r\
    \n#  Set maccheck variable by grabbing only the mac address from the comment\r\
    \n#  If an active hotspot listing doesn't exist for this mac address:\r\
    \n#    Remove the address-list line\r\
    \n#  End of if segement\r\
    \n#End of foreach segment\r\
    \n\r\
    \n:foreach line in=[/ipv6 firewall address-list find list=\"hotspot-auth\"] do={\r\
    \n  :set linecomment [/ipv6 firewall address-list get \$line comment]\r\
    \n  :set maccheck [:pick \$linecomment 0 17]\r\
    \n  :if ([/ip hotspot active find mac-address=\$maccheck] =\"\") do={\r\
    \n    /ipv6 firewall address-list remove \$line\r\
    \n  }\r\
    \n}\r\
    \n\r\
    \n#Loop through active hotspot user lines\r\
    \n#  Set username variable to match currently selecte lines user value\r\
    \n#  Set mac varible to match currently selected lines mac-address value\r\
    \n#  For each listing in neighbour discovery table with the same mac address\r\
    \n#    Set ipv6 variable to match currently selected lines address value\r\
    \n#\t Set localcheck variable to first 4 digits of the current IPv6 address\r\
    \n#    If localcheck doesn't = \"fe80\" then do the following\r\
    \n#      If no listing exists in the \"hotspot-auth\" list with the same ip address:\r\
    \n#        Create a new \"hotspot-auth\" address list entry with the ipv6 address variable and comment set to the mac address and username\r\
    \n#      End of if segment\r\
    \n#    End of if segment\r\
    \n#  End of foreach segment\r\
    \n#End of foreach segment\r\
    \n\r\
    \n:foreach line in=[/ip hotspot active find] do={\r\
    \n  :set username [/ip hotspot active get \$line user]\r\
    \n  :set mac [/ip hotspot active get \$line mac-address]\r\
    \n  :foreach mapping in=[/ipv6 neighbor find mac-address=\$mac] do={\r\
    \n    :set ipv6 [/ipv6 neighbor get \$mapping address]\r\
    \n    :set localcheck [:pick \$ipv6 0 4]\r\
    \n    if (\$localcheck != \"fe80\") do={\r\
    \n      if ([/ipv6 firewall address-list find list=\"hotspot-auth\" address=\"\$ipv6/128\"]= \"\") do={\r\
    \n        /ipv6 firewall address-list add address=\$ipv6 list=hotspot-auth comment=\"\$mac \$username\"\r\
    \n      }\r\
    \n    }\r\
    \n  }\r\
    \n}"

/ipv6 firewall filter
add action=accept chain=forward comment="Accept local to local connections on link-local or public address range" disabled=no in-interface=hotspot out-interface=hotspot
add action=accept chain=forward comment="Allow outbound traffic from any IPv6 address on the \"hotspot-auth\" list" disabled=no in-interface=hotspot src-address-list=hotspot-auth
add action=reject chain=forward comment="Reject traffic not in \"active-hosts\" list" disabled=no in-interface=hotspot

/ip hotspot user profile
set default idle-timeout=none keepalive-timeout=2m name=default on-login="/system script run ipv6-auth-check" on-logout="/system script run ipv6-auth-check" shared-users=1 status-autorefresh=1m transparent-proxy=no
 
User avatar
arturportella
newbie
Posts: 46
Joined: Wed Oct 30, 2013 3:16 pm

Re: (Draft) IPv6 Authentication for Hotspots

Mon Mar 28, 2016 3:59 pm

Amazing tutorial!

But I'm facing some issues. As I have a Radius server giving all my customers the correct access-list with blocked connections (blocked-access) and etc, how can I use this script to work on? I can't use "address list" on User profile because this can suppress my Radius-server address lists control. How can I block customers in "hs-unauth" chains from ipv4 to ipv6? Or any other method that bypass the use of address list. That's great, but my customers are now using free ipv6 transit over my network without any kind of bandwidth limitation. I wonder there is a way of limiting access by MAC address or something after authentication...

Regards,
 
User avatar
omega-00
Forum Guru
Forum Guru
Topic Author
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: (Draft) IPv6 Authentication for Hotspots

Tue Mar 29, 2016 4:43 am

This was largely broken by the advent of anonymised link-local addresses as there's no way to determine who an IPv6 client is based on their IPv4 address or MAC.

The best suggestion for now would be to block all hotspot user access to v6 (and don't announce it) until there is a working working IPv6 hotspot gateway available.
 
User avatar
arturportella
newbie
Posts: 46
Joined: Wed Oct 30, 2013 3:16 pm

Re: (Draft) IPv6 Authentication for Hotspots

Tue Mar 29, 2016 3:04 pm

Awww, that's sad. Well, by the way, your tutorial works very well for it's purpose. Let's wait for some update in this scenario. I guess that on Hotspot (dual stacked customers) this is a very important thing to work on. I will grab my popcorn here and wait hahaha.. Thanks a lot!
 
abdrzjsy
just joined
Posts: 7
Joined: Sun Mar 11, 2018 11:30 pm
Location: Turkey
Contact:

Re: (Draft) IPv6 Authentication for Hotspots

Fri Jan 19, 2024 9:16 pm

MikroTik IPv6 Hotspot 8) DNS64 & NAT64
https://youtu.be/QhL4Io3rh3Y?si=I2hSP85LNJsqKNli

Who is online

Users browsing this forum: drpioneer, erkexzcx, jakabasej9 and 67 guests