mirror of https://github.com/k3s-io/k3s
Fix testing if an interface is the loopback
It's not guaranteed that the loopback interface only has the loopback IP, in our environments our loopback interface is also assigned a 169 address as well.pull/564/head
parent
01e7b3040a
commit
70923dd9db
|
@ -547,12 +547,15 @@ func getLocalIP() ([]v1.NodeAddress, error) {
|
|||
return nil, err
|
||||
}
|
||||
for _, i := range ifaces {
|
||||
if i.Flags&net.FlagLoopback != 0 {
|
||||
continue
|
||||
}
|
||||
localAddrs, err := i.Addrs()
|
||||
if err != nil {
|
||||
klog.Warningf("Failed to extract addresses for NodeAddresses - %v", err)
|
||||
} else {
|
||||
for _, addr := range localAddrs {
|
||||
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet, ok := addr.(*net.IPNet); ok {
|
||||
if ipnet.IP.To4() != nil {
|
||||
// Filter external IP by MAC address OUIs from vCenter and from ESX
|
||||
vmMACAddr := strings.ToLower(i.HardwareAddr.String())
|
||||
|
|
Loading…
Reference in New Issue