Article Title: how to set and activate an IP address in linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
In Linux, how do I set IP addresses? We can use commands to set the IP address, but the prerequisite for this method is that the user needs the root permission. The nic ip address configuration information is stored in the/etc/sysconfig/network-script/ifcfg-eth0 file of the linux system. the specific format is:
# Cat ifcfg-eth0 [root @ localhost network-scripts] #
DEVICE = eth0
BOOTPROTO = none
ONBOOT = yes
TYPE = Ethernet
NETMASK = 255.255.255.0
IPADDR = IP address
USERCTL = no
PEERDNS = yes
GATEWAY = GATEWAY address (IP address of the router)
The following is an example of how to set IP addresses in Linux.
# Ifconfig eth0 192.168.0.1 or modify the ifcfg-eth0 under/etc/sysconfig/network-scripts/
# Vi/etc/syssconfig/network-scripts/ifcfg-eth0
DEVICE = eth0
BOOTPROTO = static
HWADDR =; here is the physical address of your Nic. you do not need to enter the detected Nic.
ONBOOT = yes
IPADDR = 192.168.0.1
NETMASK = 255.255.255.0
NETWORK = 192.168.1.0
BROADCAST = 192.168.1.255
GATEWAY =; enter the IP address of your GATEWAY and router.
Save and exit
#/Sbin/service network restart
If the enable Nic is OK, the IP address is successfully set. In addition, we can use ifconfig eth0 to display the current IP address to confirm whether it is set correctly.
Use the following command:
/Etc/init. d/network reload command or service network [command]
Re-import the file to start the network.