1
00:00:00,000 --> 00:00:10,200
In this lesson, you'll learn about the name service switch.

2
00:00:10,200 --> 00:00:18,959
The name service switch is in the file etcnsswitch.conf, or better, etcnsswitch.conf, because after

3
00:00:18,959 --> 00:00:23,120
all it's a name service switch.conf.

4
00:00:23,120 --> 00:00:28,240
So it's used to define the order in which hostname resolution should happen.

5
00:00:28,240 --> 00:00:33,560
And it has a content like hosts, files, DNS, myhostname, meaning that it will first check

6
00:00:33,560 --> 00:00:38,759
files, which is etchost, then DNS, then myhostname.

7
00:00:38,759 --> 00:00:41,360
In this file, you can use a couple of items.

8
00:00:41,360 --> 00:00:42,360
And these are files.

9
00:00:42,360 --> 00:00:45,599
Files, in this example, has the highest precedence.

10
00:00:45,599 --> 00:00:49,919
It tries to resolve static hostnames in etchosts first.

11
00:00:49,919 --> 00:00:52,400
And if it matches, it looks no further.

12
00:00:52,400 --> 00:00:57,840
Then there is DNS, which is using DNS as specified in etcresolve.conf.

13
00:00:57,840 --> 00:01:02,439
And in this example, we have myhostname, which is using the local kernel hostname.

14
00:01:02,439 --> 00:01:04,639
Now, there's something funny about it.

15
00:01:04,639 --> 00:01:07,080
And let me show you.

16
00:01:07,080 --> 00:01:15,720
So first, I want to have a look at it, etcnsswitch.conf, where we see what?

17
00:01:15,720 --> 00:01:18,239
Well, we see hosts.

18
00:01:18,239 --> 00:01:20,120
This is the line I'm looking for.

19
00:01:20,120 --> 00:01:24,279
So hosts, files, DNS, myhostname.

20
00:01:24,279 --> 00:01:25,680
You know what that means.

21
00:01:25,680 --> 00:01:35,000
It means that if I'm going to define etchosts, and I'm calling it 192.168.29.11,

22
00:01:35,000 --> 00:01:42,879
no, not dummyexample.com, but let's call it google.com.

23
00:01:42,879 --> 00:01:46,879
And then I'm going to spin to google.com.

24
00:01:46,879 --> 00:01:47,800
And look what happens.

25
00:01:47,800 --> 00:01:51,680
It's spinning 192.168.29.11.

26
00:01:51,680 --> 00:01:54,000
So that is funny.

27
00:01:54,000 --> 00:01:59,720
You might think it's confusing, but some people are using this to make sure that some internet-based

28
00:01:59,720 --> 00:02:01,879
hosts can never be directly accessed.

