In Linux, there are three main methods to configure the network environment in linux: (1) Use setup to enter the configuration environment to configure the network; (2) use ifconfig to configure the network (3) the following describes how to directly modify the underlying network configuration file: Method 1: configure the network through setup (1) Log On As A root user, and then run the setup command to enter menuconfig, as shown in 1.
Figure 1 (2) and select network configuration, as shown in Figure 2
Figure 2 then you can configure the IP address. If you select the above use dynamic IP configuration system, the system will automatically allocate the IP address, which is not selected here. Www.2cto.com (3) for the configuration to take effect. Execute the command:/etc/rc. d/init. d/network restart note that permanent changes take effect after being restarted. Method 2: configure the network through ifconfig
The network configuration with ifconfig takes effect immediately, but this configuration is temporary. After the next restart, the IP address will be restored to the original settings. The specific configuration method is as follows: ifconfig eth0 xxx. xxx. xxx. the xxx command configures ifconfig eth0 network xxxx for the network. xxx. xxx. how to set the subnet mask using the xxx command 3: modifying the underlying configuration file is the most fundamental modification method. In fact, other methods are implemented by indirectly modifying it (1) run the command: vi/etc/sysconfig/network-scripts/ifcfg-eth0 in this file can modify IP, subnet mask, broadcast address, default gateway, after opening 3 shown
Figure 3 DEVICE indicates the network name. If you change the parameter After configuring the network using ifconfig, the parameter is also changed to the corresponding parameter. For example, if DEVICE = chen is used, ifconfig will be changed to ifconfig chen x. x. x. xONBOOT indicates whether to start the network. If yes, it indicates that when the server is started, several other parameters of the server are IP address, mask, and gateway. (2) restart the network to make it take effect for www.2cto.com/etc/rc. d/init. d/network restart is the above three methods for setting the network in linux. If you select use dynamic IP configuration in Figure 2, 4 shows
Figure 4 when you look at the file in method 3, 5 shows
Figure 5 the IP address, mask, and gateway are not configured here. dhcp indicates that the IP address is automatically obtained and the IP addresses are not used automatically in the LAN, in this way, an unused IP address is assigned to the computer, to prevent IP conflicts in the network, there is no substantial difference between the first method and the third method. You only need to note that the second method is temporary modification. Author: Chen qingting