Configure static IP (NAT) for Ubuntu under VMware virtual machines

Source: Internet
Author: User
Tags ranges nameserver

Turn from: http://www.cnblogs.com/objectorl/archive/2012/09/27/vmware-ubuntu-nat-static-ip-settings.html


Background

Running the operating system under a virtual machine, especially Linux, is a very common practice. Sometimes you want to build an (analog) server under a virtual machine for host access, such as a telnet/ssh. At this point you will find that each time you start a virtual machine, VMware assigns a dynamic IP to the virtual machine system, which is inconvenient when you connect to the virtual machine telnet. If you set the static IP is good.

VMnet8 and NAT

If your virtual machine is connected to the Internet by NAT, then the virtual machine's IP address is not matched, and the gateway and Internet access are provided by VMware, called the VMNET8 virtual network card. So all the settings related to setting up static IP can be found from here. VMnet8 Virtual network card, the host can access the virtual machine IP, virtual machine can connect to the host's Internet connection into the extranet.

Confirm that the VMNET8 virtual NIC is enabled

By default, VMWare workstation has enabled the VMNET8 virtual network card, under Windows 7, you can view the status of the virtual NIC by entering Control Panel > Network and internet> Network and Sharing Center > changing adapter settings. As shown in Figure 1-1.

Figure 1-1

Get available IP ranges, gateways, and subnet masks

In the VMware main interface, click the Edit>virtual Network Editor menu to enter the virtual NIC parameter setup interface (Figure 1-2). Select the VMnet8 entry and click on the NAT Settings button to see the default gateway set by our VMware Workstation for NAT-connected virtual machines, 192.168.91.2, and the subnet mask, here is 255.255.255.0, As shown in Figure 1-3.

Figure 1-2

Figure 1-3

Click the DHCP Settings button to see the available subnet IP ranges VMnet8 for the virtual machine, as shown in Figure 1-4.

Figure 1-4

Here, our subnet IP available range is 192.168.91.128~192.168.91.254

OK, so far, all the information we need has been captured, and here's a summary,

-Subnet IP available range: 192.168.91.128~192.168.91.254

-Subnet Mask: 255.255.255.0

-Gateway: 192.168.91.2

Below begins to enter the Ubuntu virtual machine to set up static IP.

Set up static IP in Ubuntu 12.04.1

1. Start the virtual machine Ubuntu system, open the terminal, use the following command to open and edit the network interface configuration file:

sudo vi/etc/network/interfaces

2. Edit the document as follows:

Auto lo
iface lo inet loopback

# Assgin static IP by Eric in 26-sep-2012 iface eth0 inet
static address
19 2.168.91.200 #change to your static IP
netmask 255.255.255.0  #change to your netmask
gateway 192.168.91.2
   #change to your getway
#We must specify Dns-nameserver this #in order to get
Internet access from host
dns- Nameservers 192.168.91.2
Auto eth0

Description

Address is one of the static IP addresses you want to assign to your virtual machine, which you can choose from the available subnet IP range that we just found.

Netmask is a subnet mask

Gateway is gateways

Note: In a relatively early version, you need to set up the resolv.conf file under/etc and add nameserver so that you can connect to the Internet. But after Ubuntu 12.04, this is not recommended, because no matter what value you want to set in the configuration file, the reboot will be restored to the original state. It is recommended that you add the Dns-nameserver < gateway Ip> Line directly to the interfaces configuration file.

3. Restart the Ubuntu network card

sudo/etc/init.d/networking restart

4. Ping Test Internet connectivity

Ping www.baidu.com

If the ping is responding, congratulations, you have successfully set the virtual machine to static IP and have been connected to the Internet.

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.