Browse Source

Enable or disable ping

Bob Mottram 9 years ago
parent
commit
f8bd657549
1 changed files with 53 additions and 27 deletions
  1. 53
    27
      src/freedombone-controlpanel

+ 53
- 27
src/freedombone-controlpanel View File

@@ -687,6 +687,30 @@ function restore_data_remote {
687 687
     esac
688 688
 }
689 689
 
690
+function ping_enable_disable {
691
+    ping_str=$"\nDo you want to enable other systems to ping this machine?\n\nPing may be useful for diagnostic purposes, but for added security you may not want to enable it."
692
+    enable_ping="no"
693
+    dialog --title $"Enable Ping / ICMP" \
694
+           --backtitle $"Freedombone Control Panel" \
695
+           --defaultno \
696
+           --yesno "$ping_str" 10 60
697
+    sel=$?
698
+    case $sel in
699
+        0) enable_ping="yes";;
700
+        255) return;;
701
+    esac
702
+
703
+    if [[ $enable_ping == "yes" ]]; then
704
+        iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
705
+        iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
706
+        echo "0" >  /proc/sys/net/ipv4/icmp_echo_ignore_all
707
+    else
708
+        iptables -D INPUT -p icmp --icmp-type echo-request -j ACCEPT
709
+        iptables -D OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
710
+        echo "1" >  /proc/sys/net/ipv4/icmp_echo_ignore_all
711
+    fi
712
+}
713
+
690 714
 function logging_on_off {
691 715
     logging="no"
692 716
     dialog --title $"Logging" \
@@ -1216,24 +1240,25 @@ function menu_top_level {
1216 1240
         trap "rm -f $data" 0 1 2 5 15
1217 1241
         dialog --backtitle $"Freedombone Control Panel" \
1218 1242
                --title $"Control Panel" \
1219
-               --radiolist $"Choose an operation:" 24 70 17 \
1243
+               --radiolist $"Choose an operation:" 25 70 18 \
1220 1244
                1 $"Backup and Restore" off \
1221 1245
                2 $"Show SIP Phone Extensions" off \
1222 1246
                3 $"Reset Tripwire" off \
1223 1247
                4 $"Logging on/off" off \
1224
-               5 $"Manage Users" off \
1225
-               6 $"Email Filtering Rules" off \
1226
-               7 $"Security Settings" off \
1227
-               8 $"Hubzilla" off \
1228
-               9 $"Media menu" off \
1229
-               10 $"IRC menu" off \
1230
-               11 $"Change the name of this system" off \
1231
-               12 $"Set the TLS date/time source" off \
1232
-               13 $"Set a static local IP address" off \
1233
-               14 $"Check for updates" off \
1234
-               15 $"Power off the system" off \
1235
-               16 $"Restart the system" off \
1236
-               17 $"Exit" on 2> $data
1248
+               5 $"Ping enable/disable" off \
1249
+               6 $"Manage Users" off \
1250
+               7 $"Email Filtering Rules" off \
1251
+               8 $"Security Settings" off \
1252
+               9 $"Hubzilla" off \
1253
+               10 $"Media menu" off \
1254
+               11 $"IRC menu" off \
1255
+               12 $"Change the name of this system" off \
1256
+               13 $"Set the TLS date/time source" off \
1257
+               14 $"Set a static local IP address" off \
1258
+               15 $"Check for updates" off \
1259
+               16 $"Power off the system" off \
1260
+               17 $"Restart the system" off \
1261
+               18 $"Exit" on 2> $data
1237 1262
         sel=$?
1238 1263
         case $sel in
1239 1264
             1) exit 1;;
@@ -1244,19 +1269,20 @@ function menu_top_level {
1244 1269
             2) show_sip_extensions;;
1245 1270
             3) reset_tripwire;;
1246 1271
             4) logging_on_off;;
1247
-            5) menu_users;;
1248
-            6) menu_email;;
1249
-            7) security_settings;;
1250
-            8) menu_hubzilla;;
1251
-            9) menu_media;;
1252
-            10) menu_irc;;
1253
-            11) change_system_name;;
1254
-            12) set_tls_time_source;;
1255
-            13) set_static_IP;;
1256
-            14) check_for_updates;;
1257
-            15) shut_down_system;;
1258
-            16) restart_system;;
1259
-            17) break;;
1272
+            5) ping_enable_disable;;
1273
+            6) menu_users;;
1274
+            7) menu_email;;
1275
+            8) security_settings;;
1276
+            9) menu_hubzilla;;
1277
+            10) menu_media;;
1278
+            11) menu_irc;;
1279
+            12) change_system_name;;
1280
+            13) set_tls_time_source;;
1281
+            14) set_static_IP;;
1282
+            15) check_for_updates;;
1283
+            16) shut_down_system;;
1284
+            17) restart_system;;
1285
+            18) break;;
1260 1286
         esac
1261 1287
     done
1262 1288
 }