linux set static ip address

 

 

First we use ifconfig to view the network card configuration information

We enter the configuration file vim /etc/sysconfig/network-scripts/ifcfg-ens33 of the network card that needs to be set

We can see that the default configuration is dhcp, that is, the ip address of the network card is dynamically assigned

ONBOOT="YES": Indicates that the network card is started with the system system (cnetos7 is enabled by default, centos6 is not started by default) We need to set this to yes

Next we want to set the ip address to static mode:

Add the following information

 

Note two points:

The first point is the gateway address, which must be the same as the gateway address in the virtual machine, as shown in the figure

 

 

 The second point is that the DNS address must be the same as the address of your own local network connection (or the local DNS server, you can't use Beijing's, I was using Beijing's DNS server at the time, and eventually I couldn't access the Internet, it may also be the network Too slow, so it is recommended to use a local DNS server)

After saving the configuration file, restart the network service: service network restart (if ONBOOT above is set to no, this step cannot be successful, and the setting will eventually fail)

ping Baidu

Open browser

So far, the static IP address is set.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325699604&siteId=291194637