The virtual machine implements static IP login and wireless Internet access

  • 2020-06-15 10:42:08
  • OfStack

Environment: Laptop + home WIFI + company WIFI + VMware + CentOS6.8 + Xshell

Problem Description: When I was a beginner of Linux, I installed a virtual machine (single network card) on my laptop. I wanted to realize that linux could connect to the Internet wirelessly at home and in the company, but I didn't want to manually enter IP to log in Xshell every time the Internet location changed.

Solution: Add 1 network card (eth1), set eth1 as VMnet1 (host mode only host-ES18en) for Xshell login, and the original network card eth0 as VMnet8 (NAT mode).

Implementation method:

Open VM's Virtual Web Editor to view the VMnet1 subnet address and manually change to 11.11.11.0

Start Linux and log in with root.

Modify the eth0 configuration file


# vim /etc/sysconfig/network-scripts/ifcfg-eth0
 
DEVICE=eth0
HWADDR=00:0C:29:97:06:BC
TYPE=Ethernet
UUID=24e72ebf-5682-4a8f-87a4-6b53b39a5e0b
ONBOOT=yes # Power on and enable network card 
NM_CONTROLLED=yes
BOOTPROTO=dhcp # Ensure that enable DHCP Service to get automatically IP 

Modify the eth1 configuration file


# vim /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1 # Pay attention to HWADDR ( MAC Address) and UUID (general wei 1 Identification code Universally Unique Identifier Cannot duplicate with other network CARDS 
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static # static IP Used for xshell Remote login 
IPADDR=11.11.11.68 #VMnet1 The subnet is 30 Period of 
NETMASK=255.255.255.0 
#GATEWAY=11.11.11.1  My mistake: network card eth1 Can't add a gateway 

After the configuration, restart the network service and check the connection status


#service network restart

#ping www.qq.com

ping proved to be able to connect the external network, this scheme is feasible.


Related articles: