Linux setting static ip, detailed steps

Foreword: Every time the virtual machine is turned on, the connection ip will change after it is turned off. Finally, I can't help but set a static ip.

The steps are also very simple, just add a few addresses in the configuration file;

Implementation steps

1. Modify the ens33 configuration file    vi /etc/sysconfig/network-scripts/ifcfg-ens33

1.1 Change BOOTPROTO = dhcp   to BOOTPROTO = static 

(that is, change dynamic ip to static ip)

1.2 Add 4 rows of data as follows:

IPADDR="192.168.183.100" # Set static IP address
NETMASK="255.255.255.0" # Subnet mask
GATEWAY="192.168.183.2" # Gateway address
DNS1="192.168.183.2" # DNS server

(Add first, see the next step for data acquisition)
 

2. Obtain data source

 1. Obtain the ip address and subnet mask

Enter ifconfig in the command

inet is the ip address        nemask is the subnet mask 

2. Obtain the gateway address and DNS server ( the gateway address and the DNS server address are the same)

 In vmware: Edit - Virtual Network Editor - NAT Mode - NAT Settings - Gateway

3. Realize the configuration

 Put the obtained data source into the configuration file, the effect is as follows

 

4. The last operation    is to restart the network . After restarting the network, you need to reconnect. If the ip has not changed, it is not necessary

Instruction: systemctl restart network

 

Guess you like

Origin blog.csdn.net/weixin_55944621/article/details/126619608
Recommended