Configuring a static IP (NAT connection) for Ubuntu 12.04.1 under VMware virtual machines

Source: Internet
Author: User
Tags ranges nameserver

Background

Running the operating system under a virtual machine, especially a Linux system, is a very common practice. Sometimes you want to set up a (simulated) server under a virtual machine for host access, such as building a telnet/ssh. At this point you will find that every time you start a virtual machine, VMware assigns a dynamic IP to the virtual machine system, which makes it inconvenient to connect to the virtual machine's Telnet every time. It would be nice if it was set to a static IP.


VMnet8 and NAT

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


Confirm that the VMNET8 virtual network card is enabled

By default, VMWare workstation has enabled the VMNET8 virtual network card, under Windows 7, you can view the status of the virtual network card by going to Control Panel > Network and internet> Network and Sharing Center > changing adapter settings.


Get the available IP range, gateway, and subnet mask

In the VMware main interface, click the Edit>virtual Network Editor menu to enter the virtual network card parameter settings interface. Select the VMnet8 entry and click the NAT Settings button to see our VMware Workstation default gateway for NAT-connected virtual machines, here is 192.168.91.2, and the subnet mask, here is 255.255.255.0.

Click the DHCP Settings button to see VMnet8 the available subnet IP ranges assigned to the virtual machine.


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 obtained, here is 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 set the static IP into Ubuntu virtual machine.


Setting up a static IP in Ubuntu 12.04.1

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

sudo vi/etc/network/interfaces


2. Edit the file as follows:

Auto Lo
Iface Lo inet Loopback

# Assgin Static IP by Eric on 26-sep-2012
Iface eth0 inet Static
Address 192.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 here
#in order to get internet access from host
Dns-nameservers 192.168.91.2
Auto Eth0

Description

Address is the static IP address you want to assign to your virtual machine, and you can choose one of the available subnet IP ranges we just found here.

Netmask is a subnet mask

Gateway is gateways

Note: In a relatively early version, you need to set the resolv.conf file in/etc and add nameserver so that you can connect to the Internet. However, after Ubuntu 12.04, this is not recommended, because no matter what value you want to set in the configuration file, the restart will be reverted to its original state. The recommended practice is to 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.linux.com

If the ping responds, congratulations, you have successfully set the virtual machine as a static IP and are already connected to the Internet.

Configuring a static IP (NAT connection) for Ubuntu 12.04.1 under VMware virtual machines

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.