UbuntuVmware Virtual Machine network configuration (1)

Source: Internet
Author: User
Tags nameserver

UbuntuVmware Virtual Machine network configuration (1)

Ubuntu vmwarevm network configuration (1)

I have encountered a problem that Ubuntu virtual machines cannot connect to the internet many times. Basically, every time I use the Baidu configuration process on the internet, I only remember to modify several network configuration files and then restart the network service, however, every time you encounter network problems, you need to seek help again. The reason is that the role of these configuration files is not clear at all, and the other is that you do not know about Linux network drivers or TCP/IP protocol stacks ~

The network configuration process and simple parsing of Ubuntu virtual machine are organized here ~

 

Although we are also unfamiliar with the network driver or TCP/IP protocol stack, we seem to be familiar with the configuration process of computer internet access in Windows: first, the computer must first have network hardware resources-the network card, and secondly, the network card must be driven by the network card. If the network hardware device and driver are working normally, we need to configure IP addresses, subnet masks, and DNS (Domain Name System, Domain Name System, and general servers have DNS resolution services ~) for accessing the Internet ~).

Internet access is always a computer. Both Windows and Linux follow the basic architecture of the network, whether it is a hardware device or software configuration, in other words, you need to configure the NIC, NIC Driver, IP/subnet mask/DNS address ~ The vmwarevm simulates the computer system through software and follows the corresponding architecture ~

Therefore, the network configuration process for all Ubuntu virtual machines is centered on "Nic, NIC Driver, IP/subnet mask/DNS Address Configuration, whether it is to configure the vmwarevm or the network configuration file of the Ubuntu virtual machine. By analogy with the network configuration in Windows, we can quickly master and remember the network-related configuration procedures and modifications to the corresponding configuration files in Linux (Ubuntu ~

Blog Ubuntu vmwarevm network configuration (1): parse the network configuration process of the Ubuntu VM.

Blog Ubuntu vmwarevm network configuration (2): Further resolve network-related terms in network configuration.

1. Nic Configuration

(1) vmwarevm adopts the Bridged mode (in principle, all three methods can be used for Internet access, but the bridge mode is more helpful for development)

Vmware menu bar-> Virtual Machine-> settings (Vmware menu bar VM-> settings-> Network Adapter)

 

(2) view the NIC status

Vmware menu bar-> Edit-> Virtual Network Editor (Vmware menu bar Edit-> Virtual Network Editor )~


 

To set it to the above Bridged mode, first shut down the Virtual Machine. If you do not close the setting, a prompt is displayed that only the virtual machine can be set in the power off status. Select VMnet0, click "Restore Default" in the lower-left corner. After the virtual machine has configured the virtual network card, select "Bridged" and bridge) select Automatic or the actual Nic name of the current host, and then click Apply.

2. Nic IP address and DNS address must be configured according to the network segment of the host

(1) refer to Host IP address and DNS Configuration

Go to the DOS environment interface of the host Windows, run-> cmd, and view the network configuration command ipconfig ~ in the DOS environment ~


 

IP: 192.168.10.15

Subnet mask (net mask): 255.255.255.0

Default gateway: 192.168.10.254

(2) IP (DNS) configuration file:/etc/network/interfaces, these configuration files cover almost all aspects of system configuration)

You need to assign the Ubuntu virtual IP address to the IP address of the same network segment as the host: 192.168.10.XXX (88 here)

Netmask, gateway is the same as host


 

Sudo vi/etc/network/interfaces

1 auto lo
2 iface lo inet loopback
3
4 auto eth0
5 iface eth0 inet static
6 address 192.168.10.88
7 network 192.168.10.0
8 netmask 255.255.255.0
9 broadcast 192.168.10.255
10 gateway 192.168.10.254

(3) DNS configuration file:/etc/resolv. conf (resolve: solution, but the DNSDomain Name System is considered as a solution for network address recognition and identification ~)


 

Sudo vi/et/resolv. conf

Nameserver 192.168.10.254

(Multiple slave gateways can be written ~)

3. Restart the network service


 

Sudo/etc/init. d/networking restart

Or

Sudo ifdown eth0 (disable Nic)

Sudo ifup eth0 (enable Nic)

('D' in init. d: demon, Genie, daemon process)

4. Verification

Verify that the VM and host can be pinged (in bridging mode, the host must be in the network status ~)

Ping 192.168.10.15 (Host IP)


 

Problem: After the Ubuntu virtual machine is restarted, The nameserver set in/etc/resolv. conf is cleared or overwritten. Cause and solution:

The resolv. conf file contains the following text descriptions:

# Dynamic resolv. conf (5) file for glibc resolver (3) generated by resolvconf (8)

# Do not edit this file by hand -- your changes will be overwritten (do not manually modify this file, and your changes will be overwritten and OVERWRITTEN)

For resolv. conf

1/etc/resolv. conf is actually a Link

It actually points to/run/resolvconf/resolv. conf


 

# Ll/etc/resolv. conf

Lrwxrwxrwx 1 root 29 Oct 9/etc/resolv. conf-> ../run/resolvconf/resolv. conf

2. Ubuntu has a resolvconf service. If you restart it, the content of/etc/resolv. conf will be changed to the default one.

Therefore, you cannot directly modify/etc/resolv. conf.

3 if you want to define your own nameserver, there are two methods:

A is added to the NIC configuration file:

Iface eth0 inet static

Address 192.168.3.3

Netmask 255.255.255.0

Gateway 192.168.3.1

Dns-nameservers 192.168.3.45 192.168.8.10

B. modify the configuration file of the resolvconf service:/etc/resolvconf/resolv. conf. d/base

Echo "search test.com">/etc/resolvconf/resolv. conf. d/base

Echo "nameserver 202.106.0.20">/etc/resolvconf/resolv. conf. d/base

Sometimes, you need to add a tail file to write DNS to the tail, and sometimes directly write to the base or original.

In this way, you can ensure that the configuration will be written to/etc/resolv. conf when the machine or resolvconf service is restarted.

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.