1
00:00:00,050 --> 00:00:00,930
In this lesson,

2
00:00:00,930 --> 00:00:03,270
we're going to talk about how you can connect a Linux system

3
00:00:03,270 --> 00:00:05,400
to a home or office network.

4
00:00:05,400 --> 00:00:06,450
Now, computers are connected

5
00:00:06,450 --> 00:00:09,030
to a network to exchange information or resources

6
00:00:09,030 --> 00:00:10,260
to each other.

7
00:00:10,260 --> 00:00:11,760
Two or more computers that are connected

8
00:00:11,760 --> 00:00:14,550
through network media are called a computer network

9
00:00:14,550 --> 00:00:17,310
and there are a number of different network devices or media

10
00:00:17,310 --> 00:00:19,920
that are going to be involved to form a computer network.

11
00:00:19,920 --> 00:00:22,200
A computer that's loaded with the Linux operating system

12
00:00:22,200 --> 00:00:23,790
can also be part of a network,

13
00:00:23,790 --> 00:00:25,830
whether it's a small or large network

14
00:00:25,830 --> 00:00:28,440
by using multitasking and multi-user natures

15
00:00:28,440 --> 00:00:30,300
of the Linux operating system.

16
00:00:30,300 --> 00:00:33,060
It's your job as a system or network administrator

17
00:00:33,060 --> 00:00:34,770
to maintain your system and network

18
00:00:34,770 --> 00:00:36,930
and ensure it's up and running at all times.

19
00:00:36,930 --> 00:00:38,640
So in this video, we're going to review

20
00:00:38,640 --> 00:00:40,800
some frequently used network configurations,

21
00:00:40,800 --> 00:00:43,530
and also learn how you can troubleshoot things in Linux

22
00:00:43,530 --> 00:00:45,240
using network commands.

23
00:00:45,240 --> 00:00:48,690
Now in Linux, we're going to use a device or system hostname

24
00:00:48,690 --> 00:00:51,270
to easily recognize the machine within the network,

25
00:00:51,270 --> 00:00:53,250
using a human readable format.

26
00:00:53,250 --> 00:00:56,700
For example, I might call my computer Jason's computer

27
00:00:56,700 --> 00:00:59,490
or DNS server or something like that.

28
00:00:59,490 --> 00:01:01,710
That is a human readable format and a hostname

29
00:01:01,710 --> 00:01:03,093
that's easy to understand.

30
00:01:03,093 --> 00:01:06,390
These hostnames can be set up by using a simple command

31
00:01:06,390 --> 00:01:09,030
known as hostnamectl.

32
00:01:09,030 --> 00:01:14,030
To use it, simply type in hostnamectl set-hostname

33
00:01:14,285 --> 00:01:16,890
and then the hostname you want to use.

34
00:01:16,890 --> 00:01:19,320
For a computer to be able to participate on a network,

35
00:01:19,320 --> 00:01:21,180
it has to have a valid identity.

36
00:01:21,180 --> 00:01:24,150
And this means, it has to have a MAC address an IP address,

37
00:01:24,150 --> 00:01:25,500
and a hostname.

38
00:01:25,500 --> 00:01:28,140
IP addresses are going to be configured on your system

39
00:01:28,140 --> 00:01:30,960
using either static or dynamic configurations.

40
00:01:30,960 --> 00:01:32,430
If you do it statically,

41
00:01:32,430 --> 00:01:35,400
you have to set the IP address, the subnet mask,

42
00:01:35,400 --> 00:01:38,040
the location of the default gateway, which is the router

43
00:01:38,040 --> 00:01:40,500
and the location of one or more DNS servers,

44
00:01:40,500 --> 00:01:43,620
so your machine can convert names into numbers.

45
00:01:43,620 --> 00:01:45,720
Now, if you don't want to do all this statically

46
00:01:45,720 --> 00:01:47,970
and there's a DHCP server on your network,

47
00:01:47,970 --> 00:01:50,160
you can simply use dynamic assignments,

48
00:01:50,160 --> 00:01:53,280
and that way, your machine can reach out to the DHTP server

49
00:01:53,280 --> 00:01:56,730
and configure itself with these four pieces of information.

50
00:01:56,730 --> 00:01:58,770
Anytime you have an error or misconfiguration

51
00:01:58,770 --> 00:02:00,660
in any one of these four values,

52
00:02:00,660 --> 00:02:01,710
it means your system

53
00:02:01,710 --> 00:02:04,950
is not going to be able to operate properly on that network.

54
00:02:04,950 --> 00:02:07,890
For example, if you forget to include the DNS server's

55
00:02:07,890 --> 00:02:09,539
IP address in your configuration

56
00:02:09,539 --> 00:02:11,340
on your workstation or server,

57
00:02:11,340 --> 00:02:13,290
this means you're not going to be able to look up things

58
00:02:13,290 --> 00:02:14,970
like diontraining.com,

59
00:02:14,970 --> 00:02:17,190
and you'll only be able to access that web server

60
00:02:17,190 --> 00:02:19,800
if you know its exact IP address.

61
00:02:19,800 --> 00:02:21,390
Now, most Linux distributions,

62
00:02:21,390 --> 00:02:23,390
include a utility called Network Manager,

63
00:02:23,390 --> 00:02:25,890
that helps you set up the proper configuration

64
00:02:25,890 --> 00:02:29,190
for all this data that you need for your network devices.

65
00:02:29,190 --> 00:02:31,650
Network Manager includes three different interfaces

66
00:02:31,650 --> 00:02:33,600
that you can use depending on whether or not

67
00:02:33,600 --> 00:02:35,610
you have a graphical user interface available

68
00:02:35,610 --> 00:02:37,800
on your particular Linux system.

69
00:02:37,800 --> 00:02:40,350
Now, the most fundamental version of Network Manager

70
00:02:40,350 --> 00:02:43,260
is going to be known as nmcli.

71
00:02:43,260 --> 00:02:45,330
This is a command line interface tool

72
00:02:45,330 --> 00:02:46,950
for the Network Manager.

73
00:02:46,950 --> 00:02:49,080
The nmcli tool is going to contain

74
00:02:49,080 --> 00:02:51,000
lots of different sub-commands as well,

75
00:02:51,000 --> 00:02:53,310
that'll enable you to view and configure different pieces

76
00:02:53,310 --> 00:02:54,930
of network information.

77
00:02:54,930 --> 00:02:57,300
Now, many times when you're working with a Linux server,

78
00:02:57,300 --> 00:02:59,820
it's not going to have a graphical user interface.

79
00:02:59,820 --> 00:03:01,936
So it's really important for you to get comfortable

80
00:03:01,936 --> 00:03:05,790
using nmcli to manage your network settings.

81
00:03:05,790 --> 00:03:08,370
Like I said, there's lots of different sub-commands

82
00:03:08,370 --> 00:03:10,740
underneath the nmcli tool.

83
00:03:10,740 --> 00:03:12,990
This includes the general status sub-command

84
00:03:12,990 --> 00:03:14,250
which is used to view a summary

85
00:03:14,250 --> 00:03:16,200
of your network connectivity data.

86
00:03:16,200 --> 00:03:18,060
The connection show sub-command,

87
00:03:18,060 --> 00:03:19,887
which is used to view identification information

88
00:03:19,887 --> 00:03:22,350
for each Network Interface Card.

89
00:03:22,350 --> 00:03:24,570
The con up device ID sub-command,

90
00:03:24,570 --> 00:03:26,370
which is used to enable the specified NIC

91
00:03:26,370 --> 00:03:28,590
and put it into an on position.

92
00:03:28,590 --> 00:03:30,870
The con down device ID sub-command

93
00:03:30,870 --> 00:03:33,390
is going to be used to disable that specified NIC.

94
00:03:33,390 --> 00:03:35,880
The con edit device ID will allow you to enter

95
00:03:35,880 --> 00:03:37,080
an interactive mode

96
00:03:37,080 --> 00:03:39,030
where you can configure the specified NIC

97
00:03:39,030 --> 00:03:41,520
and give it information about its characteristics.

98
00:03:41,520 --> 00:03:43,560
And the device status sub-command

99
00:03:43,560 --> 00:03:45,570
is going to be used to display the current status

100
00:03:45,570 --> 00:03:47,880
of each NIC connected in your system.

101
00:03:47,880 --> 00:03:52,290
To run this command, simply use nmcli, the options,

