Is file /etc/hostname ever used for host name resolution?
When setting up a local Wi-Fi network in a small place from an ISP, such as Verizon, using a router and modem, the machines in the network are assigned private IP addresses.
In such a local Wi-Fi network, I can use ssh name@<hostname>
to access an SSH server on another computer <hostname>
, where <hostname>
is the output of command hostname
. Is the output of hostname
resolved to a private IP address, by some DNS server (possibly on the router?)?
But I heard that the output of hostname
is unrelated to host name resolution by DNS. Then why can I successfully run ssh name@<hostname>
, where <hostname>
is the output of command hostname
?
linux domain-name-system hostname
add a comment |
When setting up a local Wi-Fi network in a small place from an ISP, such as Verizon, using a router and modem, the machines in the network are assigned private IP addresses.
In such a local Wi-Fi network, I can use ssh name@<hostname>
to access an SSH server on another computer <hostname>
, where <hostname>
is the output of command hostname
. Is the output of hostname
resolved to a private IP address, by some DNS server (possibly on the router?)?
But I heard that the output of hostname
is unrelated to host name resolution by DNS. Then why can I successfully run ssh name@<hostname>
, where <hostname>
is the output of command hostname
?
linux domain-name-system hostname
add a comment |
When setting up a local Wi-Fi network in a small place from an ISP, such as Verizon, using a router and modem, the machines in the network are assigned private IP addresses.
In such a local Wi-Fi network, I can use ssh name@<hostname>
to access an SSH server on another computer <hostname>
, where <hostname>
is the output of command hostname
. Is the output of hostname
resolved to a private IP address, by some DNS server (possibly on the router?)?
But I heard that the output of hostname
is unrelated to host name resolution by DNS. Then why can I successfully run ssh name@<hostname>
, where <hostname>
is the output of command hostname
?
linux domain-name-system hostname
When setting up a local Wi-Fi network in a small place from an ISP, such as Verizon, using a router and modem, the machines in the network are assigned private IP addresses.
In such a local Wi-Fi network, I can use ssh name@<hostname>
to access an SSH server on another computer <hostname>
, where <hostname>
is the output of command hostname
. Is the output of hostname
resolved to a private IP address, by some DNS server (possibly on the router?)?
But I heard that the output of hostname
is unrelated to host name resolution by DNS. Then why can I successfully run ssh name@<hostname>
, where <hostname>
is the output of command hostname
?
linux domain-name-system hostname
linux domain-name-system hostname
edited 33 mins ago
Peter Mortensen
2,13242124
2,13242124
asked 7 hours ago
TimTim
69231526
69231526
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Linux systems using nss-myhostname will resolve the currently configured local hostname (which on some systems comes from /etc/hostname), when you use getaddrinfo
/gethostbyname
. Systems without nss-myhostname usually have the local hostname listed in /etc/hosts
, and resolve the local hostname that way.
If you specifically do dns lookups (e.g. with nslookup
or dig
), that bypasses nss and only uses dns, so nss-myhostname doesn't get a chance to influence the result.
If you want ssh@<hostname>
to work from other devices, make sure hostname resolves in dns, or is listed in /etc/hosts
on those devices.
Thanks. Updated my post to avoid misleading.
– Tim
6 hours ago
add a comment |
There are a couple of mechanisms that could be at work here.
Firstly, a system will often include its locally-configured hostname as a DHCP Client Identifier, and the router (which is also the DHCP and DNS server) will dynamically add a DNS record for that client ID matching the IP it gave out for that request.
The other likely case is that the system is advertizing it's locally-configured hostname using Multicast DNS Service Discovery (via Bonjour services on macOS, or the avahi daemon on Linux), and many modern distros include mDNS in their NSS lookup chain by default.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f953448%2fis-file-etc-hostname-ever-used-for-host-name-resolution%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Linux systems using nss-myhostname will resolve the currently configured local hostname (which on some systems comes from /etc/hostname), when you use getaddrinfo
/gethostbyname
. Systems without nss-myhostname usually have the local hostname listed in /etc/hosts
, and resolve the local hostname that way.
If you specifically do dns lookups (e.g. with nslookup
or dig
), that bypasses nss and only uses dns, so nss-myhostname doesn't get a chance to influence the result.
If you want ssh@<hostname>
to work from other devices, make sure hostname resolves in dns, or is listed in /etc/hosts
on those devices.
Thanks. Updated my post to avoid misleading.
– Tim
6 hours ago
add a comment |
Linux systems using nss-myhostname will resolve the currently configured local hostname (which on some systems comes from /etc/hostname), when you use getaddrinfo
/gethostbyname
. Systems without nss-myhostname usually have the local hostname listed in /etc/hosts
, and resolve the local hostname that way.
If you specifically do dns lookups (e.g. with nslookup
or dig
), that bypasses nss and only uses dns, so nss-myhostname doesn't get a chance to influence the result.
If you want ssh@<hostname>
to work from other devices, make sure hostname resolves in dns, or is listed in /etc/hosts
on those devices.
Thanks. Updated my post to avoid misleading.
– Tim
6 hours ago
add a comment |
Linux systems using nss-myhostname will resolve the currently configured local hostname (which on some systems comes from /etc/hostname), when you use getaddrinfo
/gethostbyname
. Systems without nss-myhostname usually have the local hostname listed in /etc/hosts
, and resolve the local hostname that way.
If you specifically do dns lookups (e.g. with nslookup
or dig
), that bypasses nss and only uses dns, so nss-myhostname doesn't get a chance to influence the result.
If you want ssh@<hostname>
to work from other devices, make sure hostname resolves in dns, or is listed in /etc/hosts
on those devices.
Linux systems using nss-myhostname will resolve the currently configured local hostname (which on some systems comes from /etc/hostname), when you use getaddrinfo
/gethostbyname
. Systems without nss-myhostname usually have the local hostname listed in /etc/hosts
, and resolve the local hostname that way.
If you specifically do dns lookups (e.g. with nslookup
or dig
), that bypasses nss and only uses dns, so nss-myhostname doesn't get a chance to influence the result.
If you want ssh@<hostname>
to work from other devices, make sure hostname resolves in dns, or is listed in /etc/hosts
on those devices.
answered 6 hours ago
Dennis KaarsemakerDennis Kaarsemaker
15.8k3766
15.8k3766
Thanks. Updated my post to avoid misleading.
– Tim
6 hours ago
add a comment |
Thanks. Updated my post to avoid misleading.
– Tim
6 hours ago
Thanks. Updated my post to avoid misleading.
– Tim
6 hours ago
Thanks. Updated my post to avoid misleading.
– Tim
6 hours ago
add a comment |
There are a couple of mechanisms that could be at work here.
Firstly, a system will often include its locally-configured hostname as a DHCP Client Identifier, and the router (which is also the DHCP and DNS server) will dynamically add a DNS record for that client ID matching the IP it gave out for that request.
The other likely case is that the system is advertizing it's locally-configured hostname using Multicast DNS Service Discovery (via Bonjour services on macOS, or the avahi daemon on Linux), and many modern distros include mDNS in their NSS lookup chain by default.
add a comment |
There are a couple of mechanisms that could be at work here.
Firstly, a system will often include its locally-configured hostname as a DHCP Client Identifier, and the router (which is also the DHCP and DNS server) will dynamically add a DNS record for that client ID matching the IP it gave out for that request.
The other likely case is that the system is advertizing it's locally-configured hostname using Multicast DNS Service Discovery (via Bonjour services on macOS, or the avahi daemon on Linux), and many modern distros include mDNS in their NSS lookup chain by default.
add a comment |
There are a couple of mechanisms that could be at work here.
Firstly, a system will often include its locally-configured hostname as a DHCP Client Identifier, and the router (which is also the DHCP and DNS server) will dynamically add a DNS record for that client ID matching the IP it gave out for that request.
The other likely case is that the system is advertizing it's locally-configured hostname using Multicast DNS Service Discovery (via Bonjour services on macOS, or the avahi daemon on Linux), and many modern distros include mDNS in their NSS lookup chain by default.
There are a couple of mechanisms that could be at work here.
Firstly, a system will often include its locally-configured hostname as a DHCP Client Identifier, and the router (which is also the DHCP and DNS server) will dynamically add a DNS record for that client ID matching the IP it gave out for that request.
The other likely case is that the system is advertizing it's locally-configured hostname using Multicast DNS Service Discovery (via Bonjour services on macOS, or the avahi daemon on Linux), and many modern distros include mDNS in their NSS lookup chain by default.
answered 5 hours ago
techieb0ytechieb0y
3,8511315
3,8511315
add a comment |
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f953448%2fis-file-etc-hostname-ever-used-for-host-name-resolution%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown