I am not sure how to do that,
but it will be something like (untested code):
var packetListener = Minecraft.getInstance().getConnection();
if (packetListener != null && packetListener.getConnection().getRemoteAddress() instanceof InetSocketAddress inetSocketAddress) {
System.out.println(inetSocketAddress);
}
Or there is also
var packetListener = Minecraft.getInstance().getConnection();
if (packetListener != null) {
System.out.println(packetListener.getServerData().ip);
}
But the latter is probably the "abcd.net"?
If those don't give you what you want, you can use packetListener.getConnection().channel() to get the Netty implementation.