Win7 accesses web projects on centos 6.3 of the Local Machine and communicates with each other (centos runs in the local vmwarevm)

Source: Internet
Author: User
Tags ubuntu vps

 

On the local machine, a vmwarevm is installed in win7, and a centos 6.3 is installed,

One-click lnmp installation package is installed on centos (it is a one-click installation package written in Linux Shell that can be centos/radhat, Debian/Ubuntu VPS (VDS) or install the shell program in the lnmp (nginx, MySQL, PHP, and phpMyAdmin) production environment on an independent host. Http://lnmp.org /)

To use centos as a prerelease test server in an online environment.

 

Access the WEB Project in centos on the local machine.

The VM comes with three ways to access the Internet: 1.nat 2. Host-only 3. Bridging

1. Step 1, Open the virtual network Editor, select Nat, mode. Click the NAT setting button.

 

 

 

2. Part 2In the control panel of Windows 7 on the local machine, network and Internet, network connection, and interface.

Vmnet1 and vmnet8 are the two virtual NICs installed by VMware when we install the virtual machine, and they rely on the Virtual Machine to access the Internet.

Among them, vmnet1 is a virtual connection shared by host-only;

Vmnet8 is the internal network card of the VM. It is needed for the VM to access the Internet.

 

 

 

Vmnet1: Virtual Connection for shared use by host-only;
Vmnet8: virtual connection used for Nat sharing. The vmnet8 virtual Nic is equivalent to the NIC connected to the Intranet. The physical Nic on the host is equivalent to the NIC connected to the Internet, and the virtual machine itself is equivalent to a computer running on the Intranet, the virtual Nic In the virtual machine is independent of the virtual ethernet switch (vmnet8 ).

 

 

Right-click "vmnet1 broadband connection" ---> properties ----> share ---> allow other networks to connect through this computer, select vmnet8,

 

 

 

Then, set the vmnet8 IP address and DNS as the automatic acquisition method.

Right-click vmnet8, click Properties, and click Internet Protocol version 4, which is usually called IPv4. Then, select the automatically obtained IP address and DNS

 

 

Then, open the command line DOS window in Windows 7 on the local machine, and run ipconfig/all in cmd to obtain information about the VMware network adapter vmnet8 Nic,

 

 

 

The vmnet8 IP address is 192.168.89.1 (preferred) and the subnet mask is 255.255.255.0.

 

Then enter centos as the administrator, Su,

Modify the IP address of the VM to 192.168.89.2 and the subnet mask 255.255.0.

Modify the virtual IP Address:

[Root @ bogon/] #Vi etc/sysconfig/network-scripts/ifcfg-eth0

 

Then open the following file with VI (you can find a solution if VI is not used .)

Write:

 

Write:
Bootproto = "DHCP"
Gateway = "192.168.89.2"
Netmask = "255.255.255.0"
Onboot = "yes"

Then, WQ is saved and exited.

 

 

Restart the vm nic:

Input: Service Network restart

 

 

After this is done, if Windows 7 cannot access the Web project in the virtual machine, it may be that the firewall in the virtual machine has disabled port 80,

 

Then, check whether port 80 on the server can access: Telnet 192.168.89.2 80, but the access fails. The firewall is actually faulty.

Do the following:

----- #/Sbin/iptables/-I input-P TCP -- dport 80-J accept

Then save:

----- #/Etc/rc. d/init. d/iptables save

Restart Firewall:

----- #/Etc/init. d/iptables restart

Now, OK. The host can access the nginx service of the virtual machine.

Close the centos firewall and disable its services:
View centos Firewall Information:/etc/init. d/iptables status
Disable centos Firewall Service:/etc/init. d/iptables stop

Permanently disable the Firewall:

Chkconfig-level 35 iptables off

 

 

========================================================== ======================================

Please note it yourself, so that it will not be difficult to find it next time you use it!

 

 

 

 

The following configuration commands are used to configure the network:
Directory/etc/sysconfig/network-Scripts
Under this directory, the Administrator script file (control file) of the network interface (NIC) is stored. ifcfg-eth0 is the default first network interface, if the machine has multiple network interfaces, then the name will push ifcfg-eth1, ifcfg-eth2, ifcfg-3 ........
Note: The file here is very important, and whether the network can work normally
The file project details are as follows:
Device Interface Name (device, nic)
Bootproto IP configuration method (static: fixed IP, dhcphcp, none: manual)
Hwaddr MAC address
Whether the network interface is valid when the onboot system starts (Yes/No)
Type network type (usually Ethernet)
Netmask netmask
Ipaddr IP Address
Ipv6init whether IPv6 is valid (Yes/No)
Gateway default gateway IP Address
My configuration file is as follows: # vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device = eth0
Bootproto = static
Onboot = Yes
Hostname = localhost
Broadcast = 192.168.89.2
Hwaddr = 00: 0C: 2x: 6x: 0x: xx
Ipaddr = 192.168.89.1
Netmask = 255.255.255.0
Network = 192.168.1.0
Type = Ethernet

# Service network reload // restart the network service
# Ifconfig
Note: The hostname must be consistent with that in/etc/hosts.

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.