Community discussions

 
oreggin
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 99
Joined: Fri Oct 16, 2009 9:21 pm

Howto convert numbers from dec to hex?

Thu Jun 17, 2010 8:35 pm

Hy,

As my ISP doesn't support native IPv6 so I use 6to4 relay. To this I need to configure the following in the router where "1.2.3.4" is my current WAN IP:
/interface 6to4
add disabled=no local-address=1.2.3.4 mtu=1472 name=6to4 remote-address=192.88.99.1

/ipv6 address
add address=2002:0102:0304::1/16 advertise=no disabled=no eui-64=no interface=6to4
add address=2002:0102:0304:1234::1/64 advertise=yes disabled=no eui-64=no interface=bridge1

/ipv6 nd
add advertise-dns=yes advertise-mac-address=yes disabled=no hop-limit=unspecified interface=bridge1 managed-address-configuration=\
    no mtu=1472 other-configuration=yes ra-delay=3s ra-interval=3m-10m ra-lifetime=1h reachable-time=unspecified \
    retransmit-interval=unspecified

/ipv6 nd prefix default
set autonomous=yes preferred-lifetime=1h valid-lifetime=1d

/ipv6 route
add disabled=no distance=1 dst-address=2000::/3 gateway=6to4 scope=30 target-scope=10
As my ISP often change my WAN IP, I need log into the router and configure following lines whet IP changed:
/interface 6to4
set 0 local-address=2.3.4.5
/ipv6 address
set 0 address=2002:0203:0405::1/16
set 1 address=2002:0203:0405:1234::1/64
I tought ROS scripting is the best to do this automaticaly but I didn't find any command in wiki what convert decimal values to hexadecimal.

I made a shell script what takes me the "magic" lines from "new WAN IP" parameter:
#!/bin/sh

echo "/interface 6to4"
echo "set 0 local-address=$1"
echo "/ipv6 address"

V6PREFIX=$(printf '2002:%02x%02x:%02x%02x' $(echo $1 | tr . ' '))
echo "set 0 address=$V6PREFIX::1/16"
echo "set 1 address=$V6PREFIX:1234::1/64"
This script/solution is very popular in UNIX/Linux communities.

Is there any way to make a script in ROS to get new WAN IP and update the needed lines automaticaly, etc. every 5min?

Regards,
oreggin
 
oreggin
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 99
Joined: Fri Oct 16, 2009 9:21 pm

Re: Howto convert numbers from dec to hex?

Wed Jun 23, 2010 8:19 pm

Any comment from Mikrotik team?

Converting from decimal to hexadecimal format completely missing from scripting toolset?

Who is online

Users browsing this forum: No registered users and 21 guests