Page MenuHomeDevCentral

Allow to discover IPv6 gateway for Online servers
Needs ReviewPublic

Authored by dereckson on Sun, Aug 31, 16:07.

Details

Reviewers
DorianWinty
Summary

Online doesn't document gateway for IPv6 blocks.

Normally, inet6 -ifdisabled accept_rtadv up and the DHCPv6 request
to authenticate the right to use the block with DUID should be enough.

If we want to explicitly set a gateway in the routing table, we can
discover it through neighbour discovery protocol (NDP): this will be
the only IP adress not associated to a known MAC address.

With that informatino, gateway can then be declared on NetBox
by an ops running the query-ndp-for-ipv6-neighbor.sh script.

Test Plan

sh utils/query-ndp-for-ipv6-neighbor.sh on WindRiver

Diff Detail

Repository
rOPS Nasqueron Operations
Lint
Lint Passed
Unit
No Test Coverage
Branch
detect-gw-query-ndp
Build Status
Buildable 5837
Build 6119: arc lint + arc unit

Event Timeline

dereckson created this revision.

The ndp parsing code has been written by a GPT model, offering to forget about awk.

For reference, the following script generated by GPT 5 works too, but only with GNU awk:

#!/bin/sh

# Collect local MAC addresses
LOCAL_MACS=$(ifconfig | awk '/ether/ {print $2}')

# Scan ndp table
ndp -an | gawk -v macs="$LOCAL_MACS" '
NR == 1 { next }

BEGIN {
    split(macs, arr)
    for (i in arr) {
        local[arr[i]] = 1
    }
}
# Fields: IPv6, MAC, iface, ...
{
    mac = $2
    if (mac == "(incomplete)") next
    if (!(mac in local)) {
        ip = $1
        sub(/%.*/, "", ip)
        print ip
        exit 0
    }
}
'