Build a shared IP Virtual Machine

Source: Internet
Author: User
Tags vmware server

Environment:Internet server
Objectives:Create virtual machine B on Internet server a and manage it remotely.
Others:One IP address must be shared.
Note:Virtual Machine-operating system level, virtual host-Web application server level, of course there are mixed calls, know what you want to do. Create a virtual machine-operating system level.

A's operating system Ubuntu, install vmvirtual machine, here choose vmplayer (vmserver problems, see the description below ).
Install the operating system in vmplayer or download Virtual Machine backup, as shown in figure

Http://www.thoughtpolice.co.uk/vmware/

Http://www.vmware.com/appliances/directory/

Why is there no windows? It must be unavailable outside China. If it is free, it will be infringing. If it is in China, it will not be afraid.

Install Ubuntu, the same operating system as a, as virtual machine B. Select the NAT mode. You can also select host-only. (For the network mode, see the description below)

A has two more network adapters vmnet1 and vmnet8.
When vmnet1 is in host-only mode, B accesses the address of.
When vmnet8 is in Nat mode, B accesses the address of.

In the shell of operating system B, set the B address to a static address. Otherwise, the VM may change after restart.
Nano/etc/Network/interfaces
Auto eth0
Iface eth0 Inet static
Address B address
Netmask 255.255.255.0
Gateway

Use the original B address, ifconfig, And the gateway can use Route-n.
Restart/etc/init. d/networking restart

To complete operating system settings, we need to configure two important tasks.
1) Port ing: used to manage B.
2) Web forwarding: enables B to be accessed through the Internet through.

Note that there are three IP addresses (Internet address a, Intranet address a, and Intranet address B), and only Intranet address B.
Map port 2222 of a to port 22 of B:
Iptables-T Nat-A prerouting-d a Internet address-p tcp -- dport 2222-j dnat -- to-destination B Intranet address: 22
Iptables-T Nat-A postrouting-d B Intranet address-P TCP -- dport 22-J SNAT -- to a Intranet address
Iptables-a forward-O eth0-d B Intranet address-P TCP -- dport 22-J accept
Iptables-a forward-I eth0-s B Intranet address-P TCP -- Sport 22-J accept

Enable IP forwarding.
Nano/etc/sysctl. conf
Remove the following comments
# Net. ipv4.ip _ forward = 1

After the system is restarted, it will be lost. For automatic start, modify the network configuration.
Add two lines to nano/etc/Network/interfaces:
# Save the configuration when the network is closed
Post-down iptables-save>/etc/iptables. Up. Rules
# Loading configuration during network connection
Pre-up iptables-Restore </etc/iptables. Up. Rules

Check and restart the network
/Etc/init. d/networking restart
Again
Iptables-l
You can see two lines of chain forward, on OK.

In this way, the port ing is done. Of course, you can map any port, including 80.
However, port 80 of A is usually used for other purposes and cannot be transferred to B. Therefore, the second port must be configured for Web forwarding.

Install apache2 on a and modify the configuration file under/etc/apache2/sites-available/. The default value is default.
The web site usually uses the configuration file separately, such as XXX. conf. Here is an example.

Namevirtualhost *: 80
<Virtualhost *: 80>
Servername xxx.wikiway.cn
# Web forwarding
Proxypass/http: // intranet address of B/
Proxypassreverse/http: // intranet address of B/
</Virtualhost>

So the http://xxx.wikiway.cn is forwarded to virtual machine B.
Install multiple virtual machines and configure multiple forwarding rules to share one IP address among multiple hosts.

Although multiple Web servers are installed in a or multiple hosts and ctor INS are configured, you can share an IP address through apache2 pre-forwarding, but it is very insecure. Various types of user permissions are difficult to configure and neglected, giving hackers "bypass" attack opportunities. Do not trust the security of virtual host hosting. In China, this money still requires network management. When resources are allowed, it is better to use a virtual machine. If a is saved, everything is fine.

===========================
VMware free product introduction
1) VMware vsphere hypervisor: it is an operating system, installed on bare metal, and then installed on various operating systems.
2) VMWare Player: Virtual program, and then install the operating system in the VM.
3) VMware Server: Virtual program, and then install the operating system in the VM. There is one more Remote Desktop Management (web-based) than player. The server does not need a GUI.

Note that after the vmserver is installed, it has its own Tomcat service. If Tomcat is already used on the host machine, you should modify the Tomcat port of the VM (8005/8009, 80 VM is not enabled). You can see the process by viewing the path.
The shared IP address of vmserver can only be used in Nat or host-only mode. If there is a problem between the two modes, start/etc/init. d/vmware start to report virtual ethernet failed. After being replaced with vmplayer, there is no problem.

Three Network modes of Vmware
1) bridged: the bridging mode is equivalent to a separate physical IP address of the virtual machine, and an independent IP address needs to be allocated to the public network. In this way, it is equal to the host, and can access the Internet and the Internet to directly access the virtual machine.
2) NAT: the adaptation mode allows you to access the Internet through the host. The website address is a virtual IP address of the local area network (LAN), which can be used to access the Internet. The Internet needs to be forwarded by the host to access the virtual machine.

3) Host-only: host mode. It can only access the host, but also has a LAN virtual address and cannot access the Internet. This mode is suitable for high security scenarios.

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.