Linux: fixed ip, linux fixed ip
By default, ip addresses are dynamically allocated using dhcp when the operating system is installed. Usually we need to fix it.
Otherwise, the ip address will change after each system restart, which will cause unnecessary troubles in daily work.
The following describes how to fix Ip addresses in rhel and centos.
1. Run the ifconfig command to check which network interfaces are available.
For example, the above ens33, lo. Here, lo is the loop, which is the local loop address. Ens33 is a fixed address.
Then there will be a ifcfg-ens33 configuration file under the/etc/sysconfig/network-scripts/directory. You can run the following command to verify it (the root user is required ):
Ls/etc/sysconfig/network-scripts | grep ifcfg-
2. Switch to the root user and use vim to edit the file:/Etc/sysconfig/network-scripts/ifcfg-Ens33
Note that:
Ipaddr: IP address. Enter the value of inet in ifconfig.
Netmask: Subnet Mask. Fill in the value of netmask in ifconfig above.
Gateway: refers to the gateway where the IP address is located. If your ip address is 192.168.0.x, the network segment is 192.168.0.1.
3. Run the reboot command to restart the machine after wq is saved.