diff options
-rwxr-xr-x | examples/var_service/dhcp_if/convert2ipconf | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/var_service/dhcp_if/convert2ipconf b/examples/var_service/dhcp_if/convert2ipconf index 62a288ebf..038b1f7f1 100755 --- a/examples/var_service/dhcp_if/convert2ipconf +++ b/examples/var_service/dhcp_if/convert2ipconf | |||
@@ -26,6 +26,25 @@ exec 2>&1 | |||
26 | test "$interface" || exit 1 | 26 | test "$interface" || exit 1 |
27 | test "$ip" || exit 1 | 27 | test "$ip" || exit 1 |
28 | 28 | ||
29 | # some servers do not return subnet option. | ||
30 | # guess it for standard private networks. | ||
31 | if ! test "$mask"; then | ||
32 | if test "$ip" != "${ip#192.168.}"; then | ||
33 | mask=16 | ||
34 | elif test "$ip" != "${ip#172.16.}"; then | ||
35 | mask=12 | ||
36 | # repeat for each in 172.17. - 172.31. range? | ||
37 | elif test "$ip" != "${ip#10.}"; then | ||
38 | mask=8 | ||
39 | fi | ||
40 | fi | ||
41 | |||
42 | # some servers do not return router option. | ||
43 | # assume DHCP server is the router. | ||
44 | if ! test "$router"; then | ||
45 | test "$serverid" && router="$serverid" | ||
46 | fi | ||
47 | |||
29 | { | 48 | { |
30 | echo "let cfg=cfg+1" | 49 | echo "let cfg=cfg+1" |
31 | test "$interface" && echo "if[\$cfg]='$interface'" | 50 | test "$interface" && echo "if[\$cfg]='$interface'" |