aws / amazon-ssm-agent

An agent to enable remote management of your EC2 instances, on-premises servers, or virtual machines (VMs).
https://aws.amazon.com/systems-manager/
Apache License 2.0
1.05k stars 324 forks source link

Unable to configure local on-prem default Windows Server IP Address #406

Closed kevinmcrofts closed 1 year ago

kevinmcrofts commented 3 years ago

I am unable to configure the local Windows Server IP Address for an on-prem machine. This appears to be caused by sorting by index on the IP Addresses. https://github.com/aws/amazon-ssm-agent/blob/a65a94f46200d68b4c2ed9d4bf26c59dce0eba49/agent/platform/platform.go#L77 In Linux the index order return begins at 0 and increases by 1 but in Windows this is not the case. By running Get-NetIPInterface in PowerShell. You can see the ifIndex that is returned from the golang API doesn't follow this rule. // Interface represents a mapping between network interface name // and index. It also represents network interface facility // information. type Interface struct { Index int // positive integer that starts at one, zero is never used MTU int // maximum transmission unit Name string // e.g., "en0", "lo0", "eth0.100" HardwareAddr HardwareAddr // IEEE MAC-48, EUI-48 and EUI-64 form Flags Flags // e.g., FlagUp, FlagLoopback, FlagMulticast } image

vkacharaya commented 3 years ago

Hi @kevinmcrofts, Thanks for reaching us. We just use index for sorting the interfaces. Could you please let us know what is the expected IP(need the index number alone) that you wanted to be displayed? According to the code, IPV4 address associated with Index 4 would have been displayed.

kevinmcrofts commented 3 years ago

I have the following golang test code running on the Windows Server package main

import ( "fmt" "net" )

// IP of the network interface func IP() (selected string, err error) { var interfaces []net.Interface if interfaces, err = net.Interfaces(); err == nil { fmt.Printf("interfaces=%v\n",interfaces) } return }

func main() { fmt.Printf("Get Local Addresses:\n") IP() } This is returning Get Local Addresses: interfaces=[{5 1500 Embedded LOM 1 Port 2 b4:7a:f1:50:a3:41 broadcast|multicast} {17 1500 Embedded LOM 1 Port 4 b4:7a:f1:50:a3:43 up|broadcast|multicast} {8 1500 Embedded LOM 1 Port 1 b4:7a:f1:50:a3:40 up|broadcast|multicast} {4 1500 Embedded LOM 1 Port 3 b4:7a:f1:50:a3:42 up|broadcast|multicast} {1 -1 Loopback Pseudo-Interface 1 up|loopback|multicast}] So I'm unable to unable to use the agent as it needs to connect on Ethernet LOM 1 Port 1 to reach AWS.

kevinmcrofts commented 3 years ago

If the code could use the interface metric then I could set this on the Windows Network interface and this would then allow the default IP address to connect to AWS.

VishnuKarthikRavindran commented 3 years ago

We do not use the IP returned from this function for any communication. The returned IP is just for display purposes. Thanks

kevinmcrofts commented 3 years ago

If you are not using the IP address displayed in the AWS instance overview for communication (which is an issue in itself) then how do you determine the local source address used for communication in an on-prem server with multiple network interfaces?

sluggard76 commented 1 year ago

The fix is ready and being released. Please wait for new agent version: 3.2.401.0