Linux virtual fixed IP address

Since my development environment is installed in VMWare virtual machine Centos, and then set the intercept host file, so you can jump directly CentOS virtual machines, but the IP address of the virtual machine always becomes, it is necessary to modify the host file a lot of trouble. Decision virtual machine using fixed IP mode to record the steps for easy access in the future, we hope to be able to help other small partners.

Environment: The host is Windows 10 VMWare 12 Centos 7.5

1. Set the virtual machine network connection

Click the virtual machine name -> right click -> Settings

Modify the network adapter. Network connection can select "NAT Mode" or "Custom"

2. Edit -> Virtual Network Editor

Select VMNet8, click "Change Settings"

Remove the "Use local DHCP server to assign IP addresses to the virtual machine" before the hook
set subnet IP, Subnet Mask
Subnet IP and IP segment as far as possible hosts of different segments

Click "NAT settings"

Set the gateway, and IP address of the virtual machine can not be the same, remember this gateway, will be used in the third step, the corresponding GATEWAY

3. Modify the configuration file CentOS virtual machine

cd / etc / sysconfig / network-scripts into the configuration directory

Modify the configuration file vim ifcfg-eno16777736 [system is not the same, the name of the card are not the same]

 
BOOTPROTO=static
ONBOOT= yes
IPADDR=192.168.8.123  #需要和设置的IP段统一
NETMASK=255.255.255.0
GATEWAY=192.168.8.2  #需要和第二步中虚拟网卡设置的网关一致
DNS1=8.8.8.8   #这个必须设置 否则会导致能ping通外部IP,ping不通域名

Save changes and exit after completion,

Network Service Restart

systemctl restart network.service  

IP address View the IP address has been set up to

ping www.baidu.com already can access the Internet

Here's expand, preserve some command exits:

: w Save the file but do not exit vi
: w file to modify another save to file, no exit vi
: w forced to save, not to launch vi!
: WQ save the file and exit vi
:! WQ forced to save the file and exit vi
q: do not save the file and exit vi
:! q does not save the file, force quit vi
:! E abandon all changes, starting with the last saved the file to edit

That's all for this article, we want to be helpful to learn, I hope you will support script home.

Guess you like

Origin www.cnblogs.com/360minitao/p/11593159.html