How to configure Internet on a Linux system in a virtual machine

Source: Internet
Author: User

How to configure Internet on a Linux system in a virtual machine
Background details 1. Background information

When the host can access the Internet, the operating system of the VM generally communicates with the host in NAT mode,

By default, virtual machines cannot access the internet. However, with the correct configuration, the virtual Linux System in Vmware can access the Internet.

2. configuration method 2.1. view the NAT network address and gateway address on vmware.

(1) view and verify the network address

Click "edit" à "Virtual Network Editor"

 

The NAT network segment is 192.168.2.0.

(2) view NAT settings and obtain the NAT gateway address

 

2.2 Virtual Machine System Configuration

2.2.1 Virtual Machine Linux operating system network card configuration

Set the IP address and NAT (vmnet8) to the same network segment, and set GATAWAY to 192.168.2.2, the same gateway address as vmnet8, for example:

[Root @ ol6u612csingle network-scripts] # ifcfg-eth0 more

DEVICE = eth0

HWADDR = 00: 0C: 29: 6D: 1A: 8A

TYPE = Ethernet

UUID = 6af944bf-c7d4-4933-9a94-690f66ef3234

ONBOOT = yes

NM_CONTROLLED = no

IPADDR =192.168.2.190

NETMAST = 255.255.255.0

GATEWAY = 192.168.2.2

Note two points for this Configuration:

(1) The IP address must be in the same CIDR block as the nat nic (vmnet8)

(2) set the gateway to the gateway address in the nat nic (vmnet8 ).

2.2.2 configure Resolution Server Information

Configure the resolution information. You can configure the DNS server address and/etc/resolv. conf on the NIC. Here, configure the resolv. conf file.

[Root @ ol6u612csingle/] # vi/etc/resolv. conf

Add the following table content

Nameserver 192.168.2.2

2.2.3 restart the network service

[Root @ ol6u612csingle/] # service networkrestart

3. Test Linux Internet access in a virtual machine

[Root @ ol6u612csingle/] # ping www.qq.com

PING www.qq.com (140.206.160.207) 56 (84) bytes of data.

64 bytes from 140.206.160.207: icmp_seq = 1 ttl = 128 time = 148 MS

64 bytes from 140.206.160.207: icmp_seq = 2 ttl = 128 time = 99.4 MS

64 bytes from 140.206.160.207: icmp_seq = 3 ttl = 128 time = 126 MS

Test successful!

4. Summary

(1) The operating system IP address in the virtual machine must belong to the same network segment as the nat nic (vmnet8 ).

(2) a gateway must be set for the operating system network in the virtual machine, and the GATEWAY address must be the IP address specified in the NAT Nic.

(3) name resolution settings must be set for the operating system network in the virtual machine, and the resolution server address must be the IP address specified in the NAT Nic

 

 

Author: LI Junjie (Network Name: Step-by-Step), engaged in "system architecture, operating system, storage device, database, middleware, application" six levels of systematic performance optimization work

Join the system performance optimization professional group to discuss performance optimization technologies. GROUP: 258187244

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.