How can I access the Web Service of vmwarevm from the Internet ?, Vmwarevm

Source: Internet
Author: User
Tags dns2 nameserver

How can I access the Web Service of vmwarevm from the Internet ?, Vmwarevm
Purpose:

VMware is installed on the host, and Linux virtual machine is installed on VMware (I installed Centos7 ). I want the virtual machine to provide Web services externally. This article records how to allow my host and Internet users to access the Web on the VM.

Network Environment:

One single IP server provides one fixed IP address, and the fixed IP address allows Internet access. (Jiba blog, you cannot upload images... I will write it)

VMware has three network connection modes: bridged, NAT, and Host-only. Select the NAT mode, because the virtual machine does not have a separate IP address for use, you can only share the Host IP address.

Bridging Mode,Vmnet0, a virtual switch virtualized by VMware, is equivalent to a bridge. The virtual machine and the host are in the same network segment and have an independent address with the same IP segment as the host, for example, if the host IP address is 192.168.1.100 and the virtual machine is 192.168.1.101, it is two nodes with the same status. It can be viewed as a Hub connection between the host and the virtual machine.NAT mode,Virtual machines can communicate with hosts or access internet services, but external hosts cannot access virtual machines. It can be seen that the host is a route switch (GATEWAY). The virtual machine is inside the network, and all communications with the virtual machine must go through the gateway.Host-only mode,Create a fully enclosed network environment. The only thing that a virtual machine can access is a host. Similar to NAT, but unlike NAT, virtual machines cannot access the Internet or external network, and can communicate with each other. It can be seen that the host and the virtual machine are connected by twisted pair wires, which can be in independent network segments.

For details, refer to three network modes and how to configure vmwarevm.

VMware NAT settings: 1. Virtual Machine Access to the Internet (through NAT mode) 1. Virtual Machine Access to NAT Mode

Select the installed Virtual Machine (Centos 7), right-click and select "setting (settings)" to open the virtual machine settings window, and click Hardware (Hardware) on the Left bar) select Network Adapter (Network Adapter) in the tab, and select NAT (NET mode) in the right bar );

2. Edit Virtual Network in VMware

Choose Edit> Edit from the menu bar of VMware to open the virtual network editor and view the virtual network. By default, VMnet0, VMnet1,... is automatically generated ,....

VMnet0: Bridged Network bridging mode VMnet1: Host-Only Network Only Host mode VMnet8: NAT Mode

(1) Open the network connection of the host, select the local connection NIC (generally Broadcom NetXtreme Gigabit Ethernet #2), right-click Properties, and select the "share" tab;

① Select "allow other network users to connect to the computer through the Internet ";

② Select "VMnet8" for the home network connection"

(2) Select "edit"> "Edit Virtual Network" on the VMware menu bar to open the virtual network editor,

① VMnet8 (NAT mode) is selected at the top );

