|
@@ -110,11 +110,27 @@ function enable_ipv6 {
|
110
|
110
|
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
|
111
|
111
|
}
|
112
|
112
|
|
|
113
|
+function firewall_update_external_ip {
|
|
114
|
+ ip_update_script=/usr/bin/externalipupdate
|
|
115
|
+ echo '#!/bin/bash' >> $ip_update_script
|
|
116
|
+ echo "existing_ip=\$(cat $CONFIGURATION_FILE | grep \"EXTERNAL_IPV4_ADDRESS=\" | head -n 1 | awk -F '=' '{print \$2}')'" >> $ip_update_script
|
|
117
|
+ echo "curr_ip=\$(nslookup . $EXTERNAL_IP_LOOKUP_URL | grep Address | tail -n 1 | awk -F ' ' '{print \$2}')" >> $ip_update_script
|
|
118
|
+ echo 'if [[ "$curr_ip" != "$existing_ip" ]]; then' >> $ip_update_script
|
|
119
|
+ echo " sed -i \"s|EXTERNAL_IPV4_ADDRESS=.*|EXTERNAL_IPV4_ADDRESS=\${curr_ip}|g\" $CONFIGURATION_FILE" >> $ip_update_script
|
|
120
|
+ echo " iptables -t nat -D POSTROUTING -s \${curr_ip}/24 -o ${FIREWALL_EIFACE} -j MASQUERADE" >> $ip_update_script
|
|
121
|
+ echo " iptables -t nat -A POSTROUTING -s \${curr_ip}/24 -o ${FIREWALL_EIFACE} -j MASQUERADE" >> $ip_update_script
|
|
122
|
+ echo ' iptables-save > /etc/firewall.conf' >> $ip_update_script
|
|
123
|
+ echo 'fi' >> $ip_update_script
|
|
124
|
+
|
|
125
|
+ cron_add_mins 10 $ip_update_script
|
|
126
|
+}
|
|
127
|
+
|
113
|
128
|
function firewall_disable_vpn {
|
114
|
129
|
read_config_param EXTERNAL_IPV4_ADDRESS
|
115
|
130
|
if [ ! $EXTERNAL_IPV4_ADDRESS ]; then
|
116
|
131
|
return
|
117
|
132
|
fi
|
|
133
|
+ sed -i '/externalipupdate/d' /etc/crontab
|
118
|
134
|
iptables -D INPUT -i ${FIREWALL_EIFACE} -m state --state NEW -p udp --dport 1194 -j ACCEPT
|
119
|
135
|
iptables -D INPUT -i tun+ -j ACCEPT
|
120
|
136
|
iptables -D FORWARD -i tun+ -j ACCEPT
|
|
@@ -136,6 +152,8 @@ function firewall_enable_vpn {
|
136
|
152
|
iptables -A OUTPUT -o tun+ -j ACCEPT
|
137
|
153
|
write_config_param EXTERNAL_IPV4_ADDRESS "$curr_external_ipv4_address"
|
138
|
154
|
save_firewall_settings
|
|
155
|
+
|
|
156
|
+ firewall_update_external_ip
|
139
|
157
|
}
|
140
|
158
|
|
141
|
159
|
function configure_firewall {
|