In this lesson, you'll learn about the name service switch.
The name service switch is in the file etcnsswitch.conf, or better, etcnsswitch.conf, because after
all it's a name service switch.conf.
So it's used to define the order in which hostname resolution should happen.
And it has a content like hosts, files, DNS, myhostname, meaning that it will first check
files, which is etchost, then DNS, then myhostname.
In this file, you can use a couple of items.
And these are files.
Files, in this example, has the highest precedence.
It tries to resolve static hostnames in etchosts first.
And if it matches, it looks no further.
Then there is DNS, which is using DNS as specified in etcresolve.conf.
And in this example, we have myhostname, which is using the local kernel hostname.
Now, there's something funny about it.
And let me show you.
So first, I want to have a look at it, etcnsswitch.conf, where we see what?
Well, we see hosts.
This is the line I'm looking for.
So hosts, files, DNS, myhostname.
You know what that means.
It means that if I'm going to define etchosts, and I'm calling it 192.168.29.11,
no, not dummyexample.com, but let's call it google.com.
And then I'm going to spin to google.com.
And look what happens.
It's spinning 192.168.29.11.
So that is funny.
You might think it's confusing, but some people are using this to make sure that some internet-based
hosts can never be directly accessed.