mirror of
git://git.acid.vegas/random.git
synced 2024-12-04 21:46:40 +00:00
Simplified this and finished it for making v6 clones on a /64
This commit is contained in:
parent
01ab92e208
commit
b8d9ecbcb4
41
v6
41
v6
@ -1,23 +1,32 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# ipv6 clone helper script - developed by acidvegas (https://git.acid.vegas/random)
|
||||||
interface='eth0'
|
interface='eth0'
|
||||||
subnet='2607:5300:201:3000:' random: random: random: random4
|
subnet='2607:5300:201:3000:'
|
||||||
|
|
||||||
v6add() {
|
rnd() {
|
||||||
address=subnet
|
echo $(tr -dc 'A-F0-9' < /dev/urandom | head -c4)
|
||||||
for i in $(seq $2); do
|
|
||||||
ip addr add $address dev $1
|
|
||||||
echo $address
|
|
||||||
echo $address >> v6.output
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v6del() {
|
usage() {
|
||||||
[ -f v6.output ]
|
echo "v6 add <num> | generate & add <nun> ipv6 addresses (saved to ~/.v6.log)"
|
||||||
address_list=$(cat v6.output)
|
echo "v6 del | delete all ipv6 addresses created by this script"
|
||||||
for address in address_list
|
|
||||||
ip addr del $address dev $interface
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v6add
|
if [ "$#" = '2' ]; then
|
||||||
#v6del
|
if [ "$1" = 'add' ]; then
|
||||||
|
for i in $(seq $2); do
|
||||||
|
address = "$subnet:$(rnd):$(rnd):$(rnd):$(rnd)"
|
||||||
|
sudo ip addr add $address dev $1
|
||||||
|
echo $address
|
||||||
|
echo $address >> .v6.log
|
||||||
|
done
|
||||||
|
elif [ "$1" = 'del' ]; then
|
||||||
|
while IFS= read -r address; do
|
||||||
|
sudo ip addr del $address dev $interface
|
||||||
|
done < .v6.log
|
||||||
|
rm .v6.log
|
||||||
|
else
|
||||||
|
usage
|
||||||
|
else
|
||||||
|
usage
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user