dhcp service example: rewrite "private network to mask" as case statement

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2019-02-08 10:37:05 +01:00
parent 2feaba1d8d
commit 5a387e26c2

View File

@ -29,14 +29,19 @@ test "$ip" || exit 1
# some servers do not return subnet option. # some servers do not return subnet option.
# guess it for standard private networks. # guess it for standard private networks.
if ! test "$mask"; then if ! test "$mask"; then
if test "$ip" != "${ip#192.168.}"; then case "$ip" in
mask=16 10.*)
elif test "$ip" != "${ip#172.16.}"; then mask=8;;
mask=12 192.168.*)
# repeat for each in 172.17. - 172.31. range? mask=16;;
elif test "$ip" != "${ip#10.}"; then #172.16-31.x.x
mask=8 172.1[6789].*)
fi mask=12;;
172.2[0123456789].*)
mask=12;;
172.3[01].*)
mask=12;;
esac
fi fi
# some servers do not return router option. # some servers do not return router option.