1
00:00:00,090 --> 00:00:01,680
In this lesson, we're going to cover

2
00:00:01,680 --> 00:00:05,880
the configuration of DHCP and DNS for client services

3
00:00:05,880 --> 00:00:07,860
as well as how these protocols are implemented

4
00:00:07,860 --> 00:00:10,260
on a Linux workstation or server.

5
00:00:10,260 --> 00:00:11,790
Now IP address configuration

6
00:00:11,790 --> 00:00:13,380
is one of the most critical settings

7
00:00:13,380 --> 00:00:15,030
on your network devices.

8
00:00:15,030 --> 00:00:17,790
Workstations, servers, routers, and other components

9
00:00:17,790 --> 00:00:20,430
all have to be properly assigned IP addresses

10
00:00:20,430 --> 00:00:22,560
to be able to participate on the network.

11
00:00:22,560 --> 00:00:25,110
IP address configurations can be set one of two ways,

12
00:00:25,110 --> 00:00:26,400
as I've mentioned before.

13
00:00:26,400 --> 00:00:28,920
You can either do this statically or dynamically.

14
00:00:28,920 --> 00:00:31,890
Now each method has its advantages and disadvantages.

15
00:00:31,890 --> 00:00:34,770
It's important to know when you're going to use each method.

16
00:00:34,770 --> 00:00:37,440
Static IP address configuration means that the settings

17
00:00:37,440 --> 00:00:39,930
are implemented manually by an administrator.

18
00:00:39,930 --> 00:00:42,000
This method increases the risk of mistakes,

19
00:00:42,000 --> 00:00:43,500
but it also ensures that the system

20
00:00:43,500 --> 00:00:45,930
always has the exact same IP address and,

21
00:00:45,930 --> 00:00:48,420
therefore, the same network identity.

22
00:00:48,420 --> 00:00:50,940
Dynamic IP address configuration, on the other hand,

23
00:00:50,940 --> 00:00:52,710
means that the settings on that client

24
00:00:52,710 --> 00:00:54,420
are going to change each time.

25
00:00:54,420 --> 00:00:56,070
Cause every time you boot up the system,

26
00:00:56,070 --> 00:00:58,710
it's going to go to the server, ask for an IP address,

27
00:00:58,710 --> 00:01:01,050
and be given one to use temporarily.

28
00:01:01,050 --> 00:01:03,720
This method does decrease the risk of mistakes,

29
00:01:03,720 --> 00:01:06,120
but it means that system is not always going to have

30
00:01:06,120 --> 00:01:09,150
the same IP address or identity on the network.

31
00:01:09,150 --> 00:01:11,010
Dynamic IP address configurations

32
00:01:11,010 --> 00:01:13,590
are usually going to be appropriate for client machines,

33
00:01:13,590 --> 00:01:14,850
not servers.

34
00:01:14,850 --> 00:01:17,010
Static IPs are normally going to be used

35
00:01:17,010 --> 00:01:19,950
for servers and network print devices.

36
00:01:19,950 --> 00:01:22,380
Now a dynamic host configuration protocol server

37
00:01:22,380 --> 00:01:26,820
or DHCP server contains one or more pools of IP addresses

38
00:01:26,820 --> 00:01:28,410
and related configuration options

39
00:01:28,410 --> 00:01:30,600
that we're going to hand out to our client machines

40
00:01:30,600 --> 00:01:31,830
once they connect.

41
00:01:31,830 --> 00:01:34,530
We call this a lease when we hand it out to them

42
00:01:34,530 --> 00:01:35,790
because we're letting them borrow it

43
00:01:35,790 --> 00:01:37,500
for a given amount of time.

44
00:01:37,500 --> 00:01:38,400
Now, by doing this,

45
00:01:38,400 --> 00:01:41,220
we can save ourself a lot of administrative effort

46
00:01:41,220 --> 00:01:43,080
because this IP address information

47
00:01:43,080 --> 00:01:44,700
doesn't have to be configured statically

48
00:01:44,700 --> 00:01:46,710
on each and every system.

