Created
June 12, 2021 13:51
-
-
Save mohan43u/7e4cc06226f90225aded5910496498e9 to your computer and use it in GitHub Desktop.
systemd-networkd-june-ilugc-meet.chatlog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2021-06-12 15:06:43 mohan43u-we systemd-networkd is part of systemd framework | |
2021-06-12 15:07:01 mohan43u-we systemd is the init system in modern linux | |
2021-06-12 15:07:30 mohan43u-we apart from init functionality, systemd is capable of doing lot of other things in order to make a linux os usable | |
2021-06-12 15:07:46 mohan43u-we one of that functionality is to configure network interface | |
2021-06-12 15:08:16 mohan43u-we you can configure a network interface through many ways | |
2021-06-12 15:08:55 mohan43u-we as you see in the presenter terminal (in https://meet.ilugc.in), the command 'ip link' will show all the currently available network interfaces | |
2021-06-12 15:09:16 mohan43u-we there are physical interfaces as well as virtual network interfaces | |
2021-06-12 15:09:37 mohan43u-we you can configure a network interface either static or dynamic | |
2021-06-12 15:10:29 mohan43u-we as you see in the presenter terminal, I'm currently showing details about one physical network interface called eth0 | |
2021-06-12 15:10:49 mohan43u-we the ip address is shown in line 3 as 95.217.160.106 | |
2021-06-12 15:11:04 mohan43u-we but how does this address got configured | |
2021-06-12 15:11:15 mohan43u-we there are many way to configure this ip address | |
2021-06-12 15:12:03 mohan43u-we in past, people used ifcfg.up ifcfg.down inside /etc to configure these ip addresses | |
2021-06-12 15:12:18 mohan43u-we for dynamic ip configureation, it is done through dhcp | |
2021-06-12 15:12:48 mohan43u-we dhcp requires a dhcp server (usually if you have a wireless router in your home, most propbably it will run a dhcp server) | |
2021-06-12 15:13:20 mohan43u-we so to dynamically configure a network address for a interface, we used dhcp clients like 'dhcpcd' or 'dhclient' | |
2021-06-12 15:14:04 mohan43u-we dhclient is basically a dhcp protocol client which communicates with dhcp server and fetch dynamically assigned ip address for an interface | |
2021-06-12 15:14:53 mohan43u-we after dhcpcd/dhclient, NetworkManager was introduced | |
2021-06-12 15:15:28 mohan43u-we NetworkManager is also a daemon which manages all the network interfaces in your linux system | |
2021-06-12 15:15:53 mohan43u-we it internally uses dhclient for dynamic ip address assigning | |
2021-06-12 15:16:31 mohan43u-we if you are using any desktop environment like gnome/kde, you probably use NetworkManager to configure your network interface | |
2021-06-12 15:16:56 mohan43u-we but systemd provides much better and faster way to configure network interfaces | |
2021-06-12 15:17:01 mohan43u-we it is called systemd-networkd | |
2021-06-12 15:17:45 mohan43u-we as you see, my system is also using systemd-networkd to configure network interfaces | |
2021-06-12 15:18:19 mohan43u-we infact most of the cloud vm's or containers uses systemd-networkd to configure network interfaces | |
2021-06-12 15:18:46 mohan43u-we systemd-networkd uses configuration files to for network interface configuration | |
2021-06-12 15:19:33 mohan43u-we if you see the above output, you can see that to configure eth0, systemd-networkd uses a network file called /run/systemd/network/10-netplan-eth0.network | |
2021-06-12 15:20:20 mohan43u-we if you look at this file, you can see it contains '[Match]' '[Network]' and '[DHCP]' sections | |
2021-06-12 15:20:46 mohan43u-we [Match] section tells which interface this configuration file should be applicable | |
2021-06-12 15:20:56 mohan43u-we here it says 'Name=eth0' | |
2021-06-12 15:21:07 mohan43u-we that means this configuration file is only for eth0 interface | |
2021-06-12 15:21:18 mohan43u-we next [Network] section | |
2021-06-12 15:21:39 mohan43u-we in this section, we instruct systemd-networkd to use DHCP (ipv4 address only) | |
2021-06-12 15:22:29 mohan43u-we the other variables which configured under [Netowrk] section defines other parameters, we can ignore them now for context | |
2021-06-12 15:22:34 mohan43u-we now, the next section | |
2021-06-12 15:22:38 mohan43u-we [DHCP] | |
2021-06-12 15:23:02 mohan43u-we this section tells systemd-networkd to use 100 as metric for the routing entry | |
2021-06-12 15:23:15 mohan43u-we also it instructs systemd-networkd to use MTU | |
2021-06-12 15:23:24 mohan43u-we so thats all, the configuration | |
2021-06-12 15:24:00 mohan43u-we using this configuration, at boot, systemd-networkd will try to configure this eth0 interface through dhcp and will fetch only ipv4 address | |
2021-06-12 15:24:36 mohan43u-we usually when dhcp server responds, it will tell the ipaddress,netmask, gateway and dns records | |
2021-06-12 15:24:57 mohan43u-we systemd-networkd gets these information from dhcp-server and configure them locally | |
2021-06-12 15:25:25 mohan43u-we this /etc/resolv.conf file is where dns entries will be configured | |
2021-06-12 15:25:40 mohan43u-we normally you see two lines that contains 'nameserver' entries | |
2021-06-12 15:25:50 mohan43u-we in my machine also, you can see one 'nameserver' line | |
2021-06-12 15:26:45 mohan43u-we in my machine nameserver line tells that dns is done through another daemon running at port 53 (bounded to 127.0.0.53) | |
2021-06-12 15:27:16 mohan43u-we as you see, my machine is running a daemon called systemd-resolved at port 53 bounded to 127.0.0.53 | |
2021-06-12 15:27:28 mohan43u-we it is indicated through 127.0.0.53%lo:53 | |
2021-06-12 15:27:40 mohan43u-we this systemd-resolved is a dns resolver | |
2021-06-12 15:28:09 mohan43u-we when systemd-networkd fetches dns nameserver records from dhcp-server, it will not directly configure it in /etc/resolv.conf | |
2021-06-12 15:28:29 mohan43u-we but it passes that information to systemd-resolved, so that systemd-resolved can be used properly | |
2021-06-12 15:28:52 saikumaran hi everybody joining late sorry for that | |
2021-06-12 15:29:17 mohan43u-we systemd-netoworkd then configure the eth0 interface with the proper dynamically allocated ip address | |
2021-06-12 15:29:44 mohan43u-we so, this is how we can use systemd-networkd to configure network interfaces | |
2021-06-12 15:30:08 mohan43u-we no need for NetworkManager or any other mechanism to configure dhcp addressing | |
2021-06-12 15:31:05 mohan43u-we apart from configuring physical network interfaces | |
2021-06-12 15:31:17 mohan43u-we systemd-networkd can also create virtual interfaces dynamically | |
2021-06-12 15:31:46 mohan43u-we before I move onto this section of my talk, let me know if you have any questions | |
2021-06-12 15:32:26 mohan43u-we ok, lets continue | |
2021-06-12 15:32:40 mohan43u-we now, we will create one simple bridge interface through systemd-networkd | |
2021-06-12 15:33:35 mohan43u-we I'm going to create one file with .netdev extension | |
2021-06-12 15:34:01 mohan43u-we systemd-networkd understand .netdev files and create virtual network interfaces as per the configuration | |
2021-06-12 15:34:35 mohan43u-we you can see all the variables to use in .netdev through 'man systemd.netdev' manual page | |
2021-06-12 15:35:06 mohan43u-we systemd-networkd can create all the virtual networks available in linux | |
2021-06-12 15:35:23 mohan43u-we you can see the types of virtual networks it ca create in the manual page | |
2021-06-12 15:35:37 mohan43u-we one such interface is bridge | |
2021-06-12 15:35:49 mohan43u-we bridge is nothing but a simple multiplexer | |
2021-06-12 15:36:26 mohan43u-we you can attach physical interfaces to a bridge interface and make two physical network communicate with each other | |
2021-06-12 15:39:46 mohan43u-we as you see | |
2021-06-12 15:39:56 mohan43u-we I just created one bridge interface called sbr0 | |
2021-06-12 15:40:14 mohan43u-we you can also see that interface through ip link | |
2021-06-12 15:41:01 mohan43u-we as you see, the sbr0 is created by systemd-networkd | |
2021-06-12 15:41:46 mohan43u-we you can now, create or delete a virtual network interface as you want through networkctl | |
2021-06-12 15:42:32 mohan43u-we networkctl reload means, we instruct the currently running systemd-networkd to re read all the configuration files again | |
2021-06-12 15:42:54 mohan43u-we you can create configuration files for systemd-networkd in /etc/systemd/network directory | |
2021-06-12 15:43:03 mohan43u-we /run/systemd/network directory | |
2021-06-12 15:43:11 mohan43u-we /usr/lib/systemd/network directory | |
2021-06-12 15:44:19 mohan43u-we /etc/systemd/network directory is the top most, means, the files in this directory overrides all other directories | |
2021-06-12 15:45:09 mohan43u-we so, this is how we use sysetmd-netowrkd | |
2021-06-12 15:45:26 mohan43u-we to configure/create network in modern linux | |
2021-06-12 15:45:44 mohan43u-we man systemd.network | |
2021-06-12 15:45:58 mohan43u-we this manual page provides all the details you need to create .network files | |
2021-06-12 15:46:10 mohan43u-we man systemd.netdev | |
2021-06-12 15:46:28 mohan43u-we this manual page provides all the details you need to create virtual network interfaces using .netdev files | |
2021-06-12 15:46:42 mohan43u-we man systemd.link | |
2021-06-12 15:47:16 mohan43u-we this manual page provides all the details to configure layer2 for a network interface (including assigning a name to network interface) | |
2021-06-12 15:47:33 mohan43u-we thats all from my talk | |
2021-06-12 15:47:44 mohan43u-we if you have any questions, ask | |
2021-06-12 15:49:07 mohan43u-we I hope this talk will be useful to you. use systemd-networkd to configure your network interfaces. it is very simple and straight forward | |
2021-06-12 15:49:28 mohan43u-we no more NetworkManager crap | |
2021-06-12 15:49:47 mohan43u-we just straight forward configuration files | |
2021-06-12 15:49:57 mohan43u-we and it is damn faster | |
2021-06-12 15:50:12 mohan43u-we integrates better with other systemd components | |
2021-06-12 15:50:25 mohan43u-we like systemd-resolved | |
2021-06-12 15:50:37 mohan43u-we thanks | |
2021-06-12 15:50:55 mohan43u-we over to nihaal for his presentation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment