Virtual machine network settings

Source: Internet
Author: User
Article title: Virtual Machine network settings. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

  1. let's first contact the virtual system with the Master System.

When VMware is installed, the installer automatically assigns an IP address to vmnet1. The following is an example on my computer:

Vmnet1 Link encap: Ethernet HWaddr 00: 50: 56: C0: 00: 01

Inet addr: 192.168.221.1 Bcast: 192.168.221.255 Mask: 255.255.255.0

Up broadcast running multicast mtu: 1500 Metric: 1

RX packets: 191 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 63 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 fig: 100

RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)

On the second line, we can see that the IP address assigned by the installer to vmnet1 is 192.168.221.1 (note that each installation of VMware IP address is randomly assigned. the actual situation is different from the example here ). That is, vmnet1 belongs to the network 192.168.221. Therefore, we need to start the virtual system, set network properties, and set the IP address of the virtual system's Nic "amd pcnet Family PCI Ethernet Adapter" to 192.168.221.x (x is 2 ~ The author sets any number between 254 to 2), and sets the Gateway as the vmnet1 address: 192.168.221.1 (if it does not communicate with the external real network, the Gateway can not be set)

Windows 2000 and XP settings take effect immediately, win98 needs to be restarted, and linux needs to restart the network service:

# Service network restart

Ping the virtual system on the Master System:

# Ping-c 3 192.168.221.2

PING 192.168.221.2 (192.168.221.2) from 192.168.221.1: 56 (84) bytes of data.

64 bytes from 192.168.221.2: icmp_seq = 1 ttl = 128 time = 6.91 MS

64 bytes from 192.168.221.2: icmp_seq = 2 ttl = 128 time = 0.425 MS

64 bytes from 192.168.221.2: icmp_seq = 3 ttl = 128 time = 0.527 MS

--- 192.168.221.2 ping statistics ---

3 packets transmitted, 3 bytes ed, 0% loss, time 2001 ms

Rtt min/avg/max/mdev = 0.425/2.623/6.917/3.036 MS

Yeah! Yes!

Ping the Master System on the virtual system:

C: \> ping 192.168.221.1

Pinging 192.168.221.1 with 32 bytes of data:

Reply from 192.168.221.1: bytes = 32 time <10 ms TTL = 64

Reply from 192.168.221.1: bytes = 32 time <10 ms TTL = 64

Reply from 192.168.221.1: bytes = 32 time <10 ms TTL = 64

Reply from 192.168.221.1: bytes = 32 time <10 ms TTL = 64

Ping statistics for 192.168.221.1:

Packets: Sent = 4, stored ed = 4, Lost = 0 (0% loss ),

Approximate round trip times in milli-seconds:

Minimum = 0 ms, Maximum = 0 ms, Average = 0 ms

Yeah! Again! Contact the Master System and virtual system!

 2. allow real network communication between the virtual system and the Master System

First, you need to have a real Nic connected to the real network on your computer (2 ). Vmnet8 takes effect when communicating with the real network. vmnet8 will correspond to the real network card. when the virtual system needs to send data packets to the real network, the real system is a router, first, data is sent to vmnet1, and then to vmnet8 through the vro (the main system is linux). because vmnet8 corresponds to the real network card, vmware completes this mechanism, therefore, the NIC sent to vmnet8 is sent to the real Nic, and then the packet is sent to the real network through the real Nic. please refer to the entire process. If you have more than two real NICs on your system, the installation program will ask which real Nic the Virtual NIC is mapped to during installation. It can be selected based on the actual situation.

Set the IP address of vmnet8 to the address of the same network as the real network card. if the network number of the real network is 192.168.0 and the IP address of the real network card is 192.168.0.1, you can set the IP address of vmnet8 to 192.168.0.2.

In linux, the method is as follows:

# Ifconfig vmnet8 down

# Ifconfig vmnet8 192.168.0.2 up

Let's review the three conditions mentioned above:

--------------------------------------------------------------

The key lies in three points:

1. make sure that the network numbers of amd pcnet and vmnet1 are the same.

2. set network properties in the virtual system and set the Gateway address to the address of vmnet1.

3. enable the routing function of the main system to make it a router.

--------------------------------------------------------------

The first two points have been completed in the first part. now, you only need to enable the linux routing function and the virtual system can communicate with the outside world.

Linux is a natural network operating system. its powerful network functions make it widely used in the network server field. Using linux as a router does not even require additional software. the linux kernel directly supports the static routing function. All we need to do is to enable the routing function.

You can first look at the Route table:

# Route

Make sure that the IP addresses or network addresses of all NICs are in the Destination column, for example:

-------------------------------------------------------------------------------

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.0.0*255.255.255.0 U 0 0 0 eth1

192.168.0.0*255.255.255.0 U 0 0 0 eth1

192.168.0.0*255.255.255.0 U 0 0 0 vmnet8

192.168.221.0*255.255.255.0 U 0 0 0 vmnet1

127.0.0.0*255.0.0.0 U 0 0 0 lo

Default www. gucuiwen. co 0.0.0.0 UG 0 0 0 eth0

-------------------------------------------------------------------------------

By default, when a network device is started, the system adds the IP address of the device to the routing table. if not, restart the network service:

# Service network restart

Enable the routing function again:

# Echo 1>/proc/sys/net/ipv4/ip_forward

Now, the routing function of linux has been enabled, and your linux system has become a vro connected to a virtual network and a real network. The virtual network can communicate with the real network. For security reasons, you need to use the iptables command to set routing rules if necessary.

[1] [2] [3] Next page

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.