49
00:01:46,710 --> 00:01:48,780
DHCP servers are going to be configured

50
00:01:48,780 --> 00:01:52,050
with a given scope or range of available IP addresses

51
00:01:52,050 --> 00:01:53,850
along with some additional options

52
00:01:53,850 --> 00:01:57,750
like the DNS server's location and the default gateway.

53
00:01:57,750 --> 00:02:00,930
The DHCP service, though, has to be installed on a server

54
00:02:00,930 --> 00:02:03,360
that's going to host this DHCP service

55
00:02:03,360 --> 00:02:04,920
and then allow all the client machines

56
00:02:04,920 --> 00:02:08,039
to lease out those configurations from that server.

57
00:02:08,039 --> 00:02:09,389
These workstations are going to

58
00:02:09,389 --> 00:02:12,960
lease their IP address information from that DHCP server,

59
00:02:12,960 --> 00:02:15,870
and the process really consists of four basic steps

60
00:02:15,870 --> 00:02:17,400
that's initiated by the clients

61
00:02:17,400 --> 00:02:19,860
when they boot up and connect to the network.

62
00:02:19,860 --> 00:02:24,660
These four steps follow the acronym DORA, D-O-R-A.

63
00:02:24,660 --> 00:02:28,980
This stands for discover, offer, request, and acknowledge.

64
00:02:28,980 --> 00:02:30,120
The way this works is that

65
00:02:30,120 --> 00:02:32,190
when the client first connects to the network,

66
00:02:32,190 --> 00:02:35,280
it's going to send out a DHCP discover message.

67
00:02:35,280 --> 00:02:37,290
This is the discover process.

68
00:02:37,290 --> 00:02:38,130
Essentially it says,

69
00:02:38,130 --> 00:02:42,150
hey, is there anybody on this network that's a DHCP server.

70
00:02:42,150 --> 00:02:44,400
If the DHCP server sees that message,

71
00:02:44,400 --> 00:02:46,050
it's going to get that discover message

72
00:02:46,050 --> 00:02:49,440
and then reply with what they call an offer request.

73
00:02:49,440 --> 00:02:51,450
This offer message is going to tell the client,

74
00:02:51,450 --> 00:02:53,220
hey, I'm a DHCP server,

75
00:02:53,220 --> 00:02:56,010
and I'm willing to give you an IP address.

76
00:02:56,010 --> 00:02:57,810
If that client wants to take that offer,

77
00:02:57,810 --> 00:03:01,440
it's going to send back what's called a DHCP request message.

78
00:03:01,440 --> 00:03:04,260
This message is going to say, hey, I'm a client.

79
00:03:04,260 --> 00:03:05,190
You're a server.

80
00:03:05,190 --> 00:03:07,650
I would really like to have one of those IP addresses.

81
00:03:07,650 --> 00:03:09,420
And then the server is going to respond back

82
00:03:09,420 --> 00:03:12,390
with what's called a DHCP acknowledged message.

83
00:03:12,390 --> 00:03:15,330
This message is going to send it back to that client and say,

84
00:03:15,330 --> 00:03:17,820
yes, I understand you want an IP address,

85
00:03:17,820 --> 00:03:19,680
and here is your IP address.

86
00:03:19,680 --> 00:03:22,560
You can have it for the next 24 hours, or seven days,

87
00:03:22,560 --> 00:03:25,530
or 30 days, or whatever that lease time is.

88
00:03:25,530 --> 00:03:28,770
In this message, it's also going to give them their IP address,

89
00:03:28,770 --> 00:03:31,350
their subnet mask, the default gateway,

90
00:03:31,350 --> 00:03:33,630
and the DNS server information.

91
00:03:33,630 --> 00:03:36,510
This is all the information that this client is going to need

92
00:03:36,510 --> 00:03:39,660
to configure itself and be able to connect to the network.

93
00:03:39,660 --> 00:03:42,150
At this point, the client will then configure itself

94
00:03:42,150 --> 00:03:45,120
by taking that IP address and assigning it to its interface,

95
00:03:45,120 --> 00:03:47,040
and connect to the network.

