Modify the IP address under Linux

  

Modify the IP address under Linux usually use ifconfig to modify, but this modification is very troublesome, the following small series for everyone to introduce the method of using the command to change the IP address, let's learn together.

Method /

1, using the root user logs into linux, opens into the terminal

2, the terminal type: vi /etc /sysconfig /network -scripts /ifcfg-eth0

3, press Enter,

start editing, fill in the ip address, subnet mask, gateway, DNS and so on. Among them, the information in the red box is a must.

4, after editing, save and exit

Network Service Restart

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

Then ping the gateway and ping the external network for testing. Can ping通 to indicate 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

Immediately after modification, restart is also effective

---Modify host name---

Effective immediately:

# hostname test1

Restart takes effect:

Modify vi /etc/sysconfig /network

END

Precautions

Not familiar with practice more than a few times

The above is the use of linux to easily modify the ip address method, I hope to Help everyone!

The above is the method of modifying the ip address under Linux. If you need to modify the ip address, you can easily complete the ip change by installing the steps described above. Have you learned it?

Copyright © Windows knowledge All Rights Reserved