Host for Linux, Windows VMware Three ways to access the Internet (turn)

Source: Internet
Author: User
Tags nameserver

One, the VMware three ways of working principle
1 host-only Connection mode
The virtual machine has a separate IP address that differs from the host, but it is in a different network segment than the host host, and a new IP address is added to the host, and the IP address is guaranteed to be in the same network segment as the virtual machine IP address. The end result is a new LAN composed of all the virtual machine and host host, but the LAN and the host host itself in the existing LAN is independent of each other, if no additional routing settings, the two LAN is not connected, so the new LAN can be considered as a separate from the current host host private network , whose members are the current host host and all associated virtual machines, which is also the origin of host-only naming.
From the network technology is equivalent to the host host to add a virtual network card, so that the host host becomes a dual-NIC host (Host network card + virtual network card). At the same time, a virtual switch is added to the host host backend, which makes the host host and all virtual institutions into another virtual LAN. Because of the dual network card, the host host can participate in two LAN (existing host LAN + new virtual local area network), but by default, two LAN is not connected.

2 Bridge (bridging) connection mode
Having a virtual machine with a separate IP address different from the host, but staying on the same network segment as the host, the end result is that all the VMs are joined to the local area network where the host host is located, which is no different from the effect of adding other host hosts to the LAN.
The network technology is equivalent to the host host in the front end of a virtual switch, and then the host host and all virtual machines to share the switch, or simply understand the host host to make a point enhancement, so that it has a switch (of course, virtual) function for the host host and other virtual machines in the network segment to use.

3 NAT Connection mode
Although from the surface phenomenon, the virtual machine does not have its own IP address, but the IP address of the shared host host, but the technology is essentially based on the host-only way (that is, the virtual machine or has its own independent IP address, but actually not put into use), as in the Host-only way, Host host becomes a dual-NIC host, while participating in the existing host local area network and the new virtual local area network, but because of the addition of a virtual NAT server, so that virtual LAN inside the VM in the external access, completely "run" host IP address, so from the external network, can only see the host host, The newly created virtual local area network is completely invisible.

After understanding the principle let's start to configure it!

Second, first introduction host is Redhat Enterprise Linux 5.X
Installation Environment:

1. Host system: RedHat Enterprise Linux 5.X

2. Virtual machine system: RedHat Enterprise Linux 5.X

3. VMware version: VMware Workstation 6.5

Objective: To realize the network of virtual machine system

Method One: Host only mode

settings for the host system:
Let's take a look at the network card situation
[Email protected] ~]# ifconfig
Eth0 Link encap:ethernet HWaddr 00:26:22:08:60:18
inet addr:10.106.34.219 bcast:10.106.34.255 mask:255.255.255.0
Inet6 ADDR:FE80::226:22FF:FE08:6018/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:197 errors:0 dropped:0 overruns:0 frame:0
TX packets:54 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17811 (17.3 KiB) TX bytes:11066 (10.8 KiB)
interrupt:177

Lo Link encap:local Loopback
inet addr:127.0.0.1 mask:255.0.0.0
Inet6 addr::: 1/128 scope:host
Up LOOPBACK RUNNING mtu:16436 metric:1
RX packets:33 errors:0 dropped:0 overruns:0 frame:0
TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3266 (3.1 KiB) TX bytes:3266 (3.1 KiB)

virbr0    Link encap:ethernet  HWaddr 00:00:00:00:00:00  
           inet addr:192.168.122.1  bcast:192.168.122.255  mask:255.255.255.0
          inet6 addr:fe80::200:ff:fe00:0/64 scope:link
           up broadcast RUNNING multicast  mtu:1500  metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0 
           RX bytes:0 (0.0 b)   TX bytes:10600 (10.3 KiB)

vmnet1    Link encap:ethernet  HWaddr 00:50:56:c0:00:01  
           inet addr:172.16.73.1  bcast:172.16.73.255  mask:255.255.255.0
          inet6 addr:fe80::250:56ff:fec0:1/64 scope:link
           up broadcast RUNNING multicast  mtu:1500  metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000 
           RX bytes:0 (0.0 b)   TX bytes:0 (0.0 b)

vmnet8    Link encap:ethernet  HWaddr 00:50:56:c0:00:08  
           inet addr:192.168.135.1  bcast:192.168.135.255  mask:255.255.255.0
          inet6 addr:fe80::250:56ff:fec0:8/64 scope:link
          up broadcast RUNNING multicast  mtu:1500  metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
           RX bytes:0 (0.0 b)   TX bytes:0 (0.0 b)
Note: Where VMnet1 is the network interface for virtual machine host-only mode, VMNET8 is a NAT mode network interface, VIRBR0 is a bridged mode network interface

To avoid affecting the shutdown VIRBR0,VMNET8
Ifconfig virbr0 Down
Ifconfig Vmnet8 Down