102
00:03:52,290 --> 00:03:55,530
the sub-command and the arguments you want to use.

103
00:03:55,530 --> 00:03:58,590
While Linux administrators often work at the command line,

104
00:03:58,590 --> 00:04:01,290
it's also useful for you to have a visual representation

105
00:04:01,290 --> 00:04:03,090
of network configuration options

106
00:04:03,090 --> 00:04:06,550
and you can do that using nmtui.

107
00:04:06,550 --> 00:04:08,970
nmtui is a command that will call up

108
00:04:08,970 --> 00:04:10,800
a Text-based User Interface

109
00:04:10,800 --> 00:04:14,460
or TUI, Text-based User Interface.

110
00:04:14,460 --> 00:04:17,040
By navigating a Text-based User Interface,

111
00:04:17,040 --> 00:04:19,740
you can use things like the Tab key, the Space bar

112
00:04:19,740 --> 00:04:20,572
and the Enter key

113
00:04:20,572 --> 00:04:23,580
as well as the Arrow keys to navigate through it.

114
00:04:23,580 --> 00:04:24,660
By using the Tab key

115
00:04:24,660 --> 00:04:27,030
you can move your cursor from field to field.

116
00:04:27,030 --> 00:04:29,160
The Arrow keys are going to be used to make selections

117
00:04:29,160 --> 00:04:30,300
within the field.

118
00:04:30,300 --> 00:04:32,160
And the Enter key will activate a setting

119
00:04:32,160 --> 00:04:34,290
such as OK, or Quit.

120
00:04:34,290 --> 00:04:36,750
Your Space bar will be used to check or uncheck

121
00:04:36,750 --> 00:04:40,020
certain check boxes inside of this user interface.

122
00:04:40,020 --> 00:04:42,360
Now, if you have a graphical user environment

123
00:04:42,360 --> 00:04:44,070
you can also launch the Network Manager

124
00:04:44,070 --> 00:04:47,190
inside of a graphical user environment-based tool.

125
00:04:47,190 --> 00:04:49,590
This is really helpful for managing your network connections

126
00:04:49,590 --> 00:04:51,180
on end user workstations

127
00:04:51,180 --> 00:04:53,190
that might be running something like Ubuntu

128
00:04:53,190 --> 00:04:56,460
or one of the other more graphical-based user distributions.

129
00:04:56,460 --> 00:04:59,820
To launch this, simply type in nmgui,

130
00:04:59,820 --> 00:05:02,340
and this will allow that graphical user tool to come up

131
00:05:02,340 --> 00:05:03,360
and then you'll be able to enable

132
00:05:03,360 --> 00:05:06,150
IPv4 or IPv6 configurations

133
00:05:06,150 --> 00:05:08,400
inside the graphical user environment.

134
00:05:08,400 --> 00:05:10,230
From this tool, you'll have access to all

135
00:05:10,230 --> 00:05:11,250
of your network settings

136
00:05:11,250 --> 00:05:13,834
from the comfort of the graphical user environment.

137
00:05:13,834 --> 00:05:16,980
Now, if you're having problems with your network connection

138
00:05:16,980 --> 00:05:18,780
the first thing you need to do to troubleshoot it

139
00:05:18,780 --> 00:05:20,910
is to view your IP address.

140
00:05:20,910 --> 00:05:22,440
You can do this from the command line

141
00:05:22,440 --> 00:05:24,660
using the ifconfig command.

142
00:05:24,660 --> 00:05:27,660
The ifconfig command is going to show the IP address

143
00:05:27,660 --> 00:05:31,140
the subnet mask, the broadcast ID, the MAC address,

144
00:05:31,140 --> 00:05:34,440
the basic performance information and your NIC's name.

145
00:05:34,440 --> 00:05:36,270
This tool will also enable your NIC

146
00:05:36,270 --> 00:05:37,103
and allow it to be placed

147
00:05:37,103 --> 00:05:39,540
in an up or down configuration state.

148
00:05:39,540 --> 00:05:43,350
To use it, simply type ifconfig and then options

149
00:05:43,350 --> 00:05:45,030
and then the interface you want to use

150
00:05:45,030 --> 00:05:48,360
like eth0 for ethernet zero.

