Suppose I have some device with multiple addresses like so (due to some combination of AD and VMWare NAT name resolution, but that's not germane):
[centos@localhost ~]$ getent hosts my-weird-AD-device.company.com
192.168.1.10 my-weird-AD-device.company.com
192.168.4.13 my-weird-AD-device.company.com
The address I have a route to is 192.168.1.10
, from a device on the same network segment as 192.168.4.13
.
If I try to SSH directly to 192.168.1.10
, everything works fine, but SSH'ing by hostname fails, because it tries to connect to 192.168.4.13
.
...
debug2: resolving "my-weird-ad-device.company.com" port 22
debug1: Connecting to my-weird-ad-device.company.com [192.168.4.13] port 22.
Can I control this behavior somehow, from the SSH client? I don't want to hardcode an IP into ~/.ssh/config
or /etc/hosts
as the working IP isn't static - I want to do this via name lookup if possible.