Open colindean opened 8 years ago
In commotiond, we just use the least significant octets of the MAC address, and then bitmask those based on whatever subnet gets handed to the IP generation function (which, even though it's 100.64.0.0/10 by default, could be anything). So we never generate an address outside of that subnet, because we start with the unique bits and then mask everything not in the subnet.
Correction. 100.64.0.0-100.127.255.255 are valid.
What Commotion does is a "modulo operation" so that the 4th segment of the MAC address is converted to fit within that range like so:
01=64, 02=65, 03=66 etc up until 39=127 Once the MAC segment=40 (64 in decimal), the IP address becomes 1 again.
Example: DC:9F:DB:39:05:A8 = 100.127.0.0 and DC:9F:DB:40:05:A8 = 100.64.0.0
This process repeats again until DC:9F:DB:FF:05:A8 which is somewhere in the 60's I believe.
Curiously, Commotion does this INCORRECTLY because it doesn't use 64 as the first converted number and only goes up to 125 as the last number. We can ignore the way they do this and do it the right way.
"Correction. 100.64.0.0-100.127.255.255 are valid."
Indeed! This outputs the list of the 4,194,304 valid addresses: # nmap -sL -n 100.64.0.0/10
nmap -sL -n 100.64.0.0/10
That’s a neat trick.
THIS is what the ranges should look like: 100.64.0.0 => DC:9F:DB:00:00:00 100.65.0.0 => DC:9F:DB:01:00:00 100.66.0.0 => DC:9F:DB:02:00:00 100.67.0.0 => DC:9F:DB:03:00:00 100.68.0.0 => DC:9F:DB:04:00:00 100.69.0.0 => DC:9F:DB:05:00:00 100.70.0.0 => DC:9F:DB:06:00:00 100.71.0.0 => DC:9F:DB:07:00:00 100.72.0.0 => DC:9F:DB:08:00:00 100.73.0.0 => DC:9F:DB:09:00:00 100.74.0.0 => DC:9F:DB:0A:00:00 100.75.0.0 => DC:9F:DB:0B:00:00 100.76.0.0 => DC:9F:DB:0C:00:00 100.77.0.0 => DC:9F:DB:0D:00:00 100.78.0.0 => DC:9F:DB:0E:00:00 100.79.0.0 => DC:9F:DB:0F:00:00 100.80.0.0 => DC:9F:DB:10:00:00 100.81.0.0 => DC:9F:DB:11:00:00 100.82.0.0 => DC:9F:DB:12:00:00 100.83.0.0 => DC:9F:DB:13:00:00 100.84.0.0 => DC:9F:DB:14:00:00 100.85.0.0 => DC:9F:DB:15:00:00 100.86.0.0 => DC:9F:DB:16:00:00 100.87.0.0 => DC:9F:DB:17:00:00 100.88.0.0 => DC:9F:DB:18:00:00 100.89.0.0 => DC:9F:DB:19:00:00 100.90.0.0 => DC:9F:DB:1A:00:00 100.91.0.0 => DC:9F:DB:1B:00:00 100.92.0.0 => DC:9F:DB:1C:00:00 100.93.0.0 => DC:9F:DB:1D:00:00 100.94.0.0 => DC:9F:DB:1E:00:00 100.95.0.0 => DC:9F:DB:1F:00:00 100.96.0.0 => DC:9F:DB:20:00:00 100.97.0.0 => DC:9F:DB:21:00:00 100.98.0.0 => DC:9F:DB:22:00:00 100.99.0.0 => DC:9F:DB:23:00:00 100.100.0.0 => DC:9F:DB:24:00:00 100.101.0.0 => DC:9F:DB:25:00:00 100.102.0.0 => DC:9F:DB:26:00:00 100.103.0.0 => DC:9F:DB:27:00:00 100.104.0.0 => DC:9F:DB:28:00:00 100.105.0.0 => DC:9F:DB:29:00:00 100.106.0.0 => DC:9F:DB:2A:00:00 100.107.0.0 => DC:9F:DB:2B:00:00 100.108.0.0 => DC:9F:DB:2C:00:00 100.109.0.0 => DC:9F:DB:2D:00:00 100.110.0.0 => DC:9F:DB:2E:00:00 100.111.0.0 => DC:9F:DB:2F:00:00 100.112.0.0 => DC:9F:DB:30:00:00 100.113.0.0 => DC:9F:DB:31:00:00 100.114.0.0 => DC:9F:DB:32:00:00 100.115.0.0 => DC:9F:DB:33:00:00 100.116.0.0 => DC:9F:DB:34:00:00 100.117.0.0 => DC:9F:DB:35:00:00 100.118.0.0 => DC:9F:DB:36:00:00 100.119.0.0 => DC:9F:DB:37:00:00 100.120.0.0 => DC:9F:DB:38:00:00 100.121.0.0 => DC:9F:DB:39:00:00 100.122.0.0 => DC:9F:DB:3A:00:00 100.123.0.0 => DC:9F:DB:3B:00:00 100.124.0.0 => DC:9F:DB:3C:00:00 100.125.0.0 => DC:9F:DB:3D:00:00 100.126.0.0 => DC:9F:DB:3E:00:00 100.127.0.0 => DC:9F:DB:3F:00:00 100.64.0.0 => DC:9F:DB:40:00:00 100.65.0.0 => DC:9F:DB:41:00:00 100.66.0.0 => DC:9F:DB:42:00:00 100.67.0.0 => DC:9F:DB:43:00:00 100.68.0.0 => DC:9F:DB:44:00:00 100.69.0.0 => DC:9F:DB:45:00:00 100.70.0.0 => DC:9F:DB:46:00:00 100.71.0.0 => DC:9F:DB:47:00:00 100.72.0.0 => DC:9F:DB:48:00:00 100.73.0.0 => DC:9F:DB:49:00:00 100.74.0.0 => DC:9F:DB:4A:00:00 100.75.0.0 => DC:9F:DB:4B:00:00 100.76.0.0 => DC:9F:DB:4C:00:00 100.77.0.0 => DC:9F:DB:4D:00:00 100.78.0.0 => DC:9F:DB:4E:00:00 100.79.0.0 => DC:9F:DB:4F:00:00 100.80.0.0 => DC:9F:DB:50:00:00 100.81.0.0 => DC:9F:DB:51:00:00 100.82.0.0 => DC:9F:DB:52:00:00 100.83.0.0 => DC:9F:DB:53:00:00 100.84.0.0 => DC:9F:DB:54:00:00 100.85.0.0 => DC:9F:DB:55:00:00 100.86.0.0 => DC:9F:DB:56:00:00 100.87.0.0 => DC:9F:DB:57:00:00 100.88.0.0 => DC:9F:DB:58:00:00 100.89.0.0 => DC:9F:DB:59:00:00 100.90.0.0 => DC:9F:DB:5A:00:00 100.91.0.0 => DC:9F:DB:5B:00:00 100.92.0.0 => DC:9F:DB:5C:00:00 100.93.0.0 => DC:9F:DB:5D:00:00 100.94.0.0 => DC:9F:DB:5E:00:00 100.95.0.0 => DC:9F:DB:5F:00:00 100.96.0.0 => DC:9F:DB:60:00:00 100.97.0.0 => DC:9F:DB:61:00:00 100.98.0.0 => DC:9F:DB:62:00:00 100.99.0.0 => DC:9F:DB:63:00:00 100.100.0.0 => DC:9F:DB:64:00:00 100.101.0.0 => DC:9F:DB:65:00:00 100.102.0.0 => DC:9F:DB:66:00:00 100.103.0.0 => DC:9F:DB:67:00:00 100.104.0.0 => DC:9F:DB:68:00:00 100.105.0.0 => DC:9F:DB:69:00:00 100.106.0.0 => DC:9F:DB:6A:00:00 100.107.0.0 => DC:9F:DB:6B:00:00 100.108.0.0 => DC:9F:DB:6C:00:00 100.109.0.0 => DC:9F:DB:6D:00:00 100.110.0.0 => DC:9F:DB:6E:00:00 100.111.0.0 => DC:9F:DB:6F:00:00 100.112.0.0 => DC:9F:DB:70:00:00 100.113.0.0 => DC:9F:DB:71:00:00 100.114.0.0 => DC:9F:DB:72:00:00 100.115.0.0 => DC:9F:DB:73:00:00 100.116.0.0 => DC:9F:DB:74:00:00 100.117.0.0 => DC:9F:DB:75:00:00 100.118.0.0 => DC:9F:DB:76:00:00 100.119.0.0 => DC:9F:DB:77:00:00 100.120.0.0 => DC:9F:DB:78:00:00 100.121.0.0 => DC:9F:DB:79:00:00 100.122.0.0 => DC:9F:DB:7A:00:00 100.123.0.0 => DC:9F:DB:7B:00:00 100.124.0.0 => DC:9F:DB:7C:00:00 100.125.0.0 => DC:9F:DB:7D:00:00 100.126.0.0 => DC:9F:DB:7E:00:00 100.127.0.0 => DC:9F:DB:7F:00:00 100.64.0.0 => DC:9F:DB:80:00:00 100.65.0.0 => DC:9F:DB:81:00:00 100.66.0.0 => DC:9F:DB:82:00:00 100.67.0.0 => DC:9F:DB:83:00:00 100.68.0.0 => DC:9F:DB:84:00:00 100.69.0.0 => DC:9F:DB:85:00:00 100.70.0.0 => DC:9F:DB:86:00:00 100.71.0.0 => DC:9F:DB:87:00:00 100.72.0.0 => DC:9F:DB:88:00:00 100.73.0.0 => DC:9F:DB:89:00:00 100.74.0.0 => DC:9F:DB:8A:00:00 100.75.0.0 => DC:9F:DB:8B:00:00 100.76.0.0 => DC:9F:DB:8C:00:00 100.77.0.0 => DC:9F:DB:8D:00:00 100.78.0.0 => DC:9F:DB:8E:00:00 100.79.0.0 => DC:9F:DB:8F:00:00 100.80.0.0 => DC:9F:DB:90:00:00 100.81.0.0 => DC:9F:DB:91:00:00 100.82.0.0 => DC:9F:DB:92:00:00 100.83.0.0 => DC:9F:DB:93:00:00 100.84.0.0 => DC:9F:DB:94:00:00 100.85.0.0 => DC:9F:DB:95:00:00 100.86.0.0 => DC:9F:DB:96:00:00 100.87.0.0 => DC:9F:DB:97:00:00 100.88.0.0 => DC:9F:DB:98:00:00 100.89.0.0 => DC:9F:DB:99:00:00 100.90.0.0 => DC:9F:DB:9A:00:00 100.91.0.0 => DC:9F:DB:9B:00:00 100.92.0.0 => DC:9F:DB:9C:00:00 100.93.0.0 => DC:9F:DB:9D:00:00 100.94.0.0 => DC:9F:DB:9E:00:00 100.95.0.0 => DC:9F:DB:9F:00:00 100.96.0.0 => DC:9F:DB:A0:00:00 100.97.0.0 => DC:9F:DB:A1:00:00 100.98.0.0 => DC:9F:DB:A2:00:00 100.99.0.0 => DC:9F:DB:A3:00:00 100.100.0.0 => DC:9F:DB:A4:00:00 100.101.0.0 => DC:9F:DB:A5:00:00 100.102.0.0 => DC:9F:DB:A6:00:00 100.103.0.0 => DC:9F:DB:A7:00:00 100.104.0.0 => DC:9F:DB:A8:00:00 100.105.0.0 => DC:9F:DB:A9:00:00 100.106.0.0 => DC:9F:DB:AA:00:00 100.107.0.0 => DC:9F:DB:AB:00:00 100.108.0.0 => DC:9F:DB:AC:00:00 100.109.0.0 => DC:9F:DB:AD:00:00 100.110.0.0 => DC:9F:DB:AE:00:00 100.111.0.0 => DC:9F:DB:AF:00:00 100.112.0.0 => DC:9F:DB:B0:00:00 100.113.0.0 => DC:9F:DB:B1:00:00 100.114.0.0 => DC:9F:DB:B2:00:00 100.115.0.0 => DC:9F:DB:B3:00:00 100.116.0.0 => DC:9F:DB:B4:00:00 100.117.0.0 => DC:9F:DB:B5:00:00 100.118.0.0 => DC:9F:DB:B6:00:00 100.119.0.0 => DC:9F:DB:B7:00:00 100.120.0.0 => DC:9F:DB:B8:00:00 100.121.0.0 => DC:9F:DB:B9:00:00 100.122.0.0 => DC:9F:DB:BA:00:00 100.123.0.0 => DC:9F:DB:BB:00:00 100.124.0.0 => DC:9F:DB:BC:00:00 100.125.0.0 => DC:9F:DB:BD:00:00 100.126.0.0 => DC:9F:DB:BE:00:00 100.127.0.0 => DC:9F:DB:BF:00:00 100.64.0.0 => DC:9F:DB:C0:00:00 100.65.0.0 => DC:9F:DB:C1:00:00 100.66.0.0 => DC:9F:DB:C2:00:00 100.67.0.0 => DC:9F:DB:C3:00:00 100.68.0.0 => DC:9F:DB:C4:00:00 100.69.0.0 => DC:9F:DB:C5:00:00 100.70.0.0 => DC:9F:DB:C6:00:00 100.71.0.0 => DC:9F:DB:C7:00:00 100.72.0.0 => DC:9F:DB:C8:00:00 100.73.0.0 => DC:9F:DB:C9:00:00 100.74.0.0 => DC:9F:DB:CA:00:00 100.75.0.0 => DC:9F:DB:CB:00:00 100.76.0.0 => DC:9F:DB:CC:00:00 100.77.0.0 => DC:9F:DB:CD:00:00 100.78.0.0 => DC:9F:DB:CE:00:00 100.79.0.0 => DC:9F:DB:CF:00:00 100.80.0.0 => DC:9F:DB:D0:00:00 100.81.0.0 => DC:9F:DB:D1:00:00 100.82.0.0 => DC:9F:DB:D2:00:00 100.83.0.0 => DC:9F:DB:D3:00:00 100.84.0.0 => DC:9F:DB:D4:00:00 100.85.0.0 => DC:9F:DB:D5:00:00 100.86.0.0 => DC:9F:DB:D6:00:00 100.87.0.0 => DC:9F:DB:D7:00:00 100.88.0.0 => DC:9F:DB:D8:00:00 100.89.0.0 => DC:9F:DB:D9:00:00 100.90.0.0 => DC:9F:DB:DA:00:00 100.91.0.0 => DC:9F:DB:DB:00:00 100.92.0.0 => DC:9F:DB:DC:00:00 100.93.0.0 => DC:9F:DB:DD:00:00 100.94.0.0 => DC:9F:DB:DE:00:00 100.95.0.0 => DC:9F:DB:DF:00:00 100.96.0.0 => DC:9F:DB:E0:00:00 100.97.0.0 => DC:9F:DB:E1:00:00 100.98.0.0 => DC:9F:DB:E2:00:00 100.99.0.0 => DC:9F:DB:E3:00:00 100.100.0.0 => DC:9F:DB:E4:00:00 100.101.0.0 => DC:9F:DB:E5:00:00 100.102.0.0 => DC:9F:DB:E6:00:00 100.103.0.0 => DC:9F:DB:E7:00:00 100.104.0.0 => DC:9F:DB:E8:00:00 100.105.0.0 => DC:9F:DB:E9:00:00 100.106.0.0 => DC:9F:DB:EA:00:00 100.107.0.0 => DC:9F:DB:EB:00:00 100.108.0.0 => DC:9F:DB:EC:00:00 100.109.0.0 => DC:9F:DB:ED:00:00 100.110.0.0 => DC:9F:DB:EE:00:00 100.111.0.0 => DC:9F:DB:EF:00:00 100.112.0.0 => DC:9F:DB:F0:00:00 100.113.0.0 => DC:9F:DB:F1:00:00 100.114.0.0 => DC:9F:DB:F2:00:00 100.115.0.0 => DC:9F:DB:F3:00:00 100.116.0.0 => DC:9F:DB:F4:00:00 100.117.0.0 => DC:9F:DB:F5:00:00 100.118.0.0 => DC:9F:DB:F6:00:00 100.119.0.0 => DC:9F:DB:F7:00:00 100.120.0.0 => DC:9F:DB:F8:00:00 100.121.0.0 => DC:9F:DB:F9:00:00 100.122.0.0 => DC:9F:DB:FA:00:00 100.123.0.0 => DC:9F:DB:FB:00:00 100.124.0.0 => DC:9F:DB:FC:00:00 100.125.0.0 => DC:9F:DB:FD:00:00 100.126.0.0 => DC:9F:DB:FE:00:00 100.127.0.0 => DC:9F:DB:FF:00:00
This is the script that @mizerydearia created for configuring openwrt to use for IP addresses. Updated by Drew from Zhrodrague
#!/bin/ash
#
# Script written for pittmesh y sagerdearia
# Updated by drewzhrodague
#
# Check for --listall, otherwise proceed
if [ "$*" = "--listall" ]; then
mac1=DC
mac2=9F
mac3=DB
mac4=00
mac5=00
mac6=00
ip1=100
ip2=64
ip3=0
ip4=0
for ip2 in `seq 0 255`;do
#((ip2s63=ip2-63))
#((ip2=ip2-63))
mac4=`echo "obase=16; $ip2" | bc`
# ((ip2=(ip2+64)%64 + 64))
# # Adjust ip 2nd octet to cycle through 64-127 four times
# if [ $ip2 -ge 256 ]; then
# ((ip2-=192))
# elif [ $ip2 -ge 192 ]; then
# ((ip2-=128))
# elif [ $ip2 -ge 128 ]; then
# ((ip2-=64))
# fi
# ip2=$((ip2 % 64 + 63))
# Pad with 0
if [ ${#mac4} -eq 1 ]; then mac4=0$mac4; fi
# for ip3 in `seq 255`;do
# mac5=`echo "obase=16; $ip3" | bc`
# # Pad with 0
# if [ ${#mac5} -eq 1 ]; then mac5=0$mac5; fi
# for ip4 in `seq 255`;do
# mac6=`echo "obase=16; $ip4" | bc`
# # Pad with 0
# if [ ${#mac6} -eq 1 ]; then mac6=0$mac6; fi
# Format IP address
ip="$ip1.$ip2.$ip3.$ip4"
# Format MAC address
mac="$mac1:$mac2:$mac3:$mac4:$mac5:$mac6"
# Pad with space
space=`printf '%*s' "$((15 - ${#ip}))"`
# Output matching IP address and MAC address
echo "$ip $space=> $mac"
# done
# done
done
exit
fi
# Proceed if not --listall
# Get # of arguments passed to this script
args=$#
# # of arguments should be 1 or 6
# 1 -> DC:9F:DB:CE:13:57 -or- DC-9F-DB-CE-13-57
# 6 -> DC 9F DB CE 13 57
if [ $args -eq 1 ]; then
# Split 1 argument into 6 separate arguments, 1 for each octet
# and pass the 6 arguments to a new instance of this script
$0 `echo $1 | tr ":-" " "`
# After the new instance completes, make sure to end this one
exit
elif [ $args -eq 6 ]; then
mac1=`echo $1|tr [a-z] [A-Z]`
mac2=`echo $2|tr [a-z] [A-Z]`
mac3=`echo $3|tr [a-z] [A-Z]`
mac4=`echo $4|tr [a-z] [A-Z]`
mac5=`echo $5|tr [a-z] [A-Z]`
mac6=`echo $6|tr [a-z] [A-Z]`
else
echo "Usage: $0 <MAC address>"
echo "Usage: $0 --listall"
echo
echo "examples:"
echo " $0 DC:9F:DB:CE:13:57"
echo " $0 DC-9F-DB-CE-13-57"
echo " $0 DC 9F DB CE 13 57"
echo " $0 dc 9f db ce 13 57"
exit
fi
# Ensure that we are working with the correct large MAC address block
# DC-9F-DB
if [ ! $mac1 = "DC" -o ! $mac2 = "9F" -o ! $mac3 = "DB" ]; then
echo "Invalid MAC address. Make sure it begins with DC:9F:DB"
exit
fi
# Convert last three hexadecimal octets to decimal values
ip1=100
ip2=`echo "ibase=16; $mac4" | bc`
ip3=`echo "ibase=16; $mac5" | bc`
ip4=`echo "ibase=16; $mac6" | bc`
# nmap -sL -n 100.64.0.0/10
# DC:9F:DB:01:01:01 - DC:9F:DB:FF:FF:FF
# 100.64.0.0 - 100.127.255.255
#((ip2+=63))
echo "$ip1.$ip2.$ip3.$ip4"
#printf "%x\n" $oct4|tr [a-z] [A-Z]
Can you put that into a preformatted block with three backticks before and after it?
On Feb 4, 2016, 15:41, at 15:41, Adam Longwill notifications@github.com wrote:
This is the script that @mizerydearia created for configuring openwrt to use for IP addresses. Updated by Drew from Zhrodrague
!/bin/ash
#
Script written for pittmesh y sagerdearia
Updated by drewzhrodague
#
Check for --listall, otherwise proceed
if [ "$*" = "--listall" ]; then mac1=DC mac2=9F mac3=DB mac4=00 mac5=00 mac6=00
ip1=100 ip2=64 ip3=0 ip4=0
for ip2 in
seq 0 255
;do((ip2s63=ip2-63))
((ip2=ip2-63))
mac4=
echo "obase=16; $ip2" | bc
((ip2=(ip2+64)%64 + 64))
Adjust ip 2nd octet to cycle through 64-127 four times
if [ $ip2 -ge 256 ]; then
((ip2-=192))
elif [ $ip2 -ge 192 ]; then
((ip2-=128))
elif [ $ip2 -ge 128 ]; then
((ip2-=64))
fi
ip2=$((ip2 % 64 + 63))
Pad with 0
if [ ${#mac4} -eq 1 ]; then mac4=0$mac4; fi
for ip3 in
seq 255
;domac5=
echo "obase=16; $ip3" | bc
Pad with 0
if [ ${#mac5} -eq 1 ]; then mac5=0$mac5; fi
for ip4 in
seq 255
;domac6=
echo "obase=16; $ip4" | bc
Pad with 0
if [ ${#mac6} -eq 1 ]; then mac6=0$mac6; fi
# Format IP address ip="$ip1.$ip2.$ip3.$ip4" # Format MAC address mac="$mac1:$mac2:$mac3:$mac4:$mac5:$mac6" # Pad with space space=`printf '%*s' "$((15 - ${#ip}))"` # Output matching IP address and MAC address echo "$ip $space=> $mac"
done
done
done exit fi
Proceed if not --listall
Get # of arguments passed to this script
args=$#
of arguments should be 1 or 6
1 -> DC:9F:DB:CE:13:57 -or- DC-9F-DB-CE-13-57
6 -> DC 9F DB CE 13 57
if [ $args -eq 1 ]; then
Split 1 argument into 6 separate arguments, 1 for each octet
and pass the 6 arguments to a new instance of this script
$0
echo $1 | tr ":-" " "
After the new instance completes, make sure to end this one
exit elif [ $args -eq 6 ]; then mac1=
echo $1|tr [a-z] [A-Z]
mac2=echo $2|tr [a-z] [A-Z]
mac3=echo $3|tr [a-z] [A-Z]
mac4=echo $4|tr [a-z] [A-Z]
mac5=echo $5|tr [a-z] [A-Z]
mac6=echo $6|tr [a-z] [A-Z]
else echo "Usage: $0" echo "Usage: $0 --listall" echo echo "examples:" echo " $0 DC:9F:DB:CE:13:57" echo " $0 DC-9F-DB-CE-13-57" echo " $0 DC 9F DB CE 13 57" echo " $0 dc 9f db ce 13 57" exit fi
Ensure that we are working with the correct large MAC address block
DC-9F-DB
if [ ! $mac1 = "DC" -o ! $mac2 = "9F" -o ! $mac3 = "DB" ]; then echo "Invalid MAC address. Make sure it begins with DC:9F:DB" exit fi
Convert last three hexadecimal octets to decimal values
ip1=100 ip2=
echo "ibase=16; $mac4" | bc
ip3=echo "ibase=16; $mac5" | bc
ip4=echo "ibase=16; $mac6" | bc
nmap -sL -n 100.64.0.0/10
DC:9F:DB:01:01:01 - DC:9F:DB:FF:FF:FF
100.64.0.0 - 100.127.255.255
((ip2+=63))
echo "$ip1.$ip2.$ip3.$ip4"
printf "%x\n" $oct4|tr [a-z] [A-Z]
Reply to this email directly or view it on GitHub: https://github.com/pittmesh/ip-calculator/issues/3#issuecomment-180038094
I tried doing that with no success. I'll try again
On Thu, Feb 4, 2016 at 5:55 PM, Colin Dean notifications@github.com wrote:
Can you put that into a preformatted block with three backticks before and after it?
On Feb 4, 2016, 15:41, at 15:41, Adam Longwill notifications@github.com wrote:
This is the script that @mizerydearia created for configuring openwrt to use for IP addresses. Updated by Drew from Zhrodrague
!/bin/ash
#
Script written for pittmesh y sagerdearia
Updated by drewzhrodague
#
Check for --listall, otherwise proceed
if [ "$*" = "--listall" ]; then mac1=DC mac2=9F mac3=DB mac4=00 mac5=00 mac6=00
ip1=100 ip2=64 ip3=0 ip4=0
for ip2 in
seq 0 255
;do((ip2s63=ip2-63))
((ip2=ip2-63))
mac4=
echo "obase=16; $ip2" | bc
((ip2=(ip2+64)%64 + 64))
Adjust ip 2nd octet to cycle through 64-127 four times
if [ $ip2 -ge 256 ]; then
((ip2-=192))
elif [ $ip2 -ge 192 ]; then
((ip2-=128))
elif [ $ip2 -ge 128 ]; then
((ip2-=64))
fi
ip2=$((ip2 % 64 + 63))
Pad with 0
if [ ${#mac4} -eq 1 ]; then mac4=0$mac4; fi
for ip3 in
seq 255
;domac5=
echo "obase=16; $ip3" | bc
Pad with 0
if [ ${#mac5} -eq 1 ]; then mac5=0$mac5; fi
for ip4 in
seq 255
;domac6=
echo "obase=16; $ip4" | bc
Pad with 0
if [ ${#mac6} -eq 1 ]; then mac6=0$mac6; fi
Format IP address
ip="$ip1.$ip2.$ip3.$ip4"
Format MAC address
mac="$mac1:$mac2:$mac3:$mac4:$mac5:$mac6"
Pad with space
space=
printf '%*s' "$((15 - ${#ip}))"
Output matching IP address and MAC address
echo "$ip $space=> $mac"
done
done
done exit fi
Proceed if not --listall
Get # of arguments passed to this script
args=$#
of arguments should be 1 or 6
1 -> DC:9F:DB:CE:13:57 -or- DC-9F-DB-CE-13-57
6 -> DC 9F DB CE 13 57
if [ $args -eq 1 ]; then
Split 1 argument into 6 separate arguments, 1 for each octet
and pass the 6 arguments to a new instance of this script
$0
echo $1 | tr ":-" " "
After the new instance completes, make sure to end this one
exit elif [ $args -eq 6 ]; then mac1=
echo $1|tr [a-z] [A-Z]
mac2=echo $2|tr [a-z] [A-Z]
mac3=echo $3|tr [a-z] [A-Z]
mac4=echo $4|tr [a-z] [A-Z]
mac5=echo $5|tr [a-z] [A-Z]
mac6=echo $6|tr [a-z] [A-Z]
else echo "Usage: $0" echo "Usage: $0 --listall" echo echo "examples:" echo " $0 DC:9F:DB:CE:13:57" echo " $0 DC-9F-DB-CE-13-57" echo " $0 DC 9F DB CE 13 57" echo " $0 dc 9f db ce 13 57" exit fi
Ensure that we are working with the correct large MAC address block
DC-9F-DB
if [ ! $mac1 = "DC" -o ! $mac2 = "9F" -o ! $mac3 = "DB" ]; then echo "Invalid MAC address. Make sure it begins with DC:9F:DB" exit fi
Convert last three hexadecimal octets to decimal values
ip1=100 ip2=
echo "ibase=16; $mac4" | bc
ip3=echo "ibase=16; $mac5" | bc
ip4=echo "ibase=16; $mac6" | bc
nmap -sL -n 100.64.0.0/10
DC:9F:DB:01:01:01 - DC:9F:DB:FF:FF:FF
100.64.0.0 - 100.127.255.255
((ip2+=63))
echo "$ip1.$ip2.$ip3.$ip4"
printf "%x\n" $oct4|tr [a-z] [A-Z]
Reply to this email directly or view it on GitHub: https://github.com/pittmesh/ip-calculator/issues/3#issuecomment-180038094
— Reply to this email directly or view it on GitHub https://github.com/pittmesh/ip-calculator/issues/3#issuecomment-180091270 .
Fixed.
pull request https://github.com/pittmesh/ip-calculator/pull/4
Note: @drewzhrodague's changes haven't been applied.
rattle
Searching at https://regauth.standards.ieee.org/standards-ra-web/pub/view.html#registries for All MAC (MA-L, MA-M, MA-S) with keyword 'Ubiquiti' (entered in filter textbox below)
In addition to mac addresses beginning with DC-9F-DB I see references to:
Assignment | Assignment Type | Company Name | Company Address |
---|---|---|---|
04-18-D6 | MA-L | Ubiquiti Networks | 91 E. Tasman Dr., San Jose California 95134 US |
00-50-C2 (B04000-B04FFF) | IAB | Ubiquiti Networks | 91 E Tasman Dr, San Jose CA 95134 US |
68-72-51 | MA-L | Ubiquiti Networks | 91 E. Tasman Dr., San Jose California 95134 US |
00-27-22 | MA-L | Ubiquiti Networks | 91 E Tasman Dr, San Jose CA 95134 US |
00-15-6D | MA-L | Ubiquiti Networks Inc. | 495 Montague Expwy., Milpitas CA 95035 US |
24-A4-3C | MA-L | Ubiquiti Networks, INC | 91 E. Tasman Dr., San Jose California 95134 US |
F0-9F-C2 | MA-L | Ubiquiti Networks, Inc. | 2580 Orchard Parkway, San Jose CA 95131 US |
44-D9-E7 | MA-L | Ubiquiti Networks, Inc. | 2580 Orchard Parkway, San Jose CA 95131 US |
80-2A-A8 | MA-L | Ubiquiti Networks, Inc. | 2580 Orchard Parkway, San Jose CA 95131 US |
DC-9F-DB | MA-L | Ubiquiti Networks, Inc. | 2580 Orchard Parkway, San Jose CA 95131 US |
Yeah. The HTML version of the calculator generates IPs for all of those ranges. Sounds like an enhancement to the Perl and Shell versions is in order.
100.64.0.0-100.127.0.0 are the valid IPs.