151
00:05:48,360 --> 00:05:51,870
Because the ifconfig command is now officially deprecated,

152
00:05:51,870 --> 00:05:52,830
it's actually been replaced

153
00:05:52,830 --> 00:05:55,200
by something known as the IP command.

154
00:05:55,200 --> 00:05:56,700
Now in lots of distributions,

155
00:05:56,700 --> 00:06:00,330
you'll still find both the IP command and ifconfig

156
00:06:00,330 --> 00:06:01,560
and old-timers like me,

157
00:06:01,560 --> 00:06:04,560
we still tend to use ifconfig, just 'cause we're used to it,

158
00:06:04,560 --> 00:06:07,620
but the IP command has officially replaced it,

159
00:06:07,620 --> 00:06:10,530
and it is what you're going to find on most distributions.

160
00:06:10,530 --> 00:06:14,070
Now IP is going to give you similar information to ipconfig.

161
00:06:14,070 --> 00:06:16,770
This includes the IP address, the subnet mask

162
00:06:16,770 --> 00:06:19,440
the MAC address and all those other things I described.

163
00:06:19,440 --> 00:06:22,950
But the IP command is actually much more powerful.

164
00:06:22,950 --> 00:06:25,080
The IP command is really going to be the first tool

165
00:06:25,080 --> 00:06:25,913
you're going to use

166
00:06:25,913 --> 00:06:28,650
in any network troubleshooting on a Linux system.

167
00:06:28,650 --> 00:06:31,224
The IP command uses a lot of sub-commands as well.

168
00:06:31,224 --> 00:06:35,040
For example, you can type ip adder show

169
00:06:35,040 --> 00:06:37,110
and this will show the IP address information

170
00:06:37,110 --> 00:06:38,760
for all of your interfaces.

171
00:06:38,760 --> 00:06:40,800
If you type in ip link,

172
00:06:40,800 --> 00:06:43,200
this is going to show the status of each interface.

173
00:06:43,200 --> 00:06:46,890
If you used ip link set eth1 up,

174
00:06:46,890 --> 00:06:49,170
this would enable the interface eth1

175
00:06:49,170 --> 00:06:52,290
into the upstate and allow communication to begin.

176
00:06:52,290 --> 00:06:55,530
If you use ip link set eth1 down,

177
00:06:55,530 --> 00:06:57,210
this will actually disable that interface

178
00:06:57,210 --> 00:06:58,980
that was identified as eth1,

179
00:06:58,980 --> 00:07:01,050
so you can do other configurations to it.

180
00:07:01,050 --> 00:07:03,870
Like I said, there's a lot inside of the IP command.

181
00:07:03,870 --> 00:07:06,000
And so, if you look through the man page for IP

182
00:07:06,000 --> 00:07:07,140
you're going to get much more comfortable

183
00:07:07,140 --> 00:07:09,720
with all the different options based on what you need to do

184
00:07:09,720 --> 00:07:11,160
at a given time.

185
00:07:11,160 --> 00:07:13,470
To use the basic structure of the IP command,

186
00:07:13,470 --> 00:07:15,840
you're going to type ip, the options,

187
00:07:15,840 --> 00:07:17,550
the object you want to interface with

188
00:07:17,550 --> 00:07:19,502
and the sub-command to interact with it.

189
00:07:19,502 --> 00:07:21,480
Now, the last one we need to talk about

190
00:07:21,480 --> 00:07:23,700
is known as iwconfig.

191
00:07:23,700 --> 00:07:26,160
The iwconfig command is used to provide

192
00:07:26,160 --> 00:07:28,950
wireless network interface card configurations.

193
00:07:28,950 --> 00:07:30,780
So it works a lot like ifconfig,

194
00:07:30,780 --> 00:07:34,290
but it only works for wireless network cards.

195
00:07:34,290 --> 00:07:36,030
By using iwconfig,

196
00:07:36,030 --> 00:07:38,340
you can configure things like the SSID,

197
00:07:38,340 --> 00:07:39,510
the encryption information

198
00:07:39,510 --> 00:07:42,900
and other things that are specific to a wireless connection.

199
00:07:42,900 --> 00:07:47,400
To run iwconfig, simply type in iwconfig, the options

200
00:07:47,400 --> 00:07:49,170
and the interface you want to interact with,

