Technology Encyclopedia Home >How to configure network settings on Ubuntu?

How to configure network settings on Ubuntu?

Configuring network settings on Ubuntu can be done through various methods, including using the graphical user interface (GUI) or editing configuration files manually. Here’s a brief overview of both approaches:

Using the Graphical User Interface (GUI):

  1. Network Manager: Ubuntu uses NetworkManager to manage network connections.
    • Click on the network icon in the top right corner of the screen.
    • Select "Edit Connections" from the dropdown menu.
    • Here, you can add, edit, or delete network connections. For Wi-Fi, you can set the SSID and password. For Ethernet, you can configure IP settings manually or set it to obtain an IP address automatically.

Using Command Line:

  1. Editing Network Configuration Files:

    • Open a terminal.
    • For systems using netplan (common in newer versions of Ubuntu), edit the configuration file typically located at /etc/netplan/. For example:
      sudo nano /etc/netplan/01-netcfg.yaml
      
    • Modify the YAML file to set your network configurations. For example, to set a static IP:
      network:
        version: 2
        renderer: networkd
        ethernets:
          eth0:
            dhcp4: no
            addresses: [192.168.1.10/24]
            gateway4: 192.168.1.1
            nameservers:
              addresses: [8.8.8.8, 8.8.4.4]
      
    • Apply the changes with:
      sudo netplan apply
      
  2. Using nmcli:

    • nmcli is a command-line tool for controlling NetworkManager.
    • To set a static IP address using nmcli:
      sudo nmcli connection modify eth0 ipv4.addresses 192.168.1.10/24
      sudo nmcli connection modify eth0 ipv4.gateway 192.168.1.1
      sudo nmcli connection modify eth0 ipv4.dns "8.8.8.8 8.8.4.4"
      sudo nmcli connection modify eth0 ipv4.method manual
      sudo nmcli connection up eth0
      

Example Scenario:

If you are setting up a Ubuntu server in a cloud environment like Tencent Cloud, you might configure it to use a static IP for consistent access. You would use the netplan method to set a static IP, gateway, and DNS servers as shown above.

For more advanced networking configurations or to manage large-scale deployments, consider using Tencent Cloud's Virtual Private Cloud (VPC) services, which offer flexible network configurations tailored for cloud environments.