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:
Editing Network Configuration Files:
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
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]
sudo netplan apply
Using nmcli:
nmcli is a command-line tool for controlling NetworkManager.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
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.