Linux Network Configuration

Use examples when they help make things clearer.

You plug in an Ethernet cable into your router, which is connected to your ISP (Internet Service Provider). Your computer then sends out a signal saying ” I need some sweet, sweet internet access!”

The router receives this request and responds with its own IP address (a unique identifier for devices on the network) and tells your computer how to get to it. This is called DHCP (Dynamic Host Configuration Protocol). Your computer then sends out another signal saying “Alright, cool! I’ll remember that.”

Now you can browse the web or do whatever else you want with your newfound internet connection. But what if something goes wrong? Maybe your router isn’t working properly or your ISP is having issues. That’s where Linux network configuration comes in handy.

Linux has a built-in tool called “Netplan” that allows you to configure various networking settings, such as IP addresses and DNS servers (which translate website names into actual internet addresses). You can do this either through the command line or via a graphical interface like GNOME Network Manager.

To view your current network configuration on Ubuntu 22.04 Jammy Jellyfish, you can run the following commands:

– To get your local IP address (the one used to communicate with other devices on your home network), use this command in terminal: `$ ip a`
– To check for currently used DNS server IP address, execute this command: `$ systemd-resolve –status | grep Current`
– To display default gateway IP address, run this command: `$ ip r`

If you want to set up a static IP address (meaning your computer always uses the same one), you can do so either from GNOME Network Manager or via Netplan. Here’s how to configure it in GNOME:

1. Open Settings and click on Network menu. 2. Click on the gear wheel of the desired network interface. 3. Click the IPv4 tab, then select Manual configuration option. 4. Fill out your desired IP address, subnet mask, and default gateway (if provided by your ISP). Do not forget to also specify a custom DNS server if you wish. When you are done, click Apply to finalize the changes.

Alternatively, you can configure it from Netplan using this command:

# Edit /etc/netplan/00-installer-config.yaml file with administrative privileges and add following configuration:
# This line specifies the file to be edited and the necessary permissions to do so.

network:
  ethernets:
    enp0s3:
      dhcp4: false
      addresses: [192.168.1.202/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8,8.8.4.4,192.168.1.1]
# This section specifies the network configuration, specifically for the ethernet interface enp0s3.
# The "dhcp4: false" line disables DHCP and allows for manual configuration.
# The "addresses" line sets the IP address and subnet mask for the interface.
# The "gateway4" line specifies the default gateway for the network.
# The "nameservers" section sets the DNS servers to be used, including a custom one provided by the ISP.

# Alternatively, you can configure it from Netplan using this command:
# This line provides an alternative method for configuring the network using the Netplan command.

Replace the IP address and gateway with your own values (you can find them by running `ip a`). Then save and exit the file after you have applied your changes:

bash
# This script is used to apply network configuration changes using netplan.
# It is assumed that the user has already replaced the IP address and gateway with their own values.
# To find these values, the user can run the command `ip a` in the terminal.

# Apply the network configuration changes using netplan.
sudo netplan apply

# The `sudo` command is used to run the following command with root privileges.
# This is necessary for making changes to the network configuration.

# The `netplan apply` command applies any changes made to the network configuration.
# This ensures that the changes take effect immediately.

# It is important to note that this script assumes the user has already made the necessary changes to the network configuration.
# If the changes have not been made, the script will not work as intended.

And that’s it! You should now be able to connect to the internet using your new static IP address. If you run into any issues, try running `netplan –debug apply` instead for more detailed output.

SICORPS