2. Select NAT (shared host's IP address with VMs) (NAT mode (the IP address of the host shared with the Virtual Machine ));

③ Click "NAT Settings )";

④ Record the subnet IP address (192.168.186.), mask, and gateway address, and configure the NIC information to the NIC in the VM;

⑤ Configure the network connection of the VM (Centos 7:

# Ip addr show # query Nic Information

# Vim/etc/sysconfig/network-scripts/ifcfg-eno16777736 # modify Nic configuration information

Key Parameter meanings: HWADDR = 00: 0c: 29: 15: e1: 3e # MAC address, press # ip addr show to modify the MAC address BOOTPROTO = static # Set static IpONBOOT = yes # If it is no, change it to yes, indicates that the NIC device automatically starts GATEWAY = 192.168.137.1 # the GATEWAY address here is the VMnet8 ip address IPADDR = 192.168.137.1 # configure the ip address. According to the VMnet8 ip address, the ip address is in the range of 192.168.137.xxx, as long as they are not the same as the gateway, # NETMASK = 255.255.255.0 # subnet mask PREFIXO0 = 24 # Set subnet mask DNS1 = 211.140.13.188 # dns Server 1, fill in the available dns server address of your network to DNS2 = 211.140.188.188 # key parameters of dns Server 2: HWADDR = 00: 0c: 29: 15: e1: 3e # MAC address, press # ip addr show to modify the MAC address BOOTPROTO = static # Set static IpONBOOT = yes # If it is no, change it to yes, indicates that the NIC device automatically starts GATEWAY = 192.168.137.1 # the GATEWAY address here is the VMnet8 ip address IPADDR = 192.168.137.1 # configure the ip address. According to the VMnet8 ip address, the ip address is in the range of 192.168.137.xxx, as long as they are not the same as the gateway, # NETMASK = 255.255.255.0 # subnet mask PREFIXO0 = 24 # Set subnet mask DNS1 = 211.140.13.188 # dns Server 1, fill in the available dns server address of your network to DNS2 = 211.140.188.188 # dns Server 2 subnet mask solution: 24 bits mean 24 binary 1, which is like this: 11111111.111111.111111.00000000, the decimal format is: 201710000255.028 bits: 11111111.11111111.111111.1111110000. The decimal format is 201710000000024030 bits: 11111111.111111.111111.11111100.

⑥ Restart the network service after configuring the static IP Address

# Systemctl restart network. service or service network restart

If an error is reported when the network service is restarted, the solution is as follows: first, in conflict with the NetworkManager service, disable the NetworkManger service.

# Service NetworkManager stop and disable chkconfig NetworkManager from being started.

Restart.

Type 2: do not match the MAC address of the configuration file. Modify/etc/udev/rules. the MAC address of the d/70-persistent-net.rules file is the same as that of the/etc/sysconfig/network-scripts/ifcfg-eth0.

Solution 3: Failed to start LSB: Bring up/down networking

I. The following error occurs when you execute service network restart:

Restarting network (via systemctl): Job for network. service failed. See 'systemctl status network. service' and 'journalctl-xn 'for details.

Ii. Run "systemctl status network. service" as prompted above to output the following similar information:

[root@localhost ~]# systemctl status network.servicenetwork.service - LSB: Bring up/down networkingLoaded: loaded (/etc/rc.d/init.d/network)Active: failed (Result: exit-code) since Wed 2018-01-24 22:04:08 PST; 5min agoProcess: 5103 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)Process: 6056 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)Jan 24 22:04:08 localhost.localdomain network[6056]: RTNETLINK answers: File existsJan 24 22:04:08 localhost.localdomain network[6056]: RTNETLINK answers: File existsJan 24 22:04:08 localhost.localdomain network[6056]: RTNETLINK answers: File existsJan 24 22:04:08 localhost.localdomain network[6056]: RTNETLINK answers: File existsJan 24 22:04:08 localhost.localdomain network[6056]: RTNETLINK answers: File existsJan 24 22:04:08 localhost.localdomain network[6056]: RTNETLINK answers: File existsJan 24 22:04:08 localhost.localdomain network[6056]: RTNETLINK answers: File existsJan 24 22:04:08 localhost.localdomain systemd[1]: network.service: control process exited, code=exited status=1Jan 24 22:04:08 localhost.localdomain systemd[1]: Failed to start LSB: Bring up/down networking.Jan 24 22:04:08 localhost.localdomain systemd[1]: Unit network.service entered failed state.

Iii. solution (because the file 70-persistent-net.rules is not found in centos7, the copied Virtual Machine (vmware) needs to modify the mac address) is to modify the mac address.

Iv. To view the mac address of the VM copied from centos7, Run "ip addr" and output the following similar information:

[root@localhost ~]# ip addr show1: lo: 
 
   mtu 65536 qdisc noqueue state UNKNOWN     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00    inet 127.0.0.1/8 scope host lo       valid_lft forever preferred_lft forever    inet6 ::1/128 scope host        valid_lft forever preferred_lft forever2: eno16777736: 
  
    mtu 1500 qdisc pfifo_fast state UP qlen 1000    link/ether 00:0c:29:15:e1:3e brd ff:ff:ff:ff:ff:ff    inet 192.168.137.128/24 brd 192.168.137.255 scope global eno16777736       valid_lft forever preferred_lft forever    inet6 fe80::20c:29ff:fe15:e13e/64 scope link        valid_lft forever preferred_lft forever
  
 

Note: The bold and Red words are the new mac address, copy this mac address to the hwaddr in the ifcfg-eno16777736 file.

V. It is normal to re-execute service network restart.

3. Test

Ping www.baidu.com. If you can ping www.baidu.com, it will be OK. If not, it indicates that DNS is not configured and you need to configure DNS:

# Cd/etc/NetworkManager/

# Vim/etc/NetworkManager. conf

Add dns = none

Service NetworkManager stop # Or the NetworkManager is directly disabled

4. domain name resolution

# Vim/etc/resolv. conf

# Primary DNS

Nameserver 8.8.8.8

# Backup DNS

Nameserver 8.8.4.4

5. Gateway Configuration

# Vim/etc/sysconfig/network

2. allow Internet access (port forwarding) on the web in the Virtual Machine)

Choose Edit> edit in the VMware menu bar to open the virtual network Editor:

① VMnet8 (NAT mode) is selected at the top );

2. Select NAT (shared host's IP address with VMs) (NAT mode (the IP address of the host shared with the Virtual Machine ));

③ Click "NAT Settings )";

④ Add Port ing: click Add to set the ing between the host port and the virtual machine ip address and port. In this way, you can use the "Host IP: ing port" method to access web applications in the virtual machine.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.