-
Notifications
You must be signed in to change notification settings - Fork 10
/
ripv6.sh
67 lines (61 loc) · 1.62 KB
/
ripv6.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# -----
# Name: RIPv6
# Copyright (c) 2016 Michael Schneider (scip AG)
# Date: 27-05-2016
# Version: 0.2.3
# -----
# -----
# Variables
# -----
count=0
cmd_ip="/sbin/ip"
interface="ens33"
network="2001:470:26:12b"
gateway="2001:470:26:12b::1"
sleeptime="30s"
# -----
# Generate Random Address
# Thx to Vladislav V. Prodan [https://gist.github.com/click0/939739]
# -----
GenerateAddress() {
array=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
a=${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}
b=${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}
c=${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}
d=${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}
echo $network:$a:$b:$c:$d
}
# -----
# Run IPv6-Address-Loop
# -----
while [ 0=1 ]
do
ip1=$(GenerateAddress)
echo "[+] add ip1 $ip1"
$cmd_ip -6 addr add $ip1/64 dev $interface
if [[ $count == 0 ]]; then
echo "[*] set default route"
$cmd_ip -6 route add default via $gateway dev $interface
fi
if [[ $count > 0 ]]; then
echo "[-] del ip2 $ip2"
$cmd_ip -6 addr del $ip2/64 dev $interface
fi
sleep $sleeptime
ip2=$(GenerateAddress)
echo "[+] add ip2 $ip2"
$cmd_ip -6 addr add $ip2/64 dev $interface
if [[ $count > 0 ]]; then
echo "[-] del ip3 $ip3"
$cmd_ip -6 addr del $ip3/64 dev $interface
fi
sleep $sleeptime
ip3=$(GenerateAddress)
echo "[+] add ip3 $ip3"
$cmd_ip -6 addr add $ip3/64 dev $interface
echo "[-] del ip1 $ip1"
$cmd_ip -6 addr del $ip1/64 dev $interface
((count++))
sleep $sleeptime
done