96
00:03:47,040 --> 00:03:48,510
Now, as a system administrator,

97
00:03:48,510 --> 00:03:50,760
it's important to understand where you can configure

98
00:03:50,760 --> 00:03:53,940
your DHCP client on your given Linux system.

99
00:03:53,940 --> 00:03:55,170
To do this, you're going to go

100
00:03:55,170 --> 00:04:00,170
into the /etc/dhcp/dhclient.conf file.

101
00:04:01,860 --> 00:04:05,280
This file enables the configuration of DHCP client settings,

102
00:04:05,280 --> 00:04:08,400
including timeout values, dynamic DNS configurations,

103
00:04:08,400 --> 00:04:10,110
and other things like that.

104
00:04:10,110 --> 00:04:12,450
This file is usually managed and edited

105
00:04:12,450 --> 00:04:14,190
using the network manager.

106
00:04:14,190 --> 00:04:16,500
And this serves as your network configuration service

107
00:04:16,500 --> 00:04:18,300
for all of your different network settings,

108
00:04:18,300 --> 00:04:21,360
including your DHCP client configuration.

109
00:04:21,360 --> 00:04:24,270
Whenever you make changes to the DHCP client configuration

110
00:04:24,270 --> 00:04:25,650
inside the network manager,

111
00:04:25,650 --> 00:04:30,650
it's going to update the /etc/dhcp/dhclient.conf file for you.

112
00:04:32,490 --> 00:04:34,410
I recommend you use the network manager,

113
00:04:34,410 --> 00:04:36,000
either in the command line environment,

114
00:04:36,000 --> 00:04:39,030
the text user interface, or the graphical user interface,

115
00:04:39,030 --> 00:04:42,180
to be able to edit this dhclient.config file

116
00:04:42,180 --> 00:04:45,270
because otherwise, you're likely to make mistakes.

117
00:04:45,270 --> 00:04:49,320
Next, let's talk a little bit about DNS and name resolution.

118
00:04:49,320 --> 00:04:52,380
You might remember that TCP/IP data packets

119
00:04:52,380 --> 00:04:55,890
always need to have a source IP and a destination IP.

120
00:04:55,890 --> 00:04:57,450
So if I want to send something to you

121
00:04:57,450 --> 00:04:59,220
or you want to visit my website,

122
00:04:59,220 --> 00:05:01,320
you would need to know its IP address.

123
00:05:01,320 --> 00:05:03,930
Now the problem is we humans are not very good

124
00:05:03,930 --> 00:05:06,930
at remembering lots of different long series of numbers.

125
00:05:06,930 --> 00:05:08,940
So if I had remember the IP address

126
00:05:08,940 --> 00:05:11,010
for every website I wanted to go to,

127
00:05:11,010 --> 00:05:13,230
that would just be a total pain,

128
00:05:13,230 --> 00:05:15,870
and it would make going on the internet not very fun.

129
00:05:15,870 --> 00:05:17,610
Therefore, there's a system created

130
00:05:17,610 --> 00:05:20,640
called DNS or domain name system.

131
00:05:20,640 --> 00:05:23,010
This allows us to type in user-friendly names

132
00:05:23,010 --> 00:05:24,660
like diontraining.com,

133
00:05:24,660 --> 00:05:26,790
and that gets converted to the IP address

134
00:05:26,790 --> 00:05:28,920
and routes our computer over there.

135
00:05:28,920 --> 00:05:30,570
To set this up on your system,

136
00:05:30,570 --> 00:05:33,360
you need to configure your DNS file.

137
00:05:33,360 --> 00:05:35,790
Now to do this, there is really two methods

138
00:05:35,790 --> 00:05:38,970
to be able to do this names to numbers association.

139
00:05:38,970 --> 00:05:41,070
The first way is the original way it was done

140
00:05:41,070 --> 00:05:43,950
on the internet when the internet was a much smaller place.

141
00:05:43,950 --> 00:05:45,930
And it was where there was a static text file

142
00:05:45,930 --> 00:05:48,150
with all of these links inside of it.

