1 00:00:06,600 --> 00:00:07,433 - In this video 2 00:00:07,433 --> 00:00:09,600 I'll tell you how to manage persistent configuration 3 00:00:09,600 --> 00:00:11,670 for network interfaces. 4 00:00:11,670 --> 00:00:14,280 Now, this is a topic where we have huge differences 5 00:00:14,280 --> 00:00:16,516 between the distributions. 6 00:00:16,516 --> 00:00:19,320 To start it, there is NetworkManager. 7 00:00:19,320 --> 00:00:20,760 NetworkManager is what you use 8 00:00:20,760 --> 00:00:22,710 for persistent interface configuration 9 00:00:22,710 --> 00:00:25,080 on Red Hat Family Linux 10 00:00:25,080 --> 00:00:27,780 and also indirectly on Ubuntu desktop. 11 00:00:27,780 --> 00:00:30,780 We'll talk more about it in just a little bit. 12 00:00:30,780 --> 00:00:34,316 NetworkManager has two main utilities, which are nmtui 13 00:00:34,316 --> 00:00:39,090 and nmcli, where nmtui is a text user interface. 14 00:00:39,090 --> 00:00:41,910 It's a nice text user interface where you can easily 15 00:00:41,910 --> 00:00:42,990 choose your options. 16 00:00:42,990 --> 00:00:45,783 And nmcli is a command line interface. 17 00:00:47,160 --> 00:00:50,760 On Ubuntu server as well as desktop, there is Netplan 18 00:00:50,760 --> 00:00:54,063 and Netplan is used for persistent interface configuration. 19 00:00:55,170 --> 00:00:57,990 Netplan provides a YAML configuration abstraction 20 00:00:57,990 --> 00:00:59,433 for various back-ends. 21 00:01:02,070 --> 00:01:03,317 Based on this YAML file, 22 00:01:03,317 --> 00:01:07,470 back-end specific configuration files are generated. 23 00:01:07,470 --> 00:01:09,420 And now here is the interesting thing. 24 00:01:09,420 --> 00:01:12,120 On Ubuntu server, systemd-networkd is used 25 00:01:12,120 --> 00:01:14,613 as the default back-end to Netplan. 26 00:01:15,840 --> 00:01:18,660 If you would want to use something else, 27 00:01:18,660 --> 00:01:20,910 there's a network renderer option in your Netplan 28 00:01:20,910 --> 00:01:25,290 YAML file, which can be used to specify another back-end. 29 00:01:25,290 --> 00:01:27,764 On Ubuntu desktop, NetworkManager is used 30 00:01:27,764 --> 00:01:29,730 as a default back-end. 31 00:01:29,730 --> 00:01:30,930 Why that difference? 32 00:01:30,930 --> 00:01:33,360 Well, because NetworkManager is very good 33 00:01:33,360 --> 00:01:36,960 at managing wifi connections, which you typically find 34 00:01:36,960 --> 00:01:40,170 on desktops and not so much on servers. 35 00:01:40,170 --> 00:01:42,562 So on Ubuntu server, systemd-networkd 36 00:01:42,562 --> 00:01:45,720 is a standard back-end for managing networking. 37 00:01:45,720 --> 00:01:47,280 It uses one or more YAML files 38 00:01:47,280 --> 00:01:50,820 which are provided by Netplan for the network configuration. 39 00:01:50,820 --> 00:01:54,840 So etc Netplan whatever dot YAML is where you need to go. 40 00:01:54,840 --> 00:01:56,746 And in this Netplan configuration, 41 00:01:56,746 --> 00:01:59,034 a renderer networkd 42 00:01:59,034 --> 00:02:01,920 is used to connect to systemd-networkd. 43 00:02:01,920 --> 00:02:03,780 On modern versions of Ubuntu server, 44 00:02:03,780 --> 00:02:06,210 this is a default setting, so you might not 45 00:02:06,210 --> 00:02:09,270 specifically find this renderer option anymore. 46 00:02:09,270 --> 00:02:10,502 If you don't find it, 47 00:02:10,502 --> 00:02:13,683 then you are safe and systemd-networkd is used. 48 00:02:14,910 --> 00:02:17,764 The Netplan configuration files need to be created manually 49 00:02:17,764 --> 00:02:20,100 for persistent network configuration. 50 00:02:20,100 --> 00:02:23,130 I have an example about that on the next slide. 51 00:02:23,130 --> 00:02:25,530 And the front end for querying network status 52 00:02:25,530 --> 00:02:27,330 is networkctl. 53 00:02:27,330 --> 00:02:30,750 Networkctl is a part of systemd-networkd. 54 00:02:30,750 --> 00:02:33,257 And like many of the other system, the utilities, 55 00:02:33,257 --> 00:02:37,020 it has CTL at the end of the utility name. 56 00:02:37,020 --> 00:02:38,220 So you would use commands 57 00:02:38,220 --> 00:02:42,483 like networkctl status and networkctl up and down. 58 00:02:44,490 --> 00:02:48,852 Now how can we provide Netplan Static IP Configuration? 59 00:02:48,852 --> 00:02:52,710 Well, you create a configuration file that would look 60 00:02:52,710 --> 00:02:56,620 like etc Netplan 99 underscore conflict dot YAML. 61 00:02:56,620 --> 00:02:59,608 And then you can use sudo Netplan apply to activate 62 00:02:59,608 --> 00:03:02,403 and networkctl status to verify. 63 00:03:03,240 --> 00:03:06,840 And this is what the configuration file might look like. 64 00:03:06,840 --> 00:03:08,090 Let me type that for you. 65 00:03:10,620 --> 00:03:12,640 So here we are on Ubuntu server 66 00:03:17,160 --> 00:03:18,562 where I'm going to use 67 00:03:18,562 --> 00:03:23,400 sudo vim etc Netplan 68 00:03:23,400 --> 00:03:27,393 99 dash config dot YAML. 69 00:03:36,390 --> 00:03:38,700 So, we need to define it. 70 00:03:38,700 --> 00:03:42,003 Network version two, 71 00:03:44,250 --> 00:03:47,673 renderer networkd, 72 00:03:48,900 --> 00:03:51,057 and then we have the ethernets. 73 00:03:52,393 --> 00:03:56,853 And in the ethernets, I'm defining ens 33. 74 00:03:59,790 --> 00:04:00,753 Addresses. 75 00:04:02,160 --> 00:04:05,040 And that's the list of IP addresses that you want to assign. 76 00:04:05,040 --> 00:04:10,040 So 10.0.0.11/24, for instance, 77 00:04:10,890 --> 00:04:12,390 or whatever you want it to be. 78 00:04:13,290 --> 00:04:15,753 Then we have gateway four, 79 00:04:19,320 --> 00:04:22,143 and that will be 10.0.0.1. 80 00:04:23,100 --> 00:04:25,743 And we can insert the name servers. 81 00:04:31,410 --> 00:04:35,193 So the name servers typically come with a search parameter. 82 00:04:38,340 --> 00:04:43,340 My domain, comma your domain, or whatever you want it to be. 83 00:04:43,710 --> 00:04:44,850 This is a list by the way. 84 00:04:44,850 --> 00:04:49,050 The square bracket notation is equivalent to using list 85 00:04:49,050 --> 00:04:52,440 and every item separately in the list. 86 00:04:52,440 --> 00:04:53,853 And addresses, 87 00:04:55,710 --> 00:04:58,683 that's where we specify the addresses of the name server. 88 00:05:04,978 --> 00:05:06,311 And there we go. 89 00:05:08,850 --> 00:05:13,743 So now, I can use sudo Netplan apply. 90 00:05:14,670 --> 00:05:18,030 And okay, it's telling us gateway four has been deprecated, 91 00:05:18,030 --> 00:05:21,030 use default routes instead, 92 00:05:21,030 --> 00:05:23,040 but it's a warning and deprecation, 93 00:05:23,040 --> 00:05:25,830 that means that it still works. 94 00:05:25,830 --> 00:05:30,830 So sudo networkctl status is showing 95 00:05:31,170 --> 00:05:32,880 the current configuration. 96 00:05:32,880 --> 00:05:34,320 And in the current configuration, 97 00:05:34,320 --> 00:05:38,160 you can see that we have everything that was just set. 98 00:05:38,160 --> 00:05:43,160 Now, this is how you use Netplan on an Ubuntu server system. 99 00:05:43,200 --> 00:05:45,930 Let's also have a look at the centOS machine 100 00:05:45,930 --> 00:05:48,240 for NetworkManager. 101 00:05:48,240 --> 00:05:53,240 So NetworkManager, that is nmcli or nmtui. 102 00:05:53,820 --> 00:05:56,520 I would advise if you need to do this on the exam, 103 00:05:56,520 --> 00:05:58,039 use mntui. 104 00:05:58,039 --> 00:06:00,930 Nmtui is text user interface. 105 00:06:00,930 --> 00:06:03,840 And as such, it is very intuitive. 106 00:06:03,840 --> 00:06:06,394 So in nmtui, we see the connection 107 00:06:06,394 --> 00:06:09,990 and the connection is a configuration that is connected 108 00:06:09,990 --> 00:06:11,613 to a specific network card. 109 00:06:12,810 --> 00:06:16,290 So, you typically don't want to add or delete connections. 110 00:06:16,290 --> 00:06:17,460 You just go to edit, 111 00:06:17,460 --> 00:06:20,550 and in this edit, you find all the options that you want. 112 00:06:20,550 --> 00:06:22,590 So by default you don't see very much, 113 00:06:22,590 --> 00:06:25,020 and that's because everything is obtained automatically 114 00:06:25,020 --> 00:06:26,760 through a DHCP server. 115 00:06:26,760 --> 00:06:30,807 You wanna change stuff, go to the IPv4 configuration 116 00:06:30,807 --> 00:06:35,070 and make that manual, and then you select show, 117 00:06:35,070 --> 00:06:37,050 and then you can enter all the information 118 00:06:37,050 --> 00:06:38,850 that you want to use. 119 00:06:38,850 --> 00:06:41,289 Now this is so intuitive that I'm pretty confident 120 00:06:41,289 --> 00:06:43,830 that you will figure this out for yourself. 121 00:06:43,830 --> 00:06:45,780 Only one thing to realize, 122 00:06:45,780 --> 00:06:50,310 after editing a connection, you need to activate it. 123 00:06:50,310 --> 00:06:53,400 So go to activate, press enter, press enter, 124 00:06:53,400 --> 00:06:57,093 and then the connection with all the new settings is active. 125 00:06:58,350 --> 00:07:01,050 Last command is nmcli. 126 00:07:01,050 --> 00:07:03,059 Nmcli is a little bit hard, 127 00:07:03,059 --> 00:07:06,630 because it's a command line utility. 128 00:07:06,630 --> 00:07:09,993 But, nmcli is awesome tab completion. 129 00:07:10,830 --> 00:07:14,460 So, as we have just seen, nmcli is working with connection. 130 00:07:14,460 --> 00:07:16,890 So I'm using nmcli connection. 131 00:07:16,890 --> 00:07:18,600 And I'm pressing the tab key twice 132 00:07:18,600 --> 00:07:21,540 and I see all the opposite that are available. 133 00:07:21,540 --> 00:07:25,200 So if I want to edit, for instance, 134 00:07:25,200 --> 00:07:26,970 there we go, edit, tab, tab. 135 00:07:26,970 --> 00:07:29,460 And there we can see the different connections. 136 00:07:29,460 --> 00:07:32,550 So, I want to edit ens33. 137 00:07:32,550 --> 00:07:35,730 Tab tab is not doing anything, so I'm pressing enter. 138 00:07:35,730 --> 00:07:39,823 And here we get the nmcli editor. 139 00:07:39,823 --> 00:07:43,504 And that's also what makes it a little bit complex, 140 00:07:43,504 --> 00:07:46,140 the nmcli utility. 141 00:07:46,140 --> 00:07:47,880 Nmcli is powerful. 142 00:07:47,880 --> 00:07:51,660 But I would say on the exam, don't go use nmcli. 143 00:07:51,660 --> 00:07:56,660 And if you want to use it, man nmcli dash examples. 144 00:07:58,260 --> 00:08:00,219 This is giving you a couple of examples 145 00:08:00,219 --> 00:08:03,600 where you can easily pick out what you wanna do. 146 00:08:03,600 --> 00:08:04,620 As I told you, 147 00:08:04,620 --> 00:08:08,310 NetworkManager is very much for wifi networks. 148 00:08:08,310 --> 00:08:10,440 On a server, you don't wanna do the wifi, 149 00:08:10,440 --> 00:08:14,880 but you see in the examples, there are many wifi examples. 150 00:08:14,880 --> 00:08:16,770 What you probably want to do is something 151 00:08:16,770 --> 00:08:19,320 like what you see in example 11. 152 00:08:19,320 --> 00:08:20,153 I would say, 153 00:08:20,153 --> 00:08:22,890 try it for yourself, if you wanna know more about it, 154 00:08:22,890 --> 00:08:25,113 but on the exam, please focus on nmtui. 155 00:08:26,010 --> 00:08:28,350 That's the difference between spending one minutes 156 00:08:28,350 --> 00:08:30,813 or spending ten minutes on the same assignment.