wiki/structured/linux.network-configuration.org
Gabriel Arazas c02b532e8f Update my notes on stuff
Some CLI tools, also forgot to commit to move the exercise solutions of
SICP where it should be. The usual hierarchy notebook update.
2021-05-31 23:37:32 +08:00

2.4 KiB

Network configuration in Linux

To access the internet, you need the following components:

  • The driver of the network device installed and enabled.
  • A network manager to manage your network devices ;p
  • A DNS resolver to access domain names which are aliases to IP addresses.

Network manager configuration

With a systemd-ful environment, you can run the network daemon (i.e., systemd-networkd). Once enabled, you can run networkctl to list all of the network devices. 1

networkctl
IDX LINK   TYPE     OPERATIONAL SETUP
  1 lo     loopback carrier     unmanaged
  2 enp1s0 ether    off         unmanaged
  3 wlan0  wlan     routable    configured

3 links listed.

To configure network manager, you can create a network file in one of systemd unit file paths in the system. Each of the device will be assigned an IP address. You can either assign an IP address or dynamically assign them in some way. One of the common ways to do dynamic IP addresses is installing a DHCP server (which is another thing to be configured). Here's an example of configuring any wireless devices and assigning a dynamic IP addresses with DHCP.

[Match]
Type=wlan

[Network]
DHCP=yes
IPv6PrivacyExtensions=yes

[DHCPv4]
RouteMetric=1024

[DHCPv6]
RouteMetric=1024

DNS server configuration

While the network manager is enabled, you can access the internet. But only with raw IP addresses (e.g., 1.1.1.1 from Cloudflare, 93.174.95.27 for Library Genesis). 2[dog]] or the DNS library from NodeJS.]

Accessing the domain names as you would browse the web normally is an additional layer of the web. To access a domain name, you need a DNS client that can resolve them. While there are plenty of DNS resolvers, systemd has a component systemd-resolved which you can control with resolvectl binary.

systemd-resolved takes a configuration from /etc/resolve.conf which most third-party programs also relies on.


1

You can also run ip address for it.

2

You can find the IP addresses with DNS clients such as [[https://github.com/ogham/dog