Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to modify IP address under linux

Shulou Source: shulou.com Published: 2022-06-01 16:34:14 09月18日 Update

This article mainly explains "how to modify IP address under linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to change the IP address under linux.

Tools / raw materials

Root user rights

Methods / steps

1. Log in to linux using root user, and open the entry terminal.

2. Enter: vi / etc/sysconfig/network-scripts/ifcfg-eth0 in the terminal

3. After entering the train

Start editing and fill in the ip address, subnet mask, gateway, DNS, etc. Among them, "information in the red box" is necessary.

4. Save and exit after editing

Restart network services

Service network restart or / etc/init.d/network restart

Then the ping gateway and ping external network are tested. All ping means that the network is normal.

5. Detailed summary:

-modify ip address

Effective immediately:

# ifconfig eth0 192.168.1.155 netmask 255.255.255.0

Restart takes effect:

Modify vi / etc/sysconfig/network-scripts/ifcfg-eth0

-modify default gateway

Effective immediately:

# route add default gw 192.168.1.1

Restart takes effect:

Modify vi / etc/sysconfig/network-scripts/ifcfg-eth0

-modify dns

Modify vi / etc/resolv.conf

The modification takes effect immediately, and the restart is also effective.

-modify host name

Effective immediately:

# hostname test1

Restart takes effect:

Modify vi / etc/sysconfig/network

END

Matters needing attention

If you are not familiar with it, practice a few more times.

At this point, I believe you have a deeper understanding of "how to modify the IP address under linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Address content method user terminal gateway network learning practical deeper effective event information interest raw material practicality tool summary simple operation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker macOS MariaDB Huawei