The command to modify the IP address in Linux is "vi/etc/sysconfig/network-scripts/ifcfg-eth0"; use the root user to log in to Linux, open the terminal and execute this command, you can modify the IP address, subnet Netmask, gateway and other information.
![What is the command to change ip address in linux?](https://img.php.cn/upload/article/202112/23/2021122309340487657.jpg)
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
What is the command to modify the IP address in Linux
Use the root user to log in to Linux and open the terminal
![1640223546785143.png What is the command to change ip address in linux?](https://img.php.cn/upload/image/876/455/684/1640223546785143.png)
Enter in the terminal: vi /etc/sysconfig/network-scripts/ifcfg-eth0
![1640223608594393.png What is the command to change ip address in linux?](https://img.php.cn/upload/image/928/408/181/1640223608594393.png)
##After pressing enter, start editing and fill in the ip Address, subnet mask, gateway, DNS, etc. Among them, the "information in the red box" is a must.
![1640223626664389.png What is the command to change ip address in linux?](https://img.php.cn/upload/image/630/566/434/1640223626664389.png)
After editing is completed, save and exit
Restart network service
service network restart or /etc/init.d/network restart
Then ping the gateway and ping the external network for testing. If all can ping, it means the network is normal
![16402236577781What is the command to change ip address in linux? What is the command to change ip address in linux?](https://img.php.cn/upload/image/213/615/151/16402236577781What%20is%20the%20command%20to%20change%20ip%20address%20in%20linux?)
Detailed summary:
---Modify the ip address---
Immediately effective:
# ifconfig eth0 192.168.1.155 netmask 255.255.255.0
Restart to take effect:
Modify vi /etc/sysconfig/network-scripts/ifcfg-eth0
---Modify default gateway---
Take effect immediately:
# route add default gw 192.168.1.1
Restart to take effect:
Modify vi / etc/sysconfig/network-scripts/ifcfg-eth0
---Modify dns---
Modify vi /etc/resolv.conf
The modification will take effect immediately. Restart is also valid
---Modify host name---
It takes effect immediately:
# hostname test1
Restart takes effect:
Modify vi /etc/sysconfig/network
Related recommendations: "
Linux Video Tutorial"
The above is the detailed content of What is the command to change ip address in linux?. For more information, please follow other related articles on the PHP Chinese website!