Home > System Tutorial > LINUX > body text

Detailed explanation of Ubuntu static IP setting method

WBOY
Release: 2024-01-05 10:09:46
forward
1789 people have browsed it

After the system is installed and the sources are set up (the previous default sources have been commented out and changed to sources from several education networks, the sources from Beijiao are relatively fast), the next task is to update the system and install Required software, but only if it is available

1. Modify the network configuration file

Network configuration information is stored in the /etc/network/interfaces file
sudo vi /etc/network/interfaces
I open it with vi, and my file displays the following content:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback

There is only one loopback address in my network configuration file, which is 127.0.0.1. Add below:

auto eth0 #Indicates that the network card eth0 is automatically loaded when the system starts
iface eth0 inet static #Specify that eth0 uses an ipv4 address, inet represents an ipv4 address, inet6 represents an ipv6 address; static represents static, dhcp represents dynamic
address 172.22.112.13 #static ip
netmask 255.255.255.128 #Subnet mask
gateway 172.22.112.1 #Gateway address
:wq #Save and exit

2. Set up DNS server

You also need to configure a DNS server under static IP (Windows does the same). DNS information is stored in /etc/resolv.conf. If there is no such file, create a new one directly:

sudo vi /etc/resolv.conf #Open the file with vi
Enter edit mode, enter a, and then enter the following in sequence:

nameserver 202.202.32.33 #Preferred DNS server
nameserver 61.128.128.68 #Alternate DNS server
:wq #Save and exit

3. After all modifications, the network card needs to be restarted for the modifications to take effect. The method is as follows. Enter the following command:

sudo ifdown eth0 #Disable network card
sudo ifup eth0 #Start network card

The following are the additions from other netizens

a) Set via command

Type in the terminal: sudo ifconfig eth0 10.221.20.17 netmask 255.255.255.0
Note that "0" in eth0 is the number "0"

10.221.20.17:ip address
255.255.255.0: Subnet mask

To check whether the setting is successful, type: ifconfig

in the terminal

Detailed explanation of Ubuntu static IP setting method

b) Setting through graphical interface

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

Detailed explanation of Ubuntu static IP setting method

The above is the detailed content of Detailed explanation of Ubuntu static IP setting method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!