This article is mainly about setting up a static IP address method in a Linux system.
Tools/Materials
Method/Step
Input in Terminal: Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Start editing, fill in the IP address, subnet mask, gateway, DNS, and so on. Where "the information inside the red box" is necessary.
When you are finished editing, save the exit.
Restart the Network service. Service network restart or/etc/init.d/network restart
Ping the gateway and ping the extranet for testing. Can ping to indicate that the network is normal.
Summary:
---Modify the IP address---
Immediate effect:
# ifconfig eth0 192.168.1.155 netmask 255.255.255.0
Restart takes effect:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
---Modify the default gateway---
Immediate effect:
# route add default GW 192.168.1.1
Restart takes effect:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
---modify DNS---
Modify/etc/resolv.conf
Immediate effect after modification, restart is also valid
---Modify the host name---
Immediate effect:
# hostname Test1
Restart takes effect:
Modify/etc/sysconfig/network
How to set a static IP address in a Linux system