问题原文
原帖链接 · f10w · CC BY-SA 4.0
I own a domain name mydomain.example, which I use CloudFlare for DNS. The domain is configured to point to my website hosted on GitHub.
In parallel, I have a Debian VPS from OVH, and I would like associate to it a fully qualified domain name (FQDN) (instead of vps123456.ovh.net), which I would like to be subdomain.mydomain.example.
My long-term plan is to host my website (mydomain.example) on this VPS as well, but for now to avoid messing things up, I would like to keep the website unchanged.
After some research using Google, I came up with the following steps:
- Create an A record in CloudFlare to point
subdomain.mydomain.exampleto the IP address192.0.2.91of the VPS. Change the hostname of the VPS into
subdomain.mydomain.example:- Change the content of
/etc/hostnamefromvps123456.ovh.nettosubdomain.mydomain.example. Change the content of
/etc/hostsfrom127.0.0.1 localhost 192.0.2.91 vps123456.ovh.net vps123456to
127.0.0.1 localhost 192.0.2.91 subdomain.mydomain.example subdomainApply the change without rebooting:
/etc/init.d/hostname.sh start
- Change the content of
After this, when doing hostname I obtained subdomain.mydomain.example, which is good. But when I opened a new terminal and try ssh [email omitted], it didn't work (timeout).
Update: To clarify, my final goal is not exactly to be able to SSH to the machine using ssh [email omitted], but rather to associate the IP address of the machine with a FQDN (which is needed for some paperwork: I have to connect to some institutional server through a machine, and for security reason, the IP address of this gateway machine must be associated to a FQDN. I am trying to set my VPS up for that purpose).
已采纳解答
原帖链接 · Piotr P. Karwasz · CC BY-SA 4.0
CloudFlare might take some (short) time to distribute your new A record to its DNS servers. Moreover the old A record for subdomain.domain.example (or its previous absence) might still be in the cache of the DNS recursive resolvers you use, for the amount of time indicated by the TTL of the old record (or the last number in the SOA record if it didn't exist before). Check with dig subdomain.domain.example to see if the IP address is already correct.
However you probably need the reverse lookup for your IP address to return your domain name (check with dig -x 192.0.2.91). This is done by adding a PTR record by the IP address owner (OVH). Usually you can change your reverse lookup through some web interface.
The line you added to /etc/hosts:
192.0.2.91 subdomain.mydomain.example subdomain
locally (on your machine) functions as three DNS records:
subdomain.mydomain.example. IN A 192.0.2.91
subdomain. IN A 192.0.2.91
91.2.0.191.in-addr.arpa. IN PTR subdomain.mydomain.example.
Now you need the real PTR record.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