201
00:07:49,170 --> 00:07:53,160
such as wlan0 for wireless LAN0.

202
00:07:53,160 --> 00:07:54,840
Some common sub-command options here

203
00:07:54,840 --> 00:07:57,150
would be things like nick and a name.

204
00:07:57,150 --> 00:07:58,680
By adding nick and a name,

205
00:07:58,680 --> 00:08:00,060
it will let you give a nickname

206
00:08:00,060 --> 00:08:02,190
to your Network Interface Card.

207
00:08:02,190 --> 00:08:03,900
Or mode and a mode.

208
00:08:03,900 --> 00:08:06,000
This option is used to set the operating mode

209
00:08:06,000 --> 00:08:07,770
for that Network Interface Card,

210
00:08:07,770 --> 00:08:09,930
based on the networking topology you're using.

211
00:08:09,930 --> 00:08:11,760
Or freq and a number.

212
00:08:11,760 --> 00:08:14,040
This option is used to set the wifi frequency

213
00:08:14,040 --> 00:08:16,320
that's going to be used by your wireless card.

214
00:08:16,320 --> 00:08:17,790
Channel and a number.

215
00:08:17,790 --> 00:08:19,530
This is used to set the wifi channel

216
00:08:19,530 --> 00:08:21,510
that's going to be used by your wireless card.

217
00:08:21,510 --> 00:08:23,280
And retry and a number.

218
00:08:23,280 --> 00:08:25,380
This option is used to set the maximum number

219
00:08:25,380 --> 00:08:27,710
of MAC retransmissions for the NIC.

220
00:08:27,710 --> 00:08:29,190
Now, it's important to realize

221
00:08:29,190 --> 00:08:31,200
that when you're using the Network Manager,

222
00:08:31,200 --> 00:08:34,020
this will actually save your settings into a file,

223
00:08:34,020 --> 00:08:36,539
they'll get loaded up the next time the system boots,

224
00:08:36,539 --> 00:08:40,289
but some of the other commands like ifconfig, iwconfig,

225
00:08:40,289 --> 00:08:42,900
ip and things like that will only operate

226
00:08:42,900 --> 00:08:44,910
while the computer is already booted

227
00:08:44,910 --> 00:08:46,680
and it won't save those settings.

228
00:08:46,680 --> 00:08:49,380
So if you have a configuration that you want to be applied

229
00:08:49,380 --> 00:08:51,870
every single time you're going to boot up the system,

230
00:08:51,870 --> 00:08:54,570
you can actually go in and manually edit the files

231
00:08:54,570 --> 00:08:59,570
inside the /etc/sysconfig/network-scripts directory.

232
00:09:00,210 --> 00:09:03,150
Under that directory, you'll find a listing of files

233
00:09:03,150 --> 00:09:08,130
called ifcfg- and then some sort of identifier.

234
00:09:08,130 --> 00:09:10,470
For example, here you can see that I have a file

235
00:09:10,470 --> 00:09:12,300
that I've concatenated to the screen,

236
00:09:12,300 --> 00:09:14,160
and you'll see the different contents of this file

237
00:09:14,160 --> 00:09:16,740
including the fact that this is of TYPE-Ethernet.

238
00:09:16,740 --> 00:09:18,990
The fact that we're not using BOOTPROTO.

239
00:09:18,990 --> 00:09:21,870
Now BOOTPROTO actually stands for boot protocol.

240
00:09:21,870 --> 00:09:23,370
So since this is set as none

241
00:09:23,370 --> 00:09:25,410
this means this is a static assignment.

242
00:09:25,410 --> 00:09:27,930
I want this particular machine which is a server

243
00:09:27,930 --> 00:09:30,090
to always have the same IP address.

244
00:09:30,090 --> 00:09:31,320
As you go lower down,

245
00:09:31,320 --> 00:09:33,720
you'll see the name of this is eth0,

246
00:09:33,720 --> 00:09:35,520
and that's why I want this Network Interface Card

247
00:09:35,520 --> 00:09:37,873
to be referred to as by the operating system.

248
00:09:37,873 --> 00:09:39,900
You see ONBOOT=yes.

249
00:09:39,900 --> 00:09:42,720
This means when I boot up, I want this script to run.

