Original link: https://chegva.com/5720.html
First boot, press ctrl + alt + t to open the terminal, the window is full screen/restore, press ctrl + win + ↑/↓ , enter lsb_release -a to view the system version, uname -a to view the kernel information, ifconfig to view the network configuration, and route to view the routing information .
IP configuration of versions before ubuntu 17.01:
Edit the network configuration file is: /etc/network/interfaces
Configure a dynamic IP address: auto eth0 iface eth0 inet dhcp # Set dns resolution address dns-nameservers 223.5.5.5 dns-nameservers 114.114.114.114 Configure a static IP address: auto eth0 iface eth0 inet static address 192.168.1.110 gateway 192.168.1.1 netmask 255.255.255.0
After modification, enter sudo /etc/init.d/networking restart to restart the network card to take effect. You can also use sudo ifup/ifdown eth0 to start and stop the specified network card, so that if there are multiple network cards, other network cards will not be affected.
Configure DNS server:
# vim /etc/resolv.conf #Edit configuration file, add the following content nameserver 114.114.114.114 #Set preferred dns nameserver 8.8.8.8 #Set alternate dns
Version ip configuration after ubuntu 17.01:
Ubuntu 18.04 configures IP addresses using Netplan, a new command-line network configuration tool.
The new IP configuration method will no longer use the /etc/network/interfaces file, but a YAML file instead.
The default Netplan configuration files are generally in the /etc/netplan directory.
In Ubuntu 18.04, each line of this configuration file must be indented with spaces instead of TAB, otherwise the configuration will not work.
The DNS resolution setting of Ubuntu 18.04 has been changed to systemd-resolved, not in the original configuration file /etc/resolv.conf.
#Edit the /etc/systemd/resolved.conf file and add dns to it; sudo cp /etc/systemd/resolved.conf /etc/systemd/resolved.conf.bak #Add a new line sudo vi /etc/systemd/resolved.conf DNS=114.114.114.114 8.8.8.8 8.8.4.4 #Restart systemd-resolved.service sudo systemctl restart systemd-resolved.service #Set systemd-resolved.service boot self-start sudo systemctl enable systemd-resolved.service #Redo soft link to /etc/resolv.conf sudo mv /etc/resolv.conf /etc/resolv.conf.bak sudo ln -s /run/systemd/resolve/resolv.conf /etc/ #This step must be executed, otherwise the DNS settings will not take effect immediately
Ubuntu 18.04 no longer installs ifupdown by default, so the commands ifup and ifdown are also not available. You can use the ip command to achieve similar functions, ip link set device up and ip link set device down.
The network card configuration file /etc/network/interfaces in the previous version of Ubuntu 16.04 does not work, and it has been changed to netplan.
If the new netplan does not currently meet the user’s network usage needs, the ifupdown package is still available and supported in Ubuntu.
ifupdown installation command: apt install ifupdown
Netplan configuration IP address:
→ # cat /etc/netplan/01-network-manager-all.yaml network: version: 2 ethernets: # Static configuration eno1: #Network card name dhcp4: no #Whether to automatically configure ip dhcp6: no #whether to automatically configure ipv6 addresses: [192.168.1.102/24] #IP address is used, separated/behind is subnet gateway4: 192.168.1.1 #Set gateway nameservers: addresses: [114.114.114.114, 8.8.8.8] #Set DNS server # DHCP configuration eno2: dhcp4: true addresses: []
After saving and exiting the file, execute the restart command sudo netplan apply
Execute the sudo netplan apply –debug command to view the effective status of the configuration, and modify and adjust according to the prompts
Edit the apt source configuration file, /etc/apt/sources.list , [ Centos, ubuntu, epel, pypi replace the download source with Ali source ], select the appropriate source and execute apt update, and the basic network environment of the system is all set.
refer to:
This article is transferred from: https://chegva.com/5720.html
This site is only for collection, and the copyright belongs to the original author.