Update iptables.sh

This commit is contained in:
MarkusMcNugen 2018-04-26 02:55:08 -04:00 committed by GitHub
parent ddb4579470
commit 80b5f90e80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,7 @@ ip route add "${LAN_NETWORK}" via "${DEFAULT_GATEWAY}" dev eth0
IFS=',' read -ra lan_network_list <<< "${LAN_NETWORKS}" IFS=',' read -ra lan_network_list <<< "${LAN_NETWORKS}"
lancount=0 lancount=0
lan_network_devices=()
# process lan networks in the list # process lan networks in the list
for lan_network_item in "${lan_network_list[@]}"; do for lan_network_item in "${lan_network_list[@]}"; do
lan_network_item=$(echo "${lan_network_item}" | sed -e 's~^[ \t]*~~;s~[ \t]*$~~') lan_network_item=$(echo "${lan_network_item}" | sed -e 's~^[ \t]*~~;s~[ \t]*$~~')
@ -41,8 +42,9 @@ for lan_network_item in "${lan_network_list[@]}"; do
int_mask=$(ifconfig "${interface}" | grep -o "netmask [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*") int_mask=$(ifconfig "${interface}" | grep -o "netmask [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*")
int_cidr=$(ipcalc "${int_ip}" "${int_mask}" | grep -P -o -m 1 "(?<=Network:)\s+[^\s]+" | sed -e 's~^[ \t]*~~;s~[ \t]*$~~') int_cidr=$(ipcalc "${int_ip}" "${int_mask}" | grep -P -o -m 1 "(?<=Network:)\s+[^\s]+" | sed -e 's~^[ \t]*~~;s~[ \t]*$~~')
if [[ $int_cidr == $lan_network_item ]]; then if [[ $int_cidr == $lan_network_item ]]; then
$lan_network_devices[$lancount]=$interface lan_network_devices+=(${interface})
echo "${lan_network_devices[$lancount]}" echo "$int_cidr detected on $interface interface"
# get default gateway of interfaces as looping through them # get default gateway of interfaces as looping through them
DEFAULT_GATEWAY=$(/sbin/ip route |grep '^default' | awk "/${$interface}/ {print $3}") DEFAULT_GATEWAY=$(/sbin/ip route |grep '^default' | awk "/${$interface}/ {print $3}")