Does a computer system (Linux) only have one host name?












3















hostname is used to display the system's DNS name, and to display or set its hostname or NIS domain name.



Does a computer system (Linux) only have one host name?



In virtual hosting, several host names can be resolved to different root directories in a web server. If a computer system (Linux) can only have one host name, how is virtual hosting possible?



Thanks.










share|improve this question

























  • DNS A or AAA records point to the same IP address for multiple domains. The hostname of the machine is not necessarily important.

    – RubberStamp
    6 hours ago











  • (1) Is the output of hostname ever used in resolving hostname to IP address? (2) A means IPv4 address, AAAA IPv6. What is AAA?

    – Tim
    5 hours ago













  • mDNS services, such as avahi depend on the machine hostname. In that case, hostname.local would resolve to the local IP address of the machine. I see someone wrote an answer which is an expansion of my first comment... too simultaneous for my browser notifications.

    – RubberStamp
    5 hours ago











  • AAA is a 'A' short typo

    – RubberStamp
    5 hours ago








  • 1





    American Automobile Association?

    – Hagen von Eitzen
    4 hours ago
















3















hostname is used to display the system's DNS name, and to display or set its hostname or NIS domain name.



Does a computer system (Linux) only have one host name?



In virtual hosting, several host names can be resolved to different root directories in a web server. If a computer system (Linux) can only have one host name, how is virtual hosting possible?



Thanks.










share|improve this question

























  • DNS A or AAA records point to the same IP address for multiple domains. The hostname of the machine is not necessarily important.

    – RubberStamp
    6 hours ago











  • (1) Is the output of hostname ever used in resolving hostname to IP address? (2) A means IPv4 address, AAAA IPv6. What is AAA?

    – Tim
    5 hours ago













  • mDNS services, such as avahi depend on the machine hostname. In that case, hostname.local would resolve to the local IP address of the machine. I see someone wrote an answer which is an expansion of my first comment... too simultaneous for my browser notifications.

    – RubberStamp
    5 hours ago











  • AAA is a 'A' short typo

    – RubberStamp
    5 hours ago








  • 1





    American Automobile Association?

    – Hagen von Eitzen
    4 hours ago














3












3








3








hostname is used to display the system's DNS name, and to display or set its hostname or NIS domain name.



Does a computer system (Linux) only have one host name?



In virtual hosting, several host names can be resolved to different root directories in a web server. If a computer system (Linux) can only have one host name, how is virtual hosting possible?



Thanks.










share|improve this question
















hostname is used to display the system's DNS name, and to display or set its hostname or NIS domain name.



Does a computer system (Linux) only have one host name?



In virtual hosting, several host names can be resolved to different root directories in a web server. If a computer system (Linux) can only have one host name, how is virtual hosting possible?



Thanks.







linux hostname






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 6 hours ago









Jeff Schaller

41.3k1056131




41.3k1056131










asked 6 hours ago









TimTim

26.8k77258469




26.8k77258469













  • DNS A or AAA records point to the same IP address for multiple domains. The hostname of the machine is not necessarily important.

    – RubberStamp
    6 hours ago











  • (1) Is the output of hostname ever used in resolving hostname to IP address? (2) A means IPv4 address, AAAA IPv6. What is AAA?

    – Tim
    5 hours ago













  • mDNS services, such as avahi depend on the machine hostname. In that case, hostname.local would resolve to the local IP address of the machine. I see someone wrote an answer which is an expansion of my first comment... too simultaneous for my browser notifications.

    – RubberStamp
    5 hours ago











  • AAA is a 'A' short typo

    – RubberStamp
    5 hours ago








  • 1





    American Automobile Association?

    – Hagen von Eitzen
    4 hours ago



















  • DNS A or AAA records point to the same IP address for multiple domains. The hostname of the machine is not necessarily important.

    – RubberStamp
    6 hours ago











  • (1) Is the output of hostname ever used in resolving hostname to IP address? (2) A means IPv4 address, AAAA IPv6. What is AAA?

    – Tim
    5 hours ago













  • mDNS services, such as avahi depend on the machine hostname. In that case, hostname.local would resolve to the local IP address of the machine. I see someone wrote an answer which is an expansion of my first comment... too simultaneous for my browser notifications.

    – RubberStamp
    5 hours ago











  • AAA is a 'A' short typo

    – RubberStamp
    5 hours ago








  • 1





    American Automobile Association?

    – Hagen von Eitzen
    4 hours ago

















