Resolving NTPD Interface Deletion Issue: Why Virtual Interfaces Go Down and How to Fix It


7 views

In CentOS systems with virtual interfaces configured on eth0, administrators occasionally encounter situations where these virtual interfaces mysteriously drop while only the primary eth0 interface gets restored automatically. The logs reveal a surprising culprit - ntpd appears to be deleting all network interfaces during certain events.

The log sequence clearly shows the pattern:

Nov 12 13:10:42 raptor ntpd[2109]: Deleting interface #31 eth0, 50.116.50.97#123
Nov 12 13:10:42 raptor ntpd[2109]: Deleting interface #32 eth0:0, 50.116.53.56#123
...
Nov 12 13:10:44 raptor dhclient[20048]: bound to 50.116.50.97
Nov 12 13:10:45 raptor ntpd[2109]: Listening on interface #39 eth0

This indicates that during DHCP renewal, ntpd removes all interface bindings before dhclient re-establishes only the primary interface.

The behavior stems from ntpd's interface management logic. When network changes occur, ntpd:

  1. Detects interface changes through kernel notifications
  2. Clears all existing NTP associations
  3. Re-scans and re-binds to available interfaces

Virtual interfaces (eth0:0, eth0:1 etc.) are particularly vulnerable because:

  • They're often configured as static while eth0 uses DHCP
  • NTPD doesn't distinguish between primary and virtual interfaces in its cleanup
  • DHCP scripts typically only restore the primary interface

Option 1: Configure NTPD to Ignore Interface Changes

Edit /etc/ntp.conf:

# Disable interface autodetection
interface ignore wildcard

# Manually specify interfaces to listen on
interface listen eth0
interface listen eth0:0
interface listen eth0:1
...

Option 2: Enhance the DHCP Client Script

Modify /etc/dhcp/dhclient-enter-hooks to restore virtual interfaces:

#!/bin/bash
make_virtual_interfaces() {
    if [ "$interface" = "eth0" ]; then
        /sbin/ifup eth0:0
        /sbin/ifup eth0:1
        # Add all virtual interfaces
    fi
}
make_virtual_interfaces

Option 3: Use Network Manager Persistence

For systems using NetworkManager, create connection persistence:

nmcli connection add type ethernet ifname eth0:0 \
    con-name "eth0-virtual0" \
    ip4 50.116.53.56/24 \
    gw4 50.116.50.1

To avoid future issues:

  • Consider using proper subinterfaces (eth0.1) instead of aliases (eth0:0)
  • Move critical services to separate physical interfaces if possible
  • Monitor interface status with tools like monit or nagios

For modern systems, define virtual interfaces persistently:

[Match]
Name=eth0

[Network]
Address=50.116.50.97/24
Address=50.116.53.56/24
Address=66.175.211.192/24
Gateway=50.116.50.1

During routine maintenance of our CentOS servers, we noticed virtual interfaces (eth0:0, eth0:1, etc.) would periodically go offline while the primary eth0 interface remained functional. Log analysis revealed this pattern consistently coincided with DHCP renewal events and NTPD interface cleanup operations.

The log sequence shows the exact chain of events:

1. DHCP renewal process begins
2. NTPD removes all eth0.* interfaces
3. dhclient re-establishes only the primary eth0
4. Virtual interfaces remain down

This occurs because:

  • NTPD's interface management is triggered by network changes
  • The DHCP renewal causes a temporary interface drop
  • Virtual interfaces aren't automatically restored by standard DHCP scripts

Our interface configuration shows the virtual interfaces lack DHCP configuration:

# Virtual interface example
DEVICE=eth0:0
BOOTPROTO=none  # Critical difference from primary interface
ONBOOT=yes
IPADDR=50.116.53.56
NETMASK=255.255.255.0

Option 1: Modify NTPD Behavior

Add to /etc/ntp.conf:

# Prevent interface deletion
interface ignore wildcard

Option 2: Enhanced DHCP Client Script

Modify /etc/dhcp/dhclient-enter-hooks:

#!/bin/bash
# Restore virtual interfaces after DHCP renewal
if [ "$reason" = "BOUND" ] || [ "$reason" = "RENEW" ]; then
    for i in {0..6}; do
        ifup eth0:$i 2>/dev/null
    done
fi

Option 3: Persistent Interface Configuration

Create /etc/network/if-up.d/restore_virtual:

#!/bin/bash
[ "$IFACE" = "eth0" ] || exit 0
for alias in /etc/sysconfig/network-scripts/ifcfg-eth0:*; do
    ifup ${alias##*/ifcfg-}
done

After implementing any solution:

# Force DHCP renewal to test
dhclient -r eth0 && dhclient eth0

# Check interface status
ip addr show eth0
ip addr show eth0:0

For critical infrastructure, consider static configuration:

# /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
ONBOOT="yes"
BOOTPROTO="none"  # Changed from dhcp
IPADDR=50.116.50.97
NETMASK=255.255.255.0
GATEWAY=50.116.50.1

This eliminates DHCP-triggered interface resets entirely.

Add this cron job to verify interface status hourly:

0 * * * * /usr/sbin/ifconfig eth0:0 | grep -q 'inet ' || /sbin/ifup eth0:0