Environment: laptop + home WIFI + company WIFI + VMware + CentOS6.8 + Xshell
Problem description: When I first learned Linux, I installed a virtual machine (single network card) on my laptop and wanted to implement Linux at home and in the company They can connect to the Internet wirelessly, but they don’t want to manually enter the IP to log in to Xshell every time after the Internet location changes.
Solution: Add a network card (eth1), set eth1 to VMnet1 (host-only mode) for Xshell login, and the original network card eth0 is VMnet8 (NAT mode)
Implementation Method:
Open the VM's "Virtual Network Editor", check the VMnet1 subnet address, and manually change it to 11.11.11.0
Start Linux and log in as 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 #开机启用网卡 NM_CONTROLLED=yes BOOTPROTO=dhcp #确保启用DHCP服务来自动获取IP
Modify the eth1 configuration file
# vim /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth1 #注意HWADDR(MAC地址)和UUID(通用唯一识别码Universally Unique Identifier)不能与其他网卡重复 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static #静态IP用于xshell远程登录 IPADDR=11.11.11.68 #VMnet1的子网是30段 NETMASK=255.255.255.0 #GATEWAY=11.11.11.1 我的错误点:网卡eth1不能加网关
After the configuration is completed, restart the network service and check the network connection Situation
#service network restart #ping www.qq.com
Ping successfully proves that you can connect to the external network, this solution is feasible.
The above is the detailed content of An example of implementing static IP login for a virtual machine. For more information, please follow other related articles on the PHP Chinese website!