B #-: Calculate NETWORK from on IP/MASK

Signed-off-by: Deyan Chepishev <dchepishev@superhosting.bg>
pull/182/head
dchepishev 5 years ago committed by Vlastimil Holer
parent 5e89a5cbc1
commit 1c6d30c3ad

@ -41,7 +41,9 @@ get_network() {
network=$(get_iface_var "NETWORK") network=$(get_iface_var "NETWORK")
if [ -z "$network" ]; then if [ -z "$network" ]; then
network="$(echo $IP | cut -d'.' -f1,2,3).0" IFS=. read -r i1 i2 i3 i4 <<< "$IP"
IFS=. read -r m1 m2 m3 m4 <<< "$(get_mask)"
network=$(printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))")
fi fi
echo $network echo $network

@ -56,7 +56,9 @@ get_network() {
network=$(get_iface_var "NETWORK") network=$(get_iface_var "NETWORK")
if [ -z "$network" ]; then if [ -z "$network" ]; then
network="$(echo $IP | cut -d'.' -f1,2,3).0" IFS=. read -r i1 i2 i3 i4 <<< "$IP"
IFS=. read -r m1 m2 m3 m4 <<< "$(get_mask)"
network=$(printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))")
fi fi
echo $network echo $network

@ -37,7 +37,9 @@ get_network() {
network=$(get_iface_var "NETWORK") network=$(get_iface_var "NETWORK")
if [ -z "$network" ]; then if [ -z "$network" ]; then
network="$(echo $IP | cut -d'.' -f1,2,3).0" IFS=. read -r i1 i2 i3 i4 <<< "$IP"
IFS=. read -r m1 m2 m3 m4 <<< "$(get_mask)"
network=$(printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))")
fi fi
echo $network echo $network

@ -37,7 +37,9 @@ get_network() {
network=$(get_iface_var "NETWORK") network=$(get_iface_var "NETWORK")
if [ -z "$network" ]; then if [ -z "$network" ]; then
network="$(echo $IP | cut -d'.' -f1,2,3).0" IFS=. read -r i1 i2 i3 i4 <<< "$IP"
IFS=. read -r m1 m2 m3 m4 <<< "$(get_mask)"
network=$(printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))")
fi fi
echo $network echo $network

@ -37,7 +37,9 @@ get_network() {
network=$(get_iface_var "NETWORK") network=$(get_iface_var "NETWORK")
if [ -z "$network" ]; then if [ -z "$network" ]; then
network="$(echo $IP | cut -d'.' -f1,2,3).0" IFS=. read -r i1 i2 i3 i4 <<< "$IP"
IFS=. read -r m1 m2 m3 m4 <<< "$(get_mask)"
network=$(printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))")
fi fi
echo $network echo $network

Loading…
Cancel
Save