DNS A or AAA records point to the same IP address for multiple domains. The hostname of the machine is not necessarily important.

– RubberStamp
6 hours ago





DNS A or AAA records point to the same IP address for multiple domains. The hostname of the machine is not necessarily important.

– RubberStamp
6 hours ago













(1) Is the output of hostname ever used in resolving hostname to IP address? (2) A means IPv4 address, AAAA IPv6. What is AAA?

– Tim
5 hours ago







(1) Is the output of hostname ever used in resolving hostname to IP address? (2) A means IPv4 address, AAAA IPv6. What is AAA?

– Tim
5 hours ago















mDNS services, such as avahi depend on the machine hostname. In that case, hostname.local would resolve to the local IP address of the machine. I see someone wrote an answer which is an expansion of my first comment... too simultaneous for my browser notifications.

– RubberStamp
5 hours ago





mDNS services, such as avahi depend on the machine hostname. In that case, hostname.local would resolve to the local IP address of the machine. I see someone wrote an answer which is an expansion of my first comment... too simultaneous for my browser notifications.

– RubberStamp
5 hours ago













AAA is a 'A' short typo

– RubberStamp
5 hours ago







AAA is a 'A' short typo

– RubberStamp
5 hours ago






1




1





American Automobile Association?

– Hagen von Eitzen
4 hours ago





American Automobile Association?

– Hagen von Eitzen
4 hours ago










1 Answer
1






active

oldest

votes


















6














Yes, and no. The are two distinct things called hostnames.



The hostname internal to the system and kept by the kernel, the one returned by the hostname command (or the gethostname() call) is unique. It's mostly used for identifying the system, e.g. if you h in Bash's PS1, it expands that to the hostname. Similarly, syslog-style logfiles also include the hostname on log entries.



Then there's also DNS names that are used by other systems to look up the IP address of another. There might be more than one DNS name that point to the same IP address, and so the same host.



The internal hostname and the DNS names don't need to be the same. A web server serving two different domains could have www.example.org and www.example.com both pointing to 192.0.2.9 in DNS, while the internal hostname of the system might be orange.example.org, or something equally unrelated. In that case, the DNS setup would usually have a reverse lookup on 192.0.2.9 point back to the name orange.example.org, but there's nothing to force that.



In addition to that, virtual hosting requires that the browser tell the web server the name of the site it tried to access. Otherwise the server would not know which virtual site the client tried to reach. HTTP has the Host header for that.






