#!/bin/bash

# Make sure that the interface was no state leftover, ifdown leaves the IP
# address on the interface, since it assumes the interface is going to be
# kept down.
#

[ -n "$IFACE" ] || exit 1

# Skip if not inet
[ "$ADDRFAM" = "inet" ] || exit 0

# Skip if not eth0
[ "$IFACE" = "eth0" ] || exit 0

# Skip if zeroconf, it uses addresses on aliased (or labeled) interfaces
# and manages them correctly itself and we do not want to interfere
# with addresses on the non-aliased interface.
[ "$METHOD" = "zeroconf" ] && exit 0

# Flush the IP addresses on the non-aliased device
# (avoid aliases by using the label)
ip -4 addr flush dev "$IFACE" label "$IFACE" 2>/dev/null

exit 0
