Community discussions

MikroTik App
 
tetecko
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 70
Joined: Sun Jun 11, 2006 7:44 pm

6rd working on ROS

Tue Jul 28, 2015 11:17 pm

If anyone want to have 6RD, we made a script to enable it.

This script working for ::/32 IPv6 segment and 100.0.0.0/8 IPv4 segment

what you need to do on mikrotik (you just need to set uplink/local interface and of course your IPv6 prefix, 6RD relay):
:global ipv6localinterface "PASTE YOUR LOCAL IFACE NAME HERE"
:global uplinkinterface "PASTE YOUR UPLINK IFACE NAME HERE"

:global IPv4addr [/ip address get [find interface=$uplinkinterface] address];
:global IPv4addr [:pick $IPv4addr 0 [:find $IPv4addr "/"]]
:global IPv4addr2 [:pick $IPv4addr 4 30]
:global IPv6temp [:toip6 ("1::" . $IPv4addr2)]

:global IPv4hex [:pick $IPv6temp 3 15]
:global IPv6addr [("PASTE YOUR IPv6 PREFIX FOR 6RD HERE". $IPv4hex ."00::1/64")]
:global IPv6addrLoc [("PASTE YOUR IPv6 PREFIX FOR 6RD HERE". $IPv4hex ."01::1/64")]

#6to4 interface
:global 6to4id [/interface 6to4 find where name="6rd"]
:if ($6to4id!="") do={
:global 6to4addr [/interface 6to4 get $6to4id local-address]
if ($6to4addr != $IPv4addr) do={ :log warning "Updating local-address for 6to4 tunnel '6rd' from '$6to4addr' to '$IPv4addr'."; /interface 6to4 set [find name="6rd"] local-address=$IPv4addr }
} else { :log warning "Creating 6to4 interface '6rd'. "; /interface 6to4 add !keepalive local-address=$IPv4addr mtu=1480 name="6rd" remote-address=PASTE YOUR IPv4 ADDRESS OF 6RD RELAY HERE }

#ipv6 for uplink
:global IPv6addrnumber [/ipv6 address find where comment="6rd" and interface="6rd"]
:if ($IPv6addrnumber!="") do={
:global oldip ([/ipv6 address get $IPv6addrnumber address])
if ($oldip != $IPv6addr) do={ :log warning "Updating 6rd IPv6 from '$oldip' to '$IPv6addr'."; /ipv6 address set number=$IPv6addrnumber address=$IPv6addr disabled=no }
} else {:log warning "Setting up 6rd IPv6 '$IPv6addr' to '6rd'. "; /ipv6 address add address=$IPv6addr interface="6rd" comment="6rd" advertise=no }

#ipv6 for local
:global IPv6addrnumberLocal [/ipv6 address find where comment=("6rd_local") and interface=$ipv6localinterface]
:if ($IPv6addrnumberLocal!="") do={
:global oldip ([/ipv6 address get $IPv6addrnumberLocal address])
if ($oldip != $IPv6addrLoc) do={ :log warning "Updating 6rd LOCAL IPv6 from '$oldip' to '$IPv6addrLoc'."; /ipv6 address set number=$IPv6addrnumberLocal address=$IPv6addrLoc disabled=no }
} else {:log warning "Setting up 6rd LOCAL IPv6 '$IPv6addrLoc' na '$ipv6localinterface'. "; /ipv6 address add address=$IPv6addrLoc interface=$ipv6localinterface comment="6rd_local" advertise=yes }

#ipv6 route
:global routa [/ipv6 route find where dst-address="2000::/3" and gateway="6rd"]
if ($routa="") do={ :log warning "Setting IPv6 route '2000::/3' pres '6rd'. "; /ipv6 route add distance=1 dst-address="2000::/3" gateway="6rd" }

and here is, what do you need to do on your debian machine.
To check if your kernel supports 6RD, run: $ grep 6RD /boot/config-$(uname -r)


/etc/network/interfaces

#ipv4
iface eth0 inet static
	address 100.110.0.10
	netmask 255.255.255.240
	gateway 100.110.0.2

#ipv6
iface eth0 inet6 static
	address PASTE YOUR IPv6 PREFIX FOR RELAY HERE:110::10
	netmask 64
	gateway PASTE YOUR IPv6 PREFIX FOR RELAY HERE:110::1

#6rd
auto tun6rd
iface tun6rd inet6 v4tunnel
    address PASTE YOUR IPv6 PREFIX FOR 6RD HERE:6e00:0a00::1
    netmask 32
    local 100.110.0.10
    endpoint any
    ttl 64
    up ip tunnel 6rd dev tun6rd 6rd-prefix PASTE YOUR IPv6 PREFIX FOR 6RD HERE::/32 6rd-relay_prefix 100.0.0.0/8
    up ip link set mtu 1480 dev tun6rd
 
