forked from azavaxhuman/IPv6-TunnelBroker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtunnelbroker.sh
216 lines (195 loc) · 8.22 KB
/
tunnelbroker.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/bash
show_menu() {
# ANSI color codes
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
CYAN=$(tput setaf 6)
RED=$(tput setaf 1)
RESET=$(tput sgr0)
# ASCII Art for "DailyDigitalSkills"
echo -e "${GREEN}"
echo "-----------------------------------------------------------------------------"
echo " _____ _ _ _____ _ _ _ _ _____ _ _ _ _ "
echo " | __ \ (_) | | __ \(_) (_) | | |/ ____| | (_) | | "
echo " | | | | __ _ _| |_ _| | | |_ __ _ _| |_ __ _| | (___ | | ___| | |___ "
echo " | | | |/ _| | | | | | | | | |/ / | | | | | | | \| | / / | | / _|"
echo " | |__| | (_| | | | |_| | |__| | | (_| | | || (_| | |____) | <| | | \__ "
echo " |_____/ \___|_|_|\__, |_____/|_|\__, |_|\__\__,_|_|_____/|_|\_\_|_|_|___/"
echo " __/ | __/ | "
echo " |___/ |___/ "
echo -e "${RESET}"
banner TunnelBroker
echo -e "${RED}"
echo "-----------------------------------------------------------------------------"
echo "---------------------------- Set Your IPV6 with TunnelBroker ----------------"
echo "------------------------ Youtube : @DailyDigitalSkills ----------------------"
echo "--------------------------- You Can Use dds-ipv6 ----------------------------"
echo "-----------------------------------------------------------------------------"
echo -e "${RESET}"
# Display menu and prompt user for input
echo -e "${CYAN} 1. Add New Ipv6 ! ${RESET}"
echo " "
echo "${YELLOW} 2. Show System IP Addresses${RESET}"
echo " "
echo "${MAGENTA} 3. Show Routing Table${RESET}"
echo " "
echo "${BLUE} 4. Delete TunnelBroker${RESET}"
echo " "
echo "${RED} 5. Unistall${RESET}"
echo " "
echo "${RED} 6. Exit${RESET}"
echo " "
}
process_choice() {
echo " "
read -r -p "${GREEN}Please select an option: ${RESET}" choice
case $choice in
1)
read -r -p "${BLUE}Enter Tunnel Broker IPv4 Address (190.80.70.60): ${RESET}" S_IP
read -r -p "${BLUE}Enter Tunnel Broker IPv6 Address (e.g. 2001:470:1f10:e1f::1): ${RESET}" S_IPv6_with_perfix
S_IPv6="${S_IPv6_with_perfix%%/*}"
C_IPv6=$(echo "$S_IPv6" | awk -F: '{$NF = $NF + 1;} 1' OFS=:)
read -r -p "${BLUE}Enter Your Server IP Address (130.80.70.60): ${RESET}" C_IP
netplan_version=$(dpkg -s netplan.io | grep Version | awk '{print $NF}')
if [[ "${netplan_version%%-*}" > "0.103" ]]; then
network_config="
network:
version: 2
tunnels:
he-ipv6:
mode: sit
remote: ${S_IP}
local: ${C_IP}
addresses:
- \"${C_IPv6}/64\"
routes:
- to: default
via: \"${S_IPv6}\""
echo "$network_config" | sudo tee /etc/netplan/999dds-tunnel.yaml > /dev/null
sudo netplan apply
echo "${YELLOW}Netplan version is greater than or equal to${RESET}${GREEN} 0.103${RESET} "
else
network_config="
network:
version: 2
tunnels:
he-ipv6:
mode: sit
remote: ${S_IP}
local: ${C_IP}
addresses:
- \"${C_IPv6}/64\"
gateway6: ${S_IPv6}"
echo "$network_config" | sudo tee /etc/netplan/999dds-tunnel.yaml > /dev/null
sudo netplan apply
echo "${YELLOW}Netplan version is less than${RESET}${GREEN} 0.103${RESET}"
fi
echo " "
echo " "
echo "${YELLOW} Done ! Your Tunnel is Established & Your IPV6 Is :${RESET}${GREEN} ${C_IPv6}${RESET}"
echo " "
echo " "
echo " "
echo " "
read -r -p "In order for all settings to be applied, your virtual server needs to be rebooted.${YELLOW} Reboot now?${RESET} (Yes/No) (${GREEN}yes${RESET}/${RED}no${RESET}): " answer_reboot
if [ "$answer_reboot" == "yes" ]; then
sudo reboot
else
echo "OK . Whenever needed, use the ${GREEN}reboot${RESET} command for this."
echo " "
echo " "
echo " "
fi
;;
2)
echo -e "${CYAN}Showing System IP Addresses:${RESET}"
echo " "
echo " "
echo " "
echo -e "${CYAN} IPv4 Addresses:${RESET}"
echo " "
echo "-----------------------------------------------------------------"
ip -4 addr show
echo " "
echo " "
echo -e "${CYAN} IPv6 Addresses:${RESET}"
echo " "
echo "-----------------------------------------------------------------"
ip -6 addr show
;;
3)
echo -e "${MAGENTA}Showing Routing Table:${RESET}"
echo " "
echo " "
echo " "
echo -e "${CYAN} IPv4 Routing Table:${RESET}"
echo " "
echo " "
echo "-----------------------------------------------------------------"
ip route show
echo " "
echo -e "${CYAN} IPv6 Routing Table:${RESET}"
echo " "
echo " "
echo "-----------------------------------------------------------------"
ip -6 route show
;;
4)
read -r -p "Are You Sure to delete Ipv6? (${GREEN}yes${RESET}/${RED}no${RESET}): " answer_rm
if [ "$answer_rm" == "yes" ]; then
# اگر جواب yes بود، دستورات مورد نظر را اجرا کن
echo "Oh ! Ok , No problem!"
sudo rm /etc/netplan/999dds-tunnel.yaml
read -r -p "In order for all settings to be applied, your virtual server needs to be rebooted. Reboot now? (Yes/No) (${GREEN}yes${RESET}/${RED}no${RESET}): " answer_reboot_del
if [ "$answer_reboot_del" == "yes" ]; then
sudo reboot
else
echo "OK . Whenever needed, use the ${GREEN}reboot${RESET} command for this."
echo ""
fi
# اینجا دستورات مورد نظر را قرار دهید
else
echo "OK"
fi
;;
5)
read -r -p "Are You Sure to Unistall DDS-IPv6? (${GREEN}yes${RESET}/${RED}no${RESET}): " answer
if [ "$answer" == "yes" ]; then
# اگر جواب yes بود، دستورات مورد نظر را اجرا کن
echo "Oh ! Ok , No problem!"
sudo unlink /usr/local/bin/dds-ipv6
sudo rm -rf /root/dds-ipv6/
exit 0
# اینجا دستورات مورد نظر را قرار دهید
else
echo "OK"
fi
;;
6)
echo -e "${CYAN}Exiting...${RESET}"
exit 0
;;
*)
echo -e "${RED}Invalid option${RESET}"
;;
esac
}
while true; do
show_menu
process_choice
# سوال برای بازگشت به منوی اصلی
echo " "
read -r -p "${CYAN}Return to main menu? ${RESET}(${GREEN}y${RESET}/${RED}n${RESET}): " answer
case $answer in
[Yy]* )
;;
[Nn]* )
echo -e "${CYAN}Goodbye!${RESET}"
exit 0
;;
* )
echo "Please answer yes or no."
;;
esac
done