share|improve this answer


























  • Thanks. (1) "the DNS setup would usually have 192.0.2.9 point back to the name orange.example.org" Doesn't resolving get IP address for a given host name, why the opposite? (2) Is the output of hostname ever used in resolving hostname to IP address?

    – Tim
    5 hours ago













  • (2) ... When set up a local wifi network in your home from an ISP using a router and modem, the machines in the network can be identified by the outputs of their hostname commands, correct? Does the router act like a DNS to resolve the outputs of hostname to private IP addresses in the network?

    – Tim
    5 hours ago













  • @Tim, (2) uhhuh, I'm not sure. There might be (probably are) systems that automatically discover hosts on the same network, but I'm not too familiar with them. (I know Windows does it, but that doesn't help much.) There would need to be an additional protocol there to communicate the hostnames and IP's and to have them show up as DNS names on the other hosts.

    – ilkkachu
    5 hours ago













  • as for (1), there's also reverse lookups that take the IP address and return a name. (For a system with a single name and a single address, you'd want to have both resolve to the other, just for clarity's sake)

    – ilkkachu
    5 hours ago








  • 1





    Small networks may be using mDNS. For better or worse, it lets system owners choose their own hostnames, accessible by other systems on the local network, without the need to register with a DNS server.

    – Mark Plotnick
    3 hours ago













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500050%2fdoes-a-computer-system-linux-only-have-one-host-name%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














Yes, and no. The are two distinct things called hostnames.



The hostname internal to the system and kept by the kernel, the one returned by the hostname command (or the gethostname() call) is unique. It's mostly used for identifying the system, e.g. if you h in Bash's PS1, it expands that to the hostname. Similarly, syslog-style logfiles also include the hostname on log entries.



Then there's also DNS names that are used by other systems to look up the IP address of another. There might be more than one DNS name that point to the same IP address, and so the same host.



The internal hostname and the DNS names don't need to be the same. A web server serving two different domains could have www.example.org and www.example.com both pointing to 192.0.2.9 in DNS, while the internal hostname of the system might be orange.example.org, or something equally unrelated. In that case, the DNS setup would usually have a reverse lookup on 192.0.2.9 point back to the name orange.example.org, but there's nothing to force that.



In addition to that, virtual hosting requires that the browser tell the web server the name of the site it tried to access. Otherwise the server would not know which virtual site the client tried to reach. HTTP has the Host header for that.






share|improve this answer


























  • Thanks. (1) "the DNS setup would usually have 192.0.2.9 point back to the name orange.example.org" Doesn't resolving get IP address for a given host name, why the opposite? (2) Is the output of hostname ever used in resolving hostname to IP address?

    – Tim
    5 hours ago













  • (2) ... When set up a local wifi network in your home from an ISP using a router and modem, the machines in the network can be identified by the outputs of their hostname commands, correct? Does the router act like a DNS to resolve the outputs of hostname to private IP addresses in the network?

    – Tim
    5 hours ago













  • @Tim, (2) uhhuh, I'm not sure. There might be (probably are) systems that automatically discover hosts on the same network, but I'm not too familiar with them. (I know Windows does it, but that doesn't help much.) There would need to be an additional protocol there to communicate the hostnames and IP's and to have them show up as DNS names on the other hosts.

    – ilkkachu
    5 hours ago













  • as for (1), there's also reverse lookups that take the IP address and return a name. (For a system with a single name and a single address, you'd want to have both resolve to the other, just for clarity's sake)

    – ilkkachu
    5 hours ago








  • 1





    Small networks may be using mDNS. For better or worse, it lets system owners choose their own hostnames, accessible by other systems on the local network, without the need to register with a DNS server.

    – Mark Plotnick
    3 hours ago


















6














Yes, and no. The are two distinct things called hostnames.



The hostname internal to the system and kept by the kernel, the one returned by the hostname command (or the gethostname() call) is unique. It's mostly used for identifying the system, e.g. if you h in Bash's PS1, it expands that to the hostname. Similarly, syslog-style logfiles also include the hostname on log entries.



Then there's also DNS names that are used by other systems to look up the IP address of another. There might be more than one DNS name that point to the same IP address, and so the same host.



The internal hostname and the DNS names don't need to be the same. A web server serving two different domains could have www.example.org and www.example.com both pointing to 192.0.2.9 in DNS, while the internal hostname of the system might be orange.example.org, or something equally unrelated. In that case, the DNS setup would usually have a reverse lookup on 192.0.2.9 point back to the name orange.example.org, but there's nothing to force that.



In addition to that, virtual hosting requires that the browser tell the web server the name of the site it tried to access. Otherwise the server would not know which virtual site the client tried to reach. HTTP has the Host header for that.






share|improve this answer


























  • Thanks. (1) "the DNS setup would usually have 192.0.2.9 point back to the name orange.example.org" Doesn't resolving get IP address for a given host name, why the opposite? (2) Is the output of hostname ever used in resolving hostname to IP address?

    – Tim
    5 hours ago













  • (2) ... When set up a local wifi network in your home from an ISP using a router and modem, the machines in the network can be identified by the outputs of their hostname commands, correct? Does the router act like a DNS to resolve the outputs of hostname to private IP addresses in the network?

    – Tim
    5 hours ago













  • @Tim, (2) uhhuh, I'm not sure. There might be (probably are) systems that automatically discover hosts on the same network, but I'm not too familiar with them. (I know Windows does it, but that doesn't help much.) There would need to be an additional protocol there to communicate the hostnames and IP's and to have them show up as DNS names on the other hosts.

    – ilkkachu
    5 hours ago













  • as for (1), there's also reverse lookups that take the IP address and return a name. (For a system with a single name and a single address, you'd want to have both resolve to the other, just for clarity's sake)

    – ilkkachu
    5 hours ago








  • 1





    Small networks may be using mDNS. For better or worse, it lets system owners choose their own hostnames, accessible by other systems on the local network, without the need to register with a DNS server.

    – Mark Plotnick
    3 hours ago
















6












6








6







Yes, and no. The are two distinct things called hostnames.



The hostname internal to the system and kept by the kernel, the one returned by the hostname command (or the gethostname() call) is unique. It's mostly used for identifying the system, e.g. if you h in Bash's PS1, it expands that to the hostname. Similarly, syslog-style logfiles also include the hostname on log entries.



Then there's also DNS names that are used by other systems to look up the IP address of another. There might be more than one DNS name that point to the same IP address, and so the same host.



The internal hostname and the DNS names don't need to be the same. A web server serving two different domains could have www.example.org and www.example.com both pointing to 192.0.2.9 in DNS, while the internal hostname of the system might be orange.example.org, or something equally unrelated. In that case, the DNS setup would usually have a reverse lookup on 192.0.2.9 point back to the name orange.example.org, but there's nothing to force that.



In addition to that, virtual hosting requires that the browser tell the web server the name of the site it tried to access. Otherwise the server would not know which virtual site the client tried to reach. HTTP has the Host header for that.






share|improve this answer















Yes, and no. The are two distinct things called hostnames.



The hostname internal to the system and kept by the kernel, the one returned by the hostname command (or the gethostname() call) is unique. It's mostly used for identifying the system, e.g. if you h in Bash's PS1, it expands that to the hostname. Similarly, syslog-style logfiles also include the hostname on log entries.



Then there's also DNS names that are used by other systems to look up the IP address of another. There might be more than one DNS name that point to the same IP address, and so the same host.



The internal hostname and the DNS names don't need to be the same. A web server serving two different domains could have www.example.org and www.example.com both pointing to 192.0.2.9 in DNS, while the internal hostname of the system might be orange.example.org, or something equally unrelated. In that case, the DNS setup would usually have a reverse lookup on 192.0.2.9 point back to the name orange.example.org, but there's nothing to force that.



In addition to that, virtual hosting requires that the browser tell the web server the name of the site it tried to access. Otherwise the server would not know which virtual site the client tried to reach. HTTP has the Host header for that.







share|improve this answer














share|improve this answer



share|improve this answer








edited 5 hours ago

























answered 6 hours ago









ilkkachuilkkachu

58.4k890164




58.4k890164













  • Thanks. (1) "the DNS setup would usually have 192.0.2.9 point back to the name orange.example.org" Doesn't resolving get IP address for a given host name, why the opposite? (2) Is the output of hostname ever used in resolving hostname to IP address?

    – Tim
    5 hours ago













  • (2) ... When set up a local wifi network in your home from an ISP using a router and modem, the machines in the network can be identified by the outputs of their hostname commands, correct? Does the router act like a DNS to resolve the outputs of hostname to private IP addresses in the network?

    – Tim
    5 hours ago













  • @Tim, (2) uhhuh, I'm not sure. There might be (probably are) systems that automatically discover hosts on the same network, but I'm not too familiar with them. (I know Windows does it, but that doesn't help much.) There would need to be an additional protocol there to communicate the hostnames and IP's and to have them show up as DNS names on the other hosts.

    – ilkkachu
    5 hours ago













  • as for (1), there's also reverse lookups that take the IP address and return a name. (For a system with a single name and a single address, you'd want to have both resolve to the other, just for clarity's sake)

    – ilkkachu
    5 hours ago








  • 1





    Small networks may be using mDNS. For better or worse, it lets system owners choose their own hostnames, accessible by other systems on the local network, without the need to register with a DNS server.

    – Mark Plotnick
    3 hours ago





















  • Thanks. (1) "the DNS setup would usually have 192.0.2.9 point back to the name orange.example.org" Doesn't resolving get IP address for a given host name, why the opposite? (2) Is the output of hostname ever used in resolving hostname to IP address?

    – Tim
    5 hours ago













  • (2) ... When set up a local wifi network in your home from an ISP using a router and modem, the machines in the network can be identified by the outputs of their hostname commands, correct? Does the router act like a DNS to resolve the outputs of hostname to private IP addresses in the network?

    – Tim
    5 hours ago













  • @Tim, (2) uhhuh, I'm not sure. There might be (probably are) systems that automatically discover hosts on the same network, but I'm not too familiar with them. (I know Windows does it, but that doesn't help much.) There would need to be an additional protocol there to communicate the hostnames and IP's and to have them show up as DNS names on the other hosts.

    – ilkkachu
    5 hours ago













  • as for (1), there's also reverse lookups that take the IP address and return a name. (For a system with a single name and a single address, you'd want to have both resolve to the other, just for clarity's sake)

    – ilkkachu
    5 hours ago








  • 1





    Small networks may be using mDNS. For better or worse, it lets system owners choose their own hostnames, accessible by other systems on the local network, without the need to register with a DNS server.

    – Mark Plotnick
    3 hours ago



















Thanks. (1) "the DNS setup would usually have 192.0.2.9 point back to the name orange.example.org" Doesn't resolving get IP address for a given host name, why the opposite? (2) Is the output of hostname ever used in resolving hostname to IP address?

– Tim
5 hours ago







Thanks. (1) "the DNS setup would usually have 192.0.2.9 point back to the name orange.example.org" Doesn't resolving get IP address for a given host name, why the opposite? (2) Is the output of hostname ever used in resolving hostname to IP address?

– Tim
5 hours ago















(2) ... When set up a local wifi network in your home from an ISP using a router and modem, the machines in the network can be identified by the outputs of their hostname commands, correct? Does the router act like a DNS to resolve the outputs of hostname to private IP addresses in the network?

– Tim
5 hours ago







(2) ... When set up a local wifi network in your home from an ISP using a router and modem, the machines in the network can be identified by the outputs of their hostname commands, correct? Does the router act like a DNS to resolve the outputs of hostname to private IP addresses in the network?

– Tim
5 hours ago















@Tim, (2) uhhuh, I'm not sure. There might be (probably are) systems that automatically discover hosts on the same network, but I'm not too familiar with them. (I know Windows does it, but that doesn't help much.) There would need to be an additional protocol there to communicate the hostnames and IP's and to have them show up as DNS names on the other hosts.

– ilkkachu
5 hours ago







@Tim, (2) uhhuh, I'm not sure. There might be (probably are) systems that automatically discover hosts on the same network, but I'm not too familiar with them. (I know Windows does it, but that doesn't help much.) There would need to be an additional protocol there to communicate the hostnames and IP's and to have them show up as DNS names on the other hosts.

– ilkkachu
5 hours ago















as for (1), there's also reverse lookups that take the IP address and return a name. (For a system with a single name and a single address, you'd want to have both resolve to the other, just for clarity's sake)

– ilkkachu
5 hours ago







as for (1), there's also reverse lookups that take the IP address and return a name. (For a system with a single name and a single address, you'd want to have both resolve to the other, just for clarity's sake)

– ilkkachu
5 hours ago






1




1





Small networks may be using mDNS. For better or worse, it lets system owners choose their own hostnames, accessible by other systems on the local network, without the need to register with a DNS server.

– Mark Plotnick
3 hours ago







Small networks may be using mDNS. For better or worse, it lets system owners choose their own hostnames, accessible by other systems on the local network, without the need to register with a DNS server.

– Mark Plotnick
3 hours ago




















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500050%2fdoes-a-computer-system-linux-only-have-one-host-name%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Liste der Baudenkmale in Friedland (Mecklenburg)

Single-Malt-Whisky

Czorneboh