250
00:09:42,720 --> 00:09:44,310
And then you see a HWADDR,

251
00:09:44,310 --> 00:09:47,040
that is the MAC address for this network interface card.

252
00:09:47,040 --> 00:09:50,263
Then I have IPADDR0=192.168.1.10.

253
00:09:52,500 --> 00:09:54,660
This is the first of the four pieces of information

254
00:09:54,660 --> 00:09:56,340
I have to statically assign,

255
00:09:56,340 --> 00:10:00,450
since I didn't enable DHCP under the BOOTPROTO option.

256
00:10:00,450 --> 00:10:03,390
Next I have PREFIX0=24.

257
00:10:03,390 --> 00:10:04,948
This is setting my subnet mask.

258
00:10:04,948 --> 00:10:07,740
Since it's a /24 CIDR notation

259
00:10:07,740 --> 00:10:09,090
which is what I'm using here,

260
00:10:09,090 --> 00:10:13,980
that means my sub mask is actually 255.255.255.0.

261
00:10:13,980 --> 00:10:16,320
This is a default class C range.

262
00:10:16,320 --> 00:10:17,790
Next, you'll see the gateway.

263
00:10:17,790 --> 00:10:21,630
GATEWAY0 is assigned to 192.168.1.1.

264
00:10:21,630 --> 00:10:24,510
And then, you'll see I have DNS1 and DNS2.

265
00:10:24,510 --> 00:10:27,060
I have one internal DNS server I'm going to refer to,

266
00:10:27,060 --> 00:10:28,080
and if that doesn't work

267
00:10:28,080 --> 00:10:31,830
I'm going to point them to Google's DNS at 8.8.8.8.

268
00:10:31,830 --> 00:10:35,310
You'll see there, my intro domain name is diontraining.com.

269
00:10:35,310 --> 00:10:38,520
And then, we also some information for IPv6.

270
00:10:38,520 --> 00:10:40,590
By setting all of this into this file

271
00:10:40,590 --> 00:10:44,370
at /etc/sysconfig/network-scripts,

272
00:10:44,370 --> 00:10:47,790
I'm going to be able to load this up every time my system boots

273
00:10:47,790 --> 00:10:49,170
and it will configure this system

274
00:10:49,170 --> 00:10:50,943
with this static IP address.

275
00:10:51,834 --> 00:10:53,970
Now you may be wondering if this was a workstation

276
00:10:53,970 --> 00:10:55,560
and I wanted to use DHCP on it,

277
00:10:55,560 --> 00:10:56,850
how would I do that?

278
00:10:56,850 --> 00:10:59,820
Well, where it says BOOTPROTO=none,

279
00:10:59,820 --> 00:11:02,190
I would simply change that to either BOOTP,

280
00:11:02,190 --> 00:11:04,170
if I'm using the boot strap protocol

281
00:11:04,170 --> 00:11:08,280
or I would enter DHCP if I want to use a DHCP server

282
00:11:08,280 --> 00:11:11,403
to do my automated configuration using a dynamic assignment.

283
00:11:12,270 --> 00:11:14,460
So in summary, there's really four things

284
00:11:14,460 --> 00:11:16,200
I want you to take away from this lesson.

285
00:11:16,200 --> 00:11:18,240
There are four main tools you're going to use

286
00:11:18,240 --> 00:11:20,790
when interacting and connecting to a network.

287
00:11:20,790 --> 00:11:22,650
You can either use the Network Manager

288
00:11:22,650 --> 00:11:24,270
in any of its three forms,

289
00:11:24,270 --> 00:11:26,640
the command line, the Text User Interface,

290
00:11:26,640 --> 00:11:28,440
or the graphical user interface,

291
00:11:28,440 --> 00:11:31,979
or you can use the older ifconfig, the newer IP,

292
00:11:31,979 --> 00:11:35,634
or if you're using a wireless card, it'll be iwconfig.

293
00:11:35,634 --> 00:11:38,070
All these are tools that you should be comfortable with,

294
00:11:38,070 --> 00:11:39,510
because at some point in your career

295
00:11:39,510 --> 00:11:41,640
you're going to have to use them to configure the network

296
00:11:41,640 --> 00:11:43,893
on your Linux servers and workstations.