User avatar
PeterFreeman
just joined
Posts: 21
Joined: Tue Aug 02, 2011 10:26 pm
Location: United Kingdom
Contact:

Re: 6rd working on ROS

Mon Feb 13, 2017 4:24 pm

That's great, I'll give it a try ;-)
Do you know if MikroTik are likely to implement 6RD natively into ROS?
Thanks
Pete.
www.freeclix.com
www.SimRush.com
Specialists in LTE, remotely manageable MikroTik hardware.
 
reardencode
just joined
Posts: 1
Joined: Wed Nov 20, 2019 4:31 pm

Re: 6rd working on ROS

Wed Nov 20, 2019 4:38 pm

Thanks so much for this script, very helpful!!

Here's a modified version of that script which works for CenturyLink 6rd. If anyone else is having issues with the original script, this might work for other ISPs too with corrected prefix and IPv4 border router.

I also made the script assume that the uplink interface is the first in the WAN list and the local is the first in the LAN list.
:global ipv6localinterface [/interface list member get [:pick [find list=LAN] 0] interface]
:global uplinkinterface [/interface list member get [:pick [find list=WAN] 0] interface]

:global IPv4addr [/ip address get [find interface=$uplinkinterface] address]
:global IPv4addr [:pick $IPv4addr 0 [:find $IPv4addr /]]
:global IPv6temp [:toip6 ("1::" . $IPv4addr)]

# Shift the colon
:global IPv4hex [([:pick $IPv6temp 3 5] . ":" . [:pick $IPv6temp 5 7] . [:pick $IPv6temp 8 10] . ":" . [:pick $IPv6temp 10 12])]
# Change the prefix in the following two lines to match your ISP
:global IPv6addr [("2602:00". $IPv4hex ."00::1/64")]
:global IPv6addrLoc [("2602:00". $IPv4hex ."01::1/64")]

#6to4 interface
:global 6to4id [/interface 6to4 find where name="6rd"]
:if ($6to4id!="") do={
:global 6to4addr [/interface 6to4 get $6to4id local-address]
# Change the remote-address in the following to match your ISP's 6rd gateway
if ($6to4addr != $IPv4addr) do={ :log warning "Updating local-address for 6to4 tunnel '6rd' from '$6to4addr' to '$IPv4addr'."; /interface 6to4 set [find name="6rd"] local-address=$IPv4addr }
} else { :log warning "Creating 6to4 interface '6rd'. "; /interface 6to4 add !keepalive local-address=$IPv4addr mtu=1480 name="6rd" remote-address=205.171.2.64 }

#ipv6 for uplink
:global IPv6addrnumber [/ipv6 address find where comment="6rd" and interface="6rd"]
:if ($IPv6addrnumber!="") do={
:global oldip ([/ipv6 address get $IPv6addrnumber address])
if ($oldip != $IPv6addr) do={ :log warning "Updating 6rd IPv6 from '$oldip' to '$IPv6addr'."; /ipv6 address set number=$IPv6addrnumber address=$IPv6addr disabled=no }
} else {:log warning "Setting up 6rd IPv6 '$IPv6addr' to '6rd'. "; /ipv6 address add address=$IPv6addr interface="6rd" comment="6rd" advertise=no }

#ipv6 for local
:global IPv6addrnumberLocal [/ipv6 address find where comment=("6rd_local") and interface=$ipv6localinterface]
:if ($IPv6addrnumberLocal!="") do={
:global oldip ([/ipv6 address get $IPv6addrnumberLocal address])
if ($oldip != $IPv6addrLoc) do={ :log warning "Updating 6rd LOCAL IPv6 from '$oldip' to '$IPv6addrLoc'."; /ipv6 address set number=$IPv6addrnumberLocal address=$IPv6addrLoc disabled=no }
} else {:log warning "Setting up 6rd LOCAL IPv6 '$IPv6addrLoc' na '$ipv6localinterface'. "; /ipv6 address add address=$IPv6addrLoc interface=$ipv6localinterface comment="6rd_local" advertise=yes }

#ipv6 route
:global routa [/ipv6 route find where dst-address="2000::/3" and gateway="6rd"]
if ($routa="") do={ :log warning "Setting IPv6 route '2000::/3' pres '6rd'. "; /ipv6 route add distance=1 dst-address="2000::/3" gateway="6rd" }

Who is online

Users browsing this forum: Bing [Bot], hkr327 and 146 guests