We all know that the host only way, using the Vmnet1 this network card, the following we have to match it
To make it easy for me to set the VMNET1 network card to a temporary IP (which is immediately effective after Setup)
Ifconfig Vmnet1 192.168.1.1/24
View Configuration
[Email protected] ~]# ifconfig
Eth0 Link encap:ethernet HWaddr 00:26:22:08:60:18
inet addr:10.106.34.219 bcast:10.106.34.255 mask:255.255.255.0
Inet6 ADDR:2001:DA8:5000:881A:226:22FF:FE08:6018/64 Scope:global
Inet6 ADDR:FE80::226:22FF:FE08:6018/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:3984 errors:0 dropped:0 overruns:0 frame:0
TX packets:2633 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1884087 (1.7 MiB) TX bytes:580140 (566.5 KiB)
interrupt:177

lo        Link encap:local loopback  
           inet addr:127.0.0.1  mask:255.0.0.0
           Inet6 Addr::: 1/128 scope:host
          up LOOPBACK running  mtu:16436  metric:1
          RX packets:33 errors:0 dropped:0 overruns:0 frame:0
          TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3266 (3.1 KiB)   TX bytes:3266 (3.1 KiB)

Vmnet1 Link encap:ethernet HWaddr 00:50:56:c0:00:01
inet addr:192.168.1.1 bcast:192.168.1.255 mask:255.255.255.0
Inet6 ADDR:FE80::250:56FF:FEC0:1/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:64 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0  (0.0 b) TX bytes:0 (0.0 b)

View DNS

Vim/etc/resolv.conf
NameServer 202.196.64.1


To set up a virtual machine system
cd/etc/sysconfig/network-scripts/
Vim Ifcfg-eth0

Device=eth0
Bootproto=none
Onboot=yes
Hwaddr=00:0c:29:f1:3d:d7
netmask=255.255.255.0
ipaddr=192.168.1.11
gateway=192.168.1.1
Type=ethernet
Save exit

cd/etc/
Vim resolv.conf
#加一条DNS服务器
NameServer 202.196.64.1
Save exit
Here are three points to note:
1. Gateway: Is the IP address of Vmnet1
2. The host is the same as the virtual machine DNS
3. Host Nic Eth0 and Vmnet1 not on the same network segment

After the above settings, you will find that the Internet is not available
The reason is because the packet is sent, the source IP is the 192.168.1.11 packet can be sent out but not back. We need to do a bit of source address translation on the host. Snat
To configure a firewall on a host:
If you are configuring iptables for the first time, start the firewall
Service Iptables Start
Iptables-f
To add a rule:
Iptables-t nat-a postrouting-s 192.168.1.11-j Masquerade

Masquerade means to address camouflage, camouflage Cheng Host network network card IP, this statement can also be written
Iptables-t nat-a postrouting-s 192.168.1.11-j SNAT--to 10.106.34.219

Save rule:
Iptables-save > Myfirewall.back
Next recovery:
Iptables-restore < Myfirewall.back

Okay, then you're on the Internet in the virtual machine.

Method Two. Nat or Bridged mode
In the case of Linux as a host, the Internet is implemented in a NAT or bridged manner, similar to the configuration of host only
The difference is that the network card used by Nat is VMNET8, and the network card used by bridged mode is VIRBR0


Third, host Window7
. Installation Environment:

1. Host system: WINDOW7

2. Virtual machine system: RedHat Enterprise Linux 5.X

3. VMware version: VMware Workstation 6.5

Objective: To realize the network of virtual machine system

Method One: Host only mode

Configuration of the host

If the first network card is a physical network card, the second is Vmnet1, the third is Vmnet8,

To view the settings for a physical NIC

Enable Vmnet1

Right-click Properties for physical NIC

Select Share

Tick the two check boxes

Click OK to appear as, click Yes

View Vmnet1 's network card configuration (where IP automatically becomes 192.168.137.1)

Configuration of the virtual machine

Configure the network card for a virtual machine (Linux) system (enter setup at the command line)

Select Network Configuration

such as the configuration of the eth0 NIC (Note that the gateway is the same as the Vmnet1 IP)

Edit DNS

Note DNS is the same as the host DNS

Save Exit Restart Network Service

Ping Baidu

OK, now I can surf the internet!!!

Method Two: Nat mode

In fact, the way to achieve Internet access, and the host only way to achieve the basic way, here I briefly introduce

Configuration of the host

Disable Vmnet1 and remove its IP, enable VMNET8 follow-up operation is the same as Vmnet1, Vmnet8 IP automatically becomes 192.168.137.1

Configuration of the virtual machine system

The NIC type changes to NAT and the rest of the configuration is unchanged

Okay, you can surf the Internet in a NAT way.

Method Three: Bridged way

bridged way more simple, disable Vmnet1 and Vmnet8, as long as the physical network card and bridged (virtual machine) network card in the same network segment and two IP can be online, here is not repeated introduction!!!

Host for Linux, Windows VMware Three ways to access the Internet (turn)

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.