Home >Operation and Maintenance >Linux Operation and Maintenance >What is the command to change ip address in linux?
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.
#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
Enter in the terminal: vi /etc/sysconfig/network-scripts/ifcfg-eth0
##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. After editing is completed, save and exitRestart network serviceservice network restart or /etc/init.d/network restartThen ping the gateway and ping the external network for testing. If all can ping, it means the network is normal Detailed summary:---Modify the ip address---Immediately effective:# ifconfig eth0 192.168.1.155 netmask 255.255.255.0Restart to take effect:Modify vi /etc/sysconfig/network-scripts/ifcfg-eth0 ---Modify default gateway---Take effect immediately:# route add default gw 192.168.1.1Restart to take effect:Modify vi / etc/sysconfig/network-scripts/ifcfg-eth0---Modify dns---Modify vi /etc/resolv.confThe modification will take effect immediately. Restart is also valid---Modify host name---It takes effect immediately:# hostname test1Restart takes effect:Modify vi /etc/sysconfig/networkRelated 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!