Linux configuration automatically obtains ip address

Back up ifcfg-eth0 before modifying the configuration file, enter the following command to open the configuration file:

[root@linux123 backup]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

The content of the configuration file is as follows:

DEVICE=eth0
HWADDR=00:0C:29:C9:1B:BB
TYPE=Ethernet
UUID=0a48dde7-690a-4697-adce-d3361f9ab707
ONBOOT=no
NM_CONTROLLED=yes
BOOTPROTO=dhcp

Add the following content to the configuration file:

DEVICE=eth0
HWADDR=00:0C:29:C9:1B:BB
TYPE=Ethernet
UUID=0a48dde7-690a-4697-adce-d3361f9ab707
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
NAME="System eth0"
IPADDR=192.168.88.128
GATEWAY=192.168.88.2
DNS1=192.168.88.2

After setting, you can automatically connect to the Internet every time you start Linux. If you don't know GATEWAY, you can query it through route -n. DNS1 is the same as GATEWAY.

Guess you like

Origin blog.csdn.net/Sruggle/article/details/115016939