forked from extern/shorewall_code
Added ipcalc command to /sbin/shorewall
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@632 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
b1b3d09473
commit
4f6f76ec72
@ -31,3 +31,7 @@ Changes since 1.4.5
|
|||||||
|
|
||||||
13) Check for shells whose arithmetic support is broken.
|
13) Check for shells whose arithmetic support is broken.
|
||||||
|
|
||||||
|
14) Moved IP Address manipulation functions to
|
||||||
|
/usr/share/shorewall/functions.
|
||||||
|
|
||||||
|
15. Added ipcalc command.
|
||||||
|
@ -341,10 +341,10 @@ in_subnet() # $1 = IP address, $2 = CIDR network
|
|||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Address Netmask to CIDR
|
# Netmask to CIDR
|
||||||
#
|
#
|
||||||
ip_cidr() {
|
ip_cidr() {
|
||||||
local mask=`decodeaddr $2`
|
local mask=`decodeaddr $1`
|
||||||
local cidr=0
|
local cidr=0
|
||||||
local x=$(( 128 $LEFTSHIFT 24 ))
|
local x=$(( 128 $LEFTSHIFT 24 ))
|
||||||
|
|
||||||
@ -354,9 +354,9 @@ ip_cidr() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ $(( $mask & 2147483647)) -ne 0 ]; then
|
if [ $(( $mask & 2147483647)) -ne 0 ]; then
|
||||||
echo "Invalid net mask: $2" >&2
|
echo "Invalid net mask: $1" >&2
|
||||||
else
|
else
|
||||||
echo $1/$cidr
|
echo $cidr
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,3 +83,23 @@ New Features:
|
|||||||
7) The shell used to interpret the firewall script
|
7) The shell used to interpret the firewall script
|
||||||
(/usr/share/shorewall/firewall) may now be specified using the
|
(/usr/share/shorewall/firewall) may now be specified using the
|
||||||
SHOREWALL_SHELL parameter in shorewall.conf.
|
SHOREWALL_SHELL parameter in shorewall.conf.
|
||||||
|
|
||||||
|
8) An 'ipcalc' command has been added to /sbin/shorewall.
|
||||||
|
|
||||||
|
ipcalc [ <address> <netmask> | <address>/<vlsm> ]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
[root@wookie root]# shorewall ipcalc 192.168.1.0/24
|
||||||
|
CIDR=192.168.1.0/24
|
||||||
|
NETMASK=255.255.255.0
|
||||||
|
NETWORK=192.168.1.0
|
||||||
|
BROADCAST=192.168.1.255
|
||||||
|
[root@wookie root]#
|
||||||
|
|
||||||
|
[root@wookie root]# shorewall ipcalc 192.168.1.0 255.255.255.0
|
||||||
|
CIDR=192.168.1.0/24
|
||||||
|
NETMASK=255.255.255.0
|
||||||
|
NETWORK=192.168.1.0
|
||||||
|
BROADCAST=192.168.1.255
|
||||||
|
[root@wookie root]#
|
||||||
|
@ -82,6 +82,10 @@
|
|||||||
# be automatically reinstated the
|
# be automatically reinstated the
|
||||||
# next time that Shorewall starts.
|
# next time that Shorewall starts.
|
||||||
#
|
#
|
||||||
|
# shorewall ipaddr [ <address>/<cidr> | <address> <netmask> ]
|
||||||
|
#
|
||||||
|
# Displays information about the network
|
||||||
|
# defined by the argument[s]
|
||||||
# Display a chain if it exists
|
# Display a chain if it exists
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -528,6 +532,7 @@ usage() # $1 = exit status
|
|||||||
echo " reject <address> ..."
|
echo " reject <address> ..."
|
||||||
echo " allow <address> ..."
|
echo " allow <address> ..."
|
||||||
echo " save"
|
echo " save"
|
||||||
|
echo " ipcalc [ <address>/<vlsm> | <address> <netmask> ]"
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -869,7 +874,30 @@ case "$1" in
|
|||||||
fi
|
fi
|
||||||
mutex_off
|
mutex_off
|
||||||
;;
|
;;
|
||||||
|
ipcalc)
|
||||||
|
if [ $# -eq 2 ]; then
|
||||||
|
address=${2%/*}
|
||||||
|
cidr=${2#*/}
|
||||||
|
elif [ $# -eq 3 ]; then
|
||||||
|
address=$2
|
||||||
|
cidr=`ip_cidr $3`
|
||||||
|
else
|
||||||
|
usage 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -z "$cidr" ] && exit 2
|
||||||
|
[ "x$address" = "x$cidr" ] && usage 2
|
||||||
|
|
||||||
|
address=$address/$cidr
|
||||||
|
|
||||||
|
echo " CIDR=$address"
|
||||||
|
temp=`ip_netmask $address`; echo " NETMASK=`encodeaddr $temp`"
|
||||||
|
temp=`ip_network $address`; echo " NETWORK=$temp"
|
||||||
|
temp=`broadcastaddress $address`; echo " BROADCAST=$temp"
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
usage 1
|
usage 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user