SQL Server – Pinging Availability Group Listener Sometimes Fails

availability-groupssql server

I have a client with a Server Availability Group. Let's say the AG listener is named AG1 . The AG1 listener is set to static IP with two IP address. When I do a nslookup of AG1, the DNS entry has the same IP addresses. It's an active/passive AG with automatic failover and it hasn't failed over.

If I open a command prompt and ping AG1 , sometimes it succeeds (primary ip replies) and sometimes it fails (secondary ip address is unreachable). In other words, the "Ping AG1" command reply sometimes tries to ping the IP address of the Primary, and in that case it succeeds. Other times the "Ping AG1" command sometimes tries to ping the IP address of the secondary, and in that case it fails. It seems like it switches back and forth every 30 seconds or so.

Is this normal behavior? I would expect the primary to always respond , but perhaps ping isn't intended to work with an AG?

Update the AG group seems to be setup like the pics in this documentation https://docs.aws.amazon.com/quickstart/latest/sql/step3.html
where the AG listener's Network Mode is Static IP with two IP addresses

Best Answer

The AG1 listener is set to static IP with two IP address ... If I open a command prompt and ping AG1 , sometimes it succeeds (primary ip replies) and sometimes it fails (secondary ip address is unreachable)

Yes. This is normal when the nodes are on different subnets. The listener requires two separate IP addresses, only one of which is ever online.

Ping will resolve the DNS name, but will attempt to connect only to whichever IP is returned first. The order address are returned varies based on the client's subnet, and through "DNS Round-Robin".

The current SQL Server client libraries are coded to understand that when a DNS name resolves to two IP addresses, it must try both, as only one will be online.