I have two Ubuntu 18.04 and 20.x installs at home and trying to ssh between them, I can connect by Internal IP but not by hostname
Setup:
Machine A: 192.x.x.115
Machine B: 192.x.x.125
both installs have ssh running and I can connect fine using internal IP.
From Machine B I would like to connect to Machine A using hostname or hostname.ddns.net
Here are things I have setup:
Machine A:
machineA> /etc/hosts
127.0.0.1 machineA.ddns.net machineA
192.x.x.115 machineA
machineA> /etc/hostname
machineA.ddns.net
machineA> /etc/resolv.conf
nameserver 127.0.0.53
options edns0 trust-ad
search hsd1.xx.isp.net
Machine B:
machineB> ssh [email protected]
# i.e machineA is successful
machineB> ssh -vvv [email protected]
gives
Connecting to machineA.ddns.net [ISP assigned address] port 22.
ssh: connect to host machineA.ddns.net port 22: Connection timed out
machineB> ssh -vvv user@machineA
ssh: Could not resolve hostname machineA: Name or service not known
SSH_from_external_to_machineA is successful
ssh [email protected] # is successful
commands tried on machineA:
machineA> sudo service ssh status # gives active(running)
machineA> sudo netstat -alnp | grep :22 # shows :22 with LISTEN
machineA> sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
I feel ISP is not blocking ssh from ssh since I can connect from external using machineA.ddns.net
Router is allowing port 22 since I can connect using IP.
I feel hostname is not resolved correctly, please review and let me know if I am missing any additional steps.
Thanks,
Additional edits:
machineB> ping machineA_Hostname
is successful
machineB> nslookup machineA.ddns.net
is showing external IP as expected
machineB> ssh machineA
# Could not resolve hostname: Name or service not known
machineB> ssh machineA.ddns.net
attempts to connect to exact external IP that was reported by ping and 'Connection timed out'