美文网首页系统性能优化
Ubuntu 20.04 Network Configurati

Ubuntu 20.04 Network Configurati

作者: Joncc | 来源:发表于2021-07-02 11:13 被阅读0次

Ubuntu 20.04 Network Configuration
1 year agoby Karim Buzdar
Whether you are a Linux administrator or regular user, you must know the basics of network configuration in your Linux system. it might be helpful when troubleshooting the issues with internal and external connectivity. The basic knowledge involves knowing the interface name, the current IP configuration, and the hostname. Also, you should know how to change the default configurations to the customized settings.
In this article, we will explain how to do basic network configuration in the Ubuntu system. We will use the command-line Terminal for executing the commands. To open the command line Terminal in Ubuntu, use the Ctrl+Alt+T keyboard shortcut.

In this article, we will be covering how to:

View current IP address
Set static IP address
Set the dynamic IP address
View current hostname
Change hostname
Note: We have run the commands and procedure mentioned in this article on the Ubuntu 20.04 system.

View Current IP Address
To view the current IP address of your machine, you can use either of the following commands:

$ ip a
Or

$ ip addr

Running either of the above commands will display the IP address information. Note down the name of the interface from the output of the above command.

Set Static IP Address
In the following procedure, we will see how to set up the static IP in a Ubuntu system.

Ubuntu 20.04 uses netplan as a default network manager. The configuration file for the netplan is stored in the /etc/netplan directory. You can find this configuration file listed in the /etc/netplan directory the following command:

$ ls /etc/netplan

The above command will return the name of the configuration file with the .yaml extension, which in my case was 01-network-manager-all.yaml.

Before making any changes to this file, make sure to create a backup copy of it. Use the cp command to do so:

$ sudo cp /etc/netplan/01-network-manager-all.yaml 01-network-manager-all.yaml.bak

Note: You might have a configuration file with the name other than the 01-network-manager-all.yaml. So make sure you use the right configuration file name in the commands.

You can edit the netplan configuration using any text editor. Here we are using the Nano text editor for this purpose.

$ sudo nano /etc/netplan/01-network-manager-all.yaml

Then add the following lines by replacing the interface name, IP address, gateway, and DNS information that fit your networking needs.

network:
version: 2
renderer: NetworkManager
ethernets:
 ens33:
  dhcp4: no
  addresses:
  - 192.168.72.140/24
  gateway4: 192.168.72.2
  nameservers:
   addresses: [8.8.8.8, 8.8.4.4]

Once done, save and close the file.

Now test the new configuration using the following command:

$ sudo netplan try

If it validates the configuration, you will receive the configuration accepted message; otherwise, it rolls back to the previous configuration.
Next, run the following command to apply the new configurations.

$ sudo netplan apply

After this, confirm the IP address of your machine using the following command:

相关文章

网友评论

    本文标题:Ubuntu 20.04 Network Configurati

    本文链接:https://www.haomeiwen.com/subject/unueultx.html