I have some ghost/orphan network interfaces on my Mac Mini M1 2020 (macOS 15.1) that I would like to clean up. They appear in several places, such as in the Internet Sharing System Settings pane, as well as in the Terminal output of networksetup -listallhardwareports.
Running the command below reveals these network interfaces, several of which no longer physically exist:
networksetup -listallhardwareports | awk '
/^Hardware/{sub("Hardware Port: ","",$0); n=$0}
/^Device/{sub("Device: ","",$0); d=$0}
/^Ethernet/{sub("Ethernet Address: ","",$0); m=$0}
/^$/ && n!="" && m!="" && d!="" {
printf "%s\t%s\t%s\n",d,m,n
n=m=d=""
}' | sort
Output
en0 14:98:77:64:11:0d Ethernet
en1 14:98:77:5a:8b:1b Wi-Fi
en2 36:32:32:20:15:00 Thunderbolt 1
en3 36:32:32:20:15:04 Thunderbolt 2
en4 82:03:9a:33:94:72 Ethernet Adapter (en4)
en5 82:03:9a:33:94:73 Ethernet Adapter (en5)
en9 00:e0:4c:68:13:10 USB 10/100/1000 LAN
In my case, en2, en3, en4, en5 and en9 do not exist. I would like to purge them. I have tried deleting the NetworkInterfaces.plist plist using
sudo rm /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
However that does not make them go away. Related question with no answer: How do I get rid of old, orphaned network hardware ports under macOS?