143
00:05:48,150 --> 00:05:51,420
This is called the /etc/hosts file.

144
00:05:51,420 --> 00:05:52,890
If you go into your Linux system

145
00:05:52,890 --> 00:05:57,890
and do cat space /etc/hosts, you'll be able to see

146
00:05:58,200 --> 00:06:01,110
if there's anything in your etc/hosts file.

147
00:06:01,110 --> 00:06:02,730
If you want to have some kind of a link

148
00:06:02,730 --> 00:06:04,890
that overrides everything else on your system

149
00:06:04,890 --> 00:06:08,760
in terms of names, you can put it in the etc/hosts file.

150
00:06:08,760 --> 00:06:10,500
For example, one of my kids

151
00:06:10,500 --> 00:06:12,420
was not doing his homework one night,

152
00:06:12,420 --> 00:06:13,950
and he kept going on YouTube.

153
00:06:13,950 --> 00:06:15,210
So I went into his computer.

154
00:06:15,210 --> 00:06:19,500
I edited his etc/hosts file and added youtube.com,

155
00:06:19,500 --> 00:06:22,860
and redirected it to the IP address of his school's website.

156
00:06:22,860 --> 00:06:24,390
So every time he tried to go to YouTube,

157
00:06:24,390 --> 00:06:26,010
it just pushed him right over

158
00:06:26,010 --> 00:06:27,600
to his school's website instead

159
00:06:27,600 --> 00:06:29,190
because your system is always

160
00:06:29,190 --> 00:06:31,740
going to check the etc/hosts file first

161
00:06:31,740 --> 00:06:33,630
before it goes to the second method,

162
00:06:33,630 --> 00:06:37,050
which is that dynamic database known as DNS.

163
00:06:37,050 --> 00:06:39,510
As I said, in the old days name resolution

164
00:06:39,510 --> 00:06:42,180
can be managed using a single static text file.

165
00:06:42,180 --> 00:06:44,970
And we could just add the different names and numbers in it,

166
00:06:44,970 --> 00:06:45,990
like a phone book.

167
00:06:45,990 --> 00:06:48,570
And we could then go to all the websites we wanted to.

168
00:06:48,570 --> 00:06:50,730
When the internet only had 50 or 100

169
00:06:50,730 --> 00:06:53,610
or a couple of thousand computers, that was manageable.

170
00:06:53,610 --> 00:06:55,830
But today, there are millions and millions of websites

171
00:06:55,830 --> 00:06:57,360
so there's just no way to keep up

172
00:06:57,360 --> 00:06:59,610
with all of the IP address changes, additions,

173
00:06:59,610 --> 00:07:01,230
and deletions that may happen.

174
00:07:01,230 --> 00:07:04,650
So we have to use this dynamic system of DNS instead.

175
00:07:04,650 --> 00:07:07,380
So to use DNS, the way our clients work

176
00:07:07,380 --> 00:07:09,810
is they're going to reach out to a DNS server and say,

177
00:07:09,810 --> 00:07:13,620
I would like to go to this hostname, like diontraining.com.

178
00:07:13,620 --> 00:07:15,780
And then the DNS server will look it up and say,

179
00:07:15,780 --> 00:07:18,090
I know where that is, it's this IP address,

180
00:07:18,090 --> 00:07:20,430
and hand you back the IP address in the background,

181
00:07:20,430 --> 00:07:22,710
and your computer then goes over to that IP address.

182
00:07:22,710 --> 00:07:24,930
That's all DNS does in the background

183
00:07:24,930 --> 00:07:28,350
to resolve a name and give you an IP address in return.

184
00:07:28,350 --> 00:07:30,960
This DNS server contains the resource records

185
00:07:30,960 --> 00:07:33,570
that provides all the answers to these different queries

186
00:07:33,570 --> 00:07:37,170
because diontraining.com isn't just one IP address.

187
00:07:37,170 --> 00:07:39,060
We actually have multiple IP addresses

188
00:07:39,060 --> 00:07:42,660
associated with that name, including our email server,

