This article is mainly about setting up a static IP address method in a Linux system.
Tools/Materials
Method/Step
- 1
Input in Terminal: Vi/etc/sysconfig/network-scripts/ifcfg-eth0
- 2
Start editing, fill in the IP address, subnet mask, gateway, DNS, and so on. Where "the information inside the red box" is necessary.
- 3
When you are finished editing, save the exit.
- 4
Restart the Network service. Service network restart or/etc/init.d/network restart
- 5
Ping the gateway and ping the extranet for testing. Can ping to indicate that the network is normal.
- 6
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