in secondary server while pinging listener , listener is pointing to offline IP and timing out
The PING utility only tries the first IP address returned by the listener name DNS query. This is problematic in the case of a multi-subnet AG because the first IP returned might not be the current primary node. You can use a nslookup command to see the listener IP name resolution order. Below is example output from a secondary node of a 4 node multi-subnet AG when run on the secondary 10.0.2.0/24 subnet node.
C:\> nslookup YourAG
Server: YourDNS.yourdomain.com
Address: 10.0.0.2
Name: YourAg.yourdomain.com
Addresses: 10.0.2.4
10.0.3.4
10.0.4.4
10.0.1.4
As you can see, the first IP address returned was the offline IP address of the local secondary node where PING was run. PING doesn't bother to try the other listener IP addresses, including the primary node (10.0.1.4 in this example). In my experience, the local subnet IP address is returned first when PING is run on a secondary.
A better way to test connectivity via the listener name using a SQL client tool like SQLCMD. This method will use a SQL client API which is a bit smarter than PING and try the other IP addresses, connecting to the online listener IP (primary node) even when it's not first in the list:
SQLCMD -S YourAG -E -Q "SELECT @@SERVERNAME;"