189
00:07:42,660 --> 00:07:46,110
our web server, our FTP server, and things like that.

190
00:07:46,110 --> 00:07:49,170
So we have to have all these records in a DNS server

191
00:07:49,170 --> 00:07:50,640
that we share with the rest of the world.

192
00:07:50,640 --> 00:07:53,610
And that way, they can know where to find our services.

193
00:07:53,610 --> 00:07:57,150
Now, how does your client know which DNS server to look at?

194
00:07:57,150 --> 00:08:02,150
Well, it does this by looking in the /etc/resolv.conf file.

195
00:08:04,380 --> 00:08:08,340
This is known as the /etc/resolve.config file,

196
00:08:08,340 --> 00:08:10,620
and it's stored locally on each Linux system.

197
00:08:10,620 --> 00:08:12,450
And it tells your system the IP address

198
00:08:12,450 --> 00:08:14,640
of one or more DNS servers.

199
00:08:14,640 --> 00:08:17,040
Now because DNS is so important,

200
00:08:17,040 --> 00:08:18,750
it's really a good idea to have at least

201
00:08:18,750 --> 00:08:23,750
two DNS servers listed inside your /etc/resolv.config file.

202
00:08:24,540 --> 00:08:26,730
Now another place you're going to configure DNS

203
00:08:26,730 --> 00:08:31,730
is inside the /etc/nsswitch.conf file.

204
00:08:32,100 --> 00:08:34,350
This includes a couple of different configuration options

205
00:08:34,350 --> 00:08:35,610
you should be aware of.

206
00:08:35,610 --> 00:08:37,530
For example, there's an option in here

207
00:08:37,530 --> 00:08:40,140
related to name resolution that defines the order

208
00:08:40,140 --> 00:08:41,730
in which name resolution methods

209
00:08:41,730 --> 00:08:43,860
are going to be used on your system.

210
00:08:43,860 --> 00:08:48,210
So should you go to etc/hosts first, then DNS?

211
00:08:48,210 --> 00:08:52,560
Or should you go to DNS first and then /etc/hosts?

212
00:08:52,560 --> 00:08:53,640
Whichever one it is,

213
00:08:53,640 --> 00:08:57,510
you need to configure that inside your nsswitch.config file.

214
00:08:57,510 --> 00:08:59,910
I will tell you, as a matter of best practice,

215
00:08:59,910 --> 00:09:04,140
you should go to /etc/hosts first and then go to your DNS,

216
00:09:04,140 --> 00:09:06,990
which is the dynamic method as your second option.

217
00:09:06,990 --> 00:09:09,210
This is how your system is configured by default.

218
00:09:09,210 --> 00:09:10,560
But if you'd like to change it,

219
00:09:10,560 --> 00:09:15,510
you can do that inside the /etc/nsswitch.config file.

220
00:09:15,510 --> 00:09:17,970
Now to set up your different DNS configurations,

221
00:09:17,970 --> 00:09:19,830
you can manually edit these files,

222
00:09:19,830 --> 00:09:21,750
or you could take the easy way out

223
00:09:21,750 --> 00:09:23,760
and use the network manager tool.

224
00:09:23,760 --> 00:09:25,740
Remember, there's a command line version,

225
00:09:25,740 --> 00:09:28,920
a text-based version, and a graphical user interface version

226
00:09:28,920 --> 00:09:31,380
that you can use to easily configure the IP address

227
00:09:31,380 --> 00:09:34,530
of your DNS servers that you want your client to use.

228
00:09:34,530 --> 00:09:35,940
Now, the last thing I want to talk about

229
00:09:35,940 --> 00:09:37,560
is a couple of command line tools

230
00:09:37,560 --> 00:09:41,070
that you should be aware of to interact with the DNS system.

231
00:09:41,070 --> 00:09:43,470
For example, if you wanted to find out right now

232
00:09:43,470 --> 00:09:46,350
what the IP address is for diontraining.com,

233
00:09:46,350 --> 00:09:48,420
you can do that using your Linux system.

234
00:09:48,420 --> 00:09:49,890
Simply open up your terminal,

