config_read $(zone_dir ${zone})/configs/${config}
if ! zone_has_ipv4 ${zone} ${ADDRESS}/${PREFIX}; then
+ if ipv4_detect_duplicate ${zone} ${ADDRESS}; then
+ error_log "Duplicate address detected on zone '${zone}' (${ADDRESS})."
+ error_log "Cannot continue."
+ exit ${EXIT_ERROR}
+ fi
+
ip addr add ${ADDRESS}/${PREFIX} dev ${zone}
- else
- warning "Do not set IPv4 address '${ADDRESS}/${PREFIX}' because it was already configured on zone '${zone}'."
+
+ # Announce our new address to the neighbours
+ ipv4_update_neighbours ${zone} ${ADDRESS}
fi
if zone_is_nonlocal ${zone} && [ -n "${GATEWAY}" ]; then
- : # XXX to be done
+ # Save configuration
+ red_db_set ${zone} type "${HOOK}"
+ red_db_set ${zone} local-ip-address ${ADDRESS}/${PREFIX}
+ red_db_set ${zone} remote-ip-address ${GATEWAY}
+
+ red_db_set ${zone} active 1
+ red_routing_update ${zone}
fi
exit ${EXIT_OK}