You can use neat, netconfig, and ifconfig to configure IP addresses in linux. The first two of them have a user interface, and the third command only sets the IP address temporarily. After the machine is restarted, the configuration will be lost.
Sometimes it is difficult to obtain graphical user interface programs. Here is a direct method to modify the network configuration file.
The general network configuration file name is: ifcfg-eth [x], this x can be 0, 1, 2, etc., because you can set multiple networks, if only one is set, the configuration file name is ifcfg-eth0, file Location:
/Etc/sysconfig/network-scripts/ifcfg-eth0
1. Modify the network configuration file
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0 # Set the network card name, which must correspond to the file name #
ONBOOT = yes# Whether to enable the NIC at startup #
BOOTPROTO = static# The IP address obtained at startup is fixed here. If it is a dynamic host, it must be changed to dhcp #
IPADDR = 192.168.1.2# IP address #
NETMASK = 255.255.255.0# Subnet mask #
NETWORK = 192.168.1.0 # The first IP address of the NETWORK segment #
BROADCAST = 192.168.1.255 # BROADCAST address of the last same network segment #
GATEWAY = 192.168.1.2 # GATEWAY address #
# GATEWAYDEV = eth0
When the linux host is installed, the default value of the ONBOOT attribute is no. You need to change it to yes, and the default value of BOORPROTO is dhcp. You need to change it to static.
Set the IP address, network mask, and gateway.
2. Restart the network service.
Use it after setting:
Service network restart
Make the network settings take effect.
Red Hat Linux passed the test.
NOTE: If ONBOOT is set to no, the service network restart startup error may occur.