235
00:09:49,890 --> 00:09:53,040
type in dig space diontraining.com,

236
00:09:53,040 --> 00:09:56,610
and it's going to return the IP address of diontraining.com.

237
00:09:56,610 --> 00:09:59,430
Dig is one of the ways that you can look up information

238
00:09:59,430 --> 00:10:02,010
on DNS and get that value back.

239
00:10:02,010 --> 00:10:03,660
Another way to get information

240
00:10:03,660 --> 00:10:05,850
is to use a tool called nslookup.

241
00:10:05,850 --> 00:10:08,760
Now, nslookup stands for name server lookup,

242
00:10:08,760 --> 00:10:09,810
and this will allow you to go

243
00:10:09,810 --> 00:10:12,050
and interact with a DNS name server

244
00:10:12,050 --> 00:10:13,980
to be able to get information back.

245
00:10:13,980 --> 00:10:16,500
For example, you might want to use nslookup

246
00:10:16,500 --> 00:10:18,810
to be able to go and look at the DNS records

247
00:10:18,810 --> 00:10:20,730
that are associated with my MX records,

248
00:10:20,730 --> 00:10:23,580
which are mail server records for diontraining.com,

249
00:10:23,580 --> 00:10:27,180
and figure out who am I using as an email service provider.

250
00:10:27,180 --> 00:10:29,220
Another thing you can use is host.

251
00:10:29,220 --> 00:10:31,680
Host is another DNS query tool,

252
00:10:31,680 --> 00:10:34,650
and it does the same type of thing as dig and nslookup,

253
00:10:34,650 --> 00:10:37,380
where you can query a DNS server and get the records back

254
00:10:37,380 --> 00:10:39,750
and look at the IP addresses and the names associated

255
00:10:39,750 --> 00:10:41,730
with each of those different records.

256
00:10:41,730 --> 00:10:44,610
Now, the final tool I want to talk about is whois.

257
00:10:44,610 --> 00:10:46,650
Whois is a command line utility

258
00:10:46,650 --> 00:10:49,260
that's going to allow you to communicate with a whois server,

259
00:10:49,260 --> 00:10:52,350
which actually hosts information about people

260
00:10:52,350 --> 00:10:54,270
who own different domain names.

261
00:10:54,270 --> 00:10:57,420
So if you want to find out who owns diontraining.com

262
00:10:57,420 --> 00:10:59,280
and what our contact information is,

263
00:10:59,280 --> 00:11:01,860
what our mailing address is, and things like that,

264
00:11:01,860 --> 00:11:03,780
that's what whois is used for.

265
00:11:03,780 --> 00:11:07,290
You could type in whois then the name diontraining.com

266
00:11:07,290 --> 00:11:08,970
and it will come back with all the information

267
00:11:08,970 --> 00:11:12,090
that we used to register that with the domain authorities

268
00:11:12,090 --> 00:11:13,980
when we bought that domain.

269
00:11:13,980 --> 00:11:16,020
As you can see, there's lots of different things

270
00:11:16,020 --> 00:11:19,680
you should be aware of when it comes to DHCP and DNS.

271
00:11:19,680 --> 00:11:21,690
Remember, you can configure both of these

272
00:11:21,690 --> 00:11:24,810
on your client using the network manager tool.

273
00:11:24,810 --> 00:11:28,170
When it comes to DHCP, you want to use DHCP assignments

274
00:11:28,170 --> 00:11:29,490
when you're dealing with clients,

275
00:11:29,490 --> 00:11:31,350
but you still want to statically assign things

276
00:11:31,350 --> 00:11:32,970
when you're dealing with servers.

277
00:11:32,970 --> 00:11:34,980
When it comes to DNS, remember,

278
00:11:34,980 --> 00:11:37,050
you can interact with the DNS servers

279
00:11:37,050 --> 00:11:40,500
and get information using dig, nslookup, or host.

280
00:11:40,500 --> 00:11:41,520
If you want to find that information

281
00:11:41,520 --> 00:11:44,583
about who owns that domain, you can use the whois command.

