Linux tips - how to modify IP (four methods)

Table of contents

Project scenario:

Method analysis and step introduction

Cause Analysis:

solution:


Project scenario:

The project often encounters the situation of modifying the IP. Here are some methods of modifying the IP in various situations. Especially when there is no host screen display, modify the IP with the help of the command line.


Method analysis and step introduction

method 1:

Temporary modification

You can use the ifconfig command.

as follows:

ifconfig eth0 192.168.1.99;

Here ETH0 is the name of the network card. If you don’t know the name, you can output ifconfig and press Enter to view it.

This method is relatively simple, fast and convenient, and is suitable for temporary debugging. But it will fail after restarting.

Method 2:

interface changes

This is actually modified when there is a screen displaying the host, click the network connection in the lower right corner of the screen

Click to edit connection

Select the corresponding network card name (you need to pay attention when changing here). The corresponding network connection and corresponding network card name must be selected. If you are not clear, you can delete them all.

Then select manual in the IP address bar to configure the IP and mask.

This method is effective for restarting. (Be sure to restart, otherwise the configuration file is not written in)

Method three:

Configure permanent IP from the command line (complex version, method 4 is relatively simple, and method 4 is recommended)

/etc/sysconfig/network-scripts, modify the file ifcfg-eth0 file.

30ed2cf5e2ebaef9b647dfe9d7140b75.png

Change the local ip type to static ip as shown in the figure, and set your own ip, subnet mask, and DNS service (just use the public one, as shown in the figure)

After modification, save and exit, and restart the network service, use the following command

service network restart or

systemctl  restart network

As shown in the figure below, it means that the network restart is successful

4d1eb2431741c7a6e6cbc5b892363dd4.png

Method four:

Also under the command line, (relatively simple, recommended)

Input command: nmtui

6569aa91d71943bb8b5fa5aafc9e5a9b.png

select edit connection

c461593e5d604af1bd075b948310a31f.png

 Select a wired connection, edit, and change and set the IP on the following page, and restart is limited.

09479bf5295e4f3f9caa19a4dda04913.png

Save and exit.


Cause Analysis:

This article mainly analyzes and discusses common network port problems under the Linux system, and summarizes four common ways to configure them.


solution:

This article mainly proposes four ways to modify IP, which are highly recommended. You are welcome to try it often. If you have any questions or have a better way, welcome to communicate.

In fact, this article is summarized in the project of debugging the network port.

Introduction of other keywords

linux:

Linux, the full name of GNU/Linux, is a free-to-use and freely disseminated UNIX-like operating system. Its kernel was first created by Linus Benedict Torvalds on October 5, 1991. Released, which is mainly inspired by the ideas of Minix and Unix , is a POSIX -based multi-user, multi-tasking , multi-threading and multi- CPU operating system . It supports 32-bit and 64-bit hardware and can run major Unix utilities, applications and network protocols.

Linux inherits Unix's network-centric design idea and is a multi-user network operating system with stable performance. There are hundreds of different distributions of Linux, such as debian and archlinux based on community development, and Red Hat Enterprise Linux , SUSE , Oracle Linux and so on based on commercial development .

On November 20, 2022, Linux submitted the last batch of drm-intel-next function patches, and Linux 6.2 will usher in the official support for Intel Ruixuan discrete graphics

IP address:

    IP refers to Internet Interconnection Protocol, the abbreviation of Internet Protocol, which is the network layer protocol in the TCP/IP system. The purpose of designing IP is to improve the scalability of the network: one is to solve Internet problems and realize the interconnection and intercommunication of large-scale and heterogeneous networks ; Independent development. According to the end-to-end design principle, IP only provides a connectionless, unreliable, best-effort data packet transmission service for the host.

The second skin 2023.5.24 in Hefei

Guess you like

Origin blog.csdn.net/whm128/article/details/130843067