assert isset network
- if ! ip_is_valid ${network}; then
+ if ! ip_is_network ${network} && ! ip_is_valid ${network}; then
error "The given network is invalid: ${network}"
return ${EXIT_ERROR}
fi
# network must be set.
isset network || return ${EXIT_ERROR}
- # network must be a valid.
- ip_is_network ${network} || return ${EXIT_ERROR}
+ # Is network or IP valid?
+ if ! ip_is_network ${network} && ! ip_is_valid ${network}; then
+ error "The given network is invalid: ${network}"
+ return ${EXIT_ERROR}
+ fi
# Check gateway settings.
if isset gateway; then
# Validate input.
assert isoneof type unicast broadcast unreachable prohibit blackhole
- assert ip_is_network ${network}
+
+ assert isset network
+
+ if ! ip_is_network ${network} && ! ip_is_valid ${network}; then
+ error "The given network is invalid: ${network}"
+ return ${EXIT_ERROR}
+ fi
+
if isset mtu; then
assert isinteger mtu
fi
# Detect the protocol of the given network.
local protocol=$(ip_detect_protocol ${network})
+
case "${protocol}" in
ipv6)
command="ip -6 route add"