diff --git a/src/etc/one-context.d/loc-10-network##apk.one b/src/etc/one-context.d/loc-10-network##apk.one index cd6af07..afba08b 100755 --- a/src/etc/one-context.d/loc-10-network##apk.one +++ b/src/etc/one-context.d/loc-10-network##apk.one @@ -41,7 +41,9 @@ get_network() { network=$(get_iface_var "NETWORK") 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 echo $network diff --git a/src/etc/one-context.d/loc-10-network##arch.one b/src/etc/one-context.d/loc-10-network##arch.one index 1b882cb..5b24f65 100755 --- a/src/etc/one-context.d/loc-10-network##arch.one +++ b/src/etc/one-context.d/loc-10-network##arch.one @@ -56,7 +56,9 @@ get_network() { network=$(get_iface_var "NETWORK") 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 echo $network diff --git a/src/etc/one-context.d/loc-10-network##bsd.one b/src/etc/one-context.d/loc-10-network##bsd.one index ab9f6f6..f31c6d9 100755 --- a/src/etc/one-context.d/loc-10-network##bsd.one +++ b/src/etc/one-context.d/loc-10-network##bsd.one @@ -37,7 +37,9 @@ get_network() { network=$(get_iface_var "NETWORK") 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 echo $network diff --git a/src/etc/one-context.d/loc-10-network##deb.one b/src/etc/one-context.d/loc-10-network##deb.one index 9d2ef0c..0940e63 100755 --- a/src/etc/one-context.d/loc-10-network##deb.one +++ b/src/etc/one-context.d/loc-10-network##deb.one @@ -37,7 +37,9 @@ get_network() { network=$(get_iface_var "NETWORK") 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 echo $network diff --git a/src/etc/one-context.d/loc-10-network##rpm.one b/src/etc/one-context.d/loc-10-network##rpm.one index 02a1aab..d44d8a4 100755 --- a/src/etc/one-context.d/loc-10-network##rpm.one +++ b/src/etc/one-context.d/loc-10-network##rpm.one @@ -37,7 +37,9 @@ get_network() { network=$(get_iface_var "NETWORK") 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 echo $network