Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 4428  / 2 Years ago, thu, february 10, 2022, 3:35:21

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



  1. I feel ISP is not blocking ssh from ssh since I can connect from external using machineA.ddns.net



  2. 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'


More From » networking

 Answers
1

To avoid hardcoding the internal IP address, setup avahi-daemon on Ubuntu for so you can reach hostname ubuntu.local from host OS.


sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan


[#2010] Saturday, February 12, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zzlingots

Total Points: 414
Total Questions: 130
Total Answers: 117

Location: Sudan
Member since Tue, Sep 15, 2020
4 Years ago
;