How to extract primary IP of Unix systems

See this related post: Registration subnet address of client error on rhel / mac

Using registration address of client should give you the IP that the client used to register with its relay, which could be what you are looking for.

What makes the primary IP the primary to you? It may not have the same meaning to everyone.