1 00:00:00,000 --> 00:00:01,589 [No audio] 2 00:00:01,589 --> 00:00:04,319 Network files and commands. There are 3 00:00:04,319 --> 00:00:06,419 many network files and commands that 4 00:00:06,419 --> 00:00:08,489 needs to be used in order to configure 5 00:00:08,609 --> 00:00:11,519 your machine and bring it online or 6 00:00:11,519 --> 00:00:13,739 bring it to the network, so it could 7 00:00:13,739 --> 00:00:16,318 communicate from one machine to another. 8 00:00:17,309 --> 00:00:20,369 It should have an interface, an interface detection. 9 00:00:20,369 --> 00:00:26,670 [No audio] 10 00:00:26,670 --> 00:00:30,000 Assigning an IP address to the system is 11 00:00:30,000 --> 00:00:31,920 very important when you bring up a 12 00:00:31,920 --> 00:00:33,750 system and you need to have it on the 13 00:00:33,750 --> 00:00:37,170 network. The interface configuration 14 00:00:37,170 --> 00:00:42,447 files are the first one is /etc/nsswitch.conf file 15 00:00:42,447 --> 00:00:45,630 This file is located in 16 00:00:45,660 --> 00:00:48,210 every Linux distribution. In fact, all 17 00:00:48,210 --> 00:00:49,890 these files that I'm going to talk about 18 00:00:49,890 --> 00:00:53,730 all of them are and will be in your 19 00:00:53,730 --> 00:00:57,623 Linux system. So the first one is nsswitch.conf, 20 00:00:57,623 --> 00:00:59,400 which tells the 21 00:00:59,400 --> 00:01:03,360 system where is where it should resolve 22 00:01:03,390 --> 00:01:06,870 its hostname to IP address. So let's 23 00:01:06,870 --> 00:01:09,060 look at our Linux machine and then we 24 00:01:09,060 --> 00:01:13,347 will find out how to read these files. 25 00:01:13,347 --> 00:01:26,211 [No audio] 26 00:01:26,211 --> 00:01:27,496 Let's clear the screen. 27 00:01:27,496 --> 00:01:40,944 [No audio] 28 00:01:40,944 --> 00:01:43,320 Okay, the first file that we're going to look at 29 00:01:43,380 --> 00:01:45,570 it's /etc/nsswitch. So just do cat 30 00:01:45,600 --> 00:01:47,970 on /etc/nsswitch.conf file. 31 00:01:48,840 --> 00:01:52,350 You will see it starting with host let's 32 00:01:52,950 --> 00:01:55,710 let's do more on it instead of just cat. 33 00:01:56,130 --> 00:01:59,610 So this will read the file page by 34 00:01:59,610 --> 00:02:02,220 page. Okay, so all these stuff, anything 35 00:02:02,220 --> 00:02:04,320 that starts with pound, it means it's 36 00:02:04,320 --> 00:02:07,200 just a comment. Anything that you want 37 00:02:07,200 --> 00:02:09,360 to have it in effect, just remove the 38 00:02:09,360 --> 00:02:13,350 comment. So let's go through it. Let's 39 00:02:13,590 --> 00:02:15,720 go to the point where you don't see the 40 00:02:15,720 --> 00:02:19,590 comment. So here it's starting from this 41 00:02:19,800 --> 00:02:22,440 page on it says a passwd file. So the 42 00:02:22,440 --> 00:02:23,880 first thing is telling you to look for 43 00:02:23,880 --> 00:02:25,950 the passwd file in the files. Don't go 44 00:02:25,980 --> 00:02:27,570 anywhere, there is no active directory, 45 00:02:27,750 --> 00:02:29,850 there is no other NIS service that's 46 00:02:29,850 --> 00:02:30,870 running that's going to give you the 47 00:02:30,870 --> 00:02:32,970 passwd, so it look for /etc/passwd. 48 00:02:33,240 --> 00:02:35,790 Shadow is also /etc/shadow, that's local, 49 00:02:35,970 --> 00:02:38,550 group is also /etc/group. And when you 50 00:02:38,550 --> 00:02:40,680 come down to host right here, it's going 51 00:02:40,680 --> 00:02:43,620 to tell you the the host information of 52 00:02:43,620 --> 00:02:46,170 your system is located in the files. And 53 00:02:46,170 --> 00:02:49,530 that is /etc/host. And then it's gonna 54 00:02:49,530 --> 00:02:52,044 say if you can't find it, then go to DNS. 55 00:02:52,044 --> 00:02:57,450 DNS is an other service that is 56 00:02:57,600 --> 00:03:00,060 installed on a Linux machine or it can 57 00:03:00,060 --> 00:03:02,370 be installed in Windows machine. We'll 58 00:03:02,370 --> 00:03:04,650 cover that later on. But for now, this 59 00:03:04,650 --> 00:03:07,140 is what the nsswitch file looks like, and if 60 00:03:07,140 --> 00:03:08,700 you want your host to be resolved with 61 00:03:08,700 --> 00:03:12,390 DNS first, you switch DNS here to here 62 00:03:12,390 --> 00:03:14,940 and file comes the second. So this is 63 00:03:14,940 --> 00:03:16,410 the nsswitch file. You're going to be 64 00:03:16,410 --> 00:03:18,270 seeing this configuration of this file 65 00:03:18,270 --> 00:03:19,980 many times while you're doing system 66 00:03:19,980 --> 00:03:22,200 administration. Next one we're going to 67 00:03:22,200 --> 00:03:25,950 look at is /etc/hosts. /etc/hosts file is 68 00:03:25,950 --> 00:03:28,260 where you define your system IP address 69 00:03:28,260 --> 00:03:31,260 and system hostname. So if my system IP 70 00:03:31,260 --> 00:03:38,321 address is ifconfig, it's 192.168.1.14, 71 00:03:38,321 --> 00:03:41,010 I could go into that /etc/file but 72 00:03:41,010 --> 00:03:42,444 by becoming root. 73 00:03:42,444 --> 00:03:45,231 [No audio] 74 00:03:45,231 --> 00:03:47,850 vi the file, and I 75 00:03:47,850 --> 00:03:49,500 could go at the bottom and I could put 76 00:03:49,500 --> 00:03:53,910 192.168.1.14. And the host 77 00:03:53,910 --> 00:03:59,340 name of my machine is, forgot, let me save 78 00:03:59,340 --> 00:04:02,880 it, and there you go, MyFirstLinuxOS. So 79 00:04:02,880 --> 00:04:04,047 let's do it again. 80 00:04:04,047 --> 00:04:07,768 [No audio] 81 00:04:07,768 --> 00:04:10,170 My, it doesn't matter 82 00:04:10,170 --> 00:04:15,600 uppercase, lowercase myfirstlinuxos. 83 00:04:15,600 --> 00:04:18,930 [No audio] 84 00:04:18,930 --> 00:04:24,925 myfirstlinuxos. So now if you ping myfirstlinuxos, 85 00:04:24,925 --> 00:04:26,100 it's going to ping your 86 00:04:26,100 --> 00:04:27,899 IP address. You see right here, the one 87 00:04:27,899 --> 00:04:30,300 that you specified in the /etc/ file. So 88 00:04:30,300 --> 00:04:32,490 that's what /etc/ file does. It's a 89 00:04:32,490 --> 00:04:35,610 small, very tiny version of DNS that's 90 00:04:35,610 --> 00:04:37,740 sitting in your machine. The next one we 91 00:04:37,740 --> 00:04:44,767 have /etc/sysconfig/network file. This file, 92 00:04:44,767 --> 00:04:48,963 [Author typing] 93 00:04:48,963 --> 00:04:51,090 sorry, this it's network I believe. 94 00:04:51,090 --> 00:04:53,010 [No audio] 95 00:04:53,010 --> 00:04:55,980 No, network, probably, yup I'm right. So this 96 00:04:55,980 --> 00:04:58,080 is the file where you specify your host 97 00:04:58,080 --> 00:04:59,430 name as well. Right now it's empty 98 00:04:59,430 --> 00:05:01,230 because we have hardcoded the hostname, 99 00:05:01,350 --> 00:05:02,580 but if you want to change it, you could 100 00:05:02,610 --> 00:05:04,890 modify it here and a certain other 101 00:05:04,890 --> 00:05:07,830 parameters can be set to, of course, you 102 00:05:07,860 --> 00:05:09,450 are more than welcome to look it up more 103 00:05:09,450 --> 00:05:11,040 on the network file. 104 00:05:11,040 --> 00:05:26,279 [No audio] 105 00:05:26,279 --> 00:05:27,449 The next file that we're going to be 106 00:05:27,449 --> 00:05:30,749 covering is actually the file, that's 107 00:05:30,749 --> 00:05:34,499 where you specify your IP address on all 108 00:05:34,499 --> 00:05:36,479 the network, all the subnet mask, and 109 00:05:36,479 --> 00:05:39,179 gateway. And when you are in the 110 00:05:39,179 --> 00:05:41,919 directory, /etc/sysconfig/network-scripts, 111 00:05:41,919 --> 00:05:44,112 I want you to do ls -ltr, 112 00:05:44,112 --> 00:05:45,749 and the last file you're going to see 113 00:05:45,749 --> 00:05:51,629 is ifcfg-enp0s3. And 114 00:05:51,629 --> 00:05:55,409 what is, this last one, it's actually 115 00:05:55,409 --> 00:05:58,589 your interface. If you go if config, and 116 00:05:58,589 --> 00:06:00,059 you will see right here, this is the 117 00:06:00,059 --> 00:06:02,489 name of your interface. So remember, 118 00:06:03,689 --> 00:06:06,149 every time all those interfaces files 119 00:06:06,179 --> 00:06:09,149 always start with ifcfg-, and the 120 00:06:09,149 --> 00:06:11,159 interface name. So when you vi that 121 00:06:11,159 --> 00:06:16,529 file, here you will see the BOOTPROTO 122 00:06:16,559 --> 00:06:18,959 is defined as dhcp. You could change 123 00:06:18,959 --> 00:06:20,759 that at here as static and then you 124 00:06:20,759 --> 00:06:22,649 could define the IP address, you could 125 00:06:22,649 --> 00:06:25,139 define subnet mask, gateway, and this way 126 00:06:25,139 --> 00:06:29,729 your IP address becomes prominent in 127 00:06:29,729 --> 00:06:31,919 your machine and does not change. So 128 00:06:31,919 --> 00:06:33,719 these are a few few of the files that I 129 00:06:33,719 --> 00:06:36,149 really want you to understand and 130 00:06:36,329 --> 00:06:38,849 memorize it because if you are going to 131 00:06:38,849 --> 00:06:41,699 go into Linux jobs and you're going to 132 00:06:41,699 --> 00:06:44,789 be applying for it. Oftentimes, you're 133 00:06:44,789 --> 00:06:47,039 going to get questions on these where 134 00:06:47,039 --> 00:06:49,559 these files are, what the files do, 135 00:06:49,559 --> 00:06:52,979 where they're located, and so on. So 136 00:06:53,009 --> 00:06:54,929 let's exit out of this file. The last 137 00:06:54,929 --> 00:06:58,859 file I have is /etc/resolve.conf. 138 00:06:59,099 --> 00:07:01,769 /etc/resolve.conf specifies your 139 00:07:01,769 --> 00:07:04,649 DNS server. DNS server is again once 140 00:07:04,649 --> 00:07:07,859 again, it actually resolve hostname to IP, 141 00:07:07,859 --> 00:07:10,949 IP to hostname, and hostname to hostname. 142 00:07:11,069 --> 00:07:14,249 So if you define it here, every time you 143 00:07:14,249 --> 00:07:19,649 go to www.google.com and hit enter, it 144 00:07:19,649 --> 00:07:23,369 knows Google is, I have to go into this 145 00:07:23,369 --> 00:07:25,409 as my gateway, I have to go to my 146 00:07:25,409 --> 00:07:27,569 gateway, which is right now acting as a 147 00:07:27,569 --> 00:07:29,399 DNS server, I'm going to go to my DNS 148 00:07:29,399 --> 00:07:32,159 server and ask where is Google and how 149 00:07:32,669 --> 00:07:36,539 to translate Google to IP address. And it 150 00:07:36,539 --> 00:07:40,139 has translated, and this is the IP 151 00:07:40,139 --> 00:07:43,619 address of Google. Let's go back to our 152 00:07:43,649 --> 00:07:45,599 lesson. The next one, we have the 153 00:07:45,599 --> 00:07:47,849 network commands. The network commands, 154 00:07:47,849 --> 00:07:50,729 we have learned ping already. If you 155 00:07:50,729 --> 00:07:55,289 wanted to ping a server, let's say ping 156 00:07:55,289 --> 00:07:57,989 the www.hotmail.com, that's the server 157 00:07:57,989 --> 00:08:00,209 outside that command that you will run 158 00:08:00,209 --> 00:08:02,939 is ping. ifconfig tells you what your 159 00:08:02,969 --> 00:08:05,969 interfaces are in the system. We have 160 00:08:05,969 --> 00:08:07,949 right now three interfaces, the local 161 00:08:07,949 --> 00:08:10,379 one does not count as an interface. And 162 00:08:10,379 --> 00:08:11,909 other one, you can ignore it, the only 163 00:08:11,909 --> 00:08:14,039 one that I have is just one and it's 164 00:08:14,039 --> 00:08:15,659 this right there. And it's telling me my 165 00:08:15,659 --> 00:08:18,619 IP is configured this. Then you have ifup or 166 00:08:18,619 --> 00:08:20,309 ifdown. If you want to bring down 167 00:08:20,309 --> 00:08:21,839 this interface, if you don't want to 168 00:08:21,839 --> 00:08:25,249 network, you could type ifup sorry, ifdown, 169 00:08:25,249 --> 00:08:26,489 or if you want to bring it back up 170 00:08:26,489 --> 00:08:28,499 your type ifup. Then the next one, we 171 00:08:28,499 --> 00:08:30,539 have netstat. netstat, you can run with 172 00:08:30,539 --> 00:08:33,339 different options, I run usually with rnv. 173 00:08:33,339 --> 00:08:35,789 This one tells you your gateway, how 174 00:08:35,789 --> 00:08:37,649 your traffic is flowing from which 175 00:08:37,679 --> 00:08:40,139 interfaces it's going from. And the last 176 00:08:40,139 --> 00:08:42,089 one we're going to cover is tcpdump. 177 00:08:42,359 --> 00:08:45,989 tcpdump is actually traces every single 178 00:08:45,989 --> 00:08:47,549 transactions that are leaving your 179 00:08:47,549 --> 00:08:50,909 machine and coming into your machine. 180 00:08:51,119 --> 00:08:55,765 The command to run is simply tcpdump. 181 00:08:55,765 --> 00:08:57,959 You have to specify i with the 182 00:08:57,959 --> 00:09:00,179 interface, which interface you are 183 00:09:00,179 --> 00:09:01,979 sniffing. It's basically a sniffing 184 00:09:01,979 --> 00:09:04,139 tool. And then you run it and you will 185 00:09:04,139 --> 00:09:06,839 see every listening coming in 186 00:09:06,839 --> 00:09:09,179 going out, it's actually listed here. So 187 00:09:09,179 --> 00:09:12,299 that's how you actually run this TCP 188 00:09:12,299 --> 00:09:14,219 command, that's how you run all these 189 00:09:14,219 --> 00:09:16,529 commands and please memorize it. Please 190 00:09:16,529 --> 00:09:18,899 run a man command on each and every one 191 00:09:18,899 --> 00:09:21,059 of them and familiarize yourself how 192 00:09:21,059 --> 00:09:23,579 these network commands and files work. 193 00:09:23,579 --> 00:09:25,632 [No audio]