How do I set up an IP address on a Linux VM running in VM Player so I can access it from my Windows 7 host?

78,503

New solution suitable for the Poster's setup. I cannot simplify it more than this.

Step 1: In VMWare Player's main window, right click on the VM name and select "Virtual Machine Settings".

Step 2: In the settings window, click on "Network Adapter" and among the options on the right, select "Host-only: a private network shared with the host".

Step 3: click ok.

BE SURE: The VMWare Player settings must be the default. If you fooled around with the various virtual network interfaces VMWare creates during installation, this won't work.

Step 4: Boot your virtual machine.

Step 5: If you have access to the linux command prompt, assign the ip address 192.168.40.129 like this (if you have root access):

ifconfig eth0 192.168.40.129 netmask 255.255.255.0

or Step 5b: sudo ifconfig eth0 192.168.40.129 netmask 255.255.255.0 (if you don't have root access).

In Windows:

Step 6: open the start menu and launch "Command Prompt". You find it in All Programs -> Accessories.

Step 7: Inside the command prompt, type ipconfig /all and press enter. One of the lines should display something like this:

Ethernet adapter VMware Network Adapter VMnet1:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 192.168.40.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0

The first three dotted groups of numbers should be identical to the one you configured inside your VM. The Subnet Mask should be identical to the one you added after the word "netmask" in the linux command you typed in Step 5.

Step 8: With the VM running, switch back to Windows and from the command prompt you opened in Step 6, type ping 192.168.40.129

You should get an output pretty much like this:

Pinging 192.168.40.129 with 32 bytes of data:
Reply from 192.168.40.129: bytes=32 time<1ms TTL=64
Reply from 192.168.40.129: bytes=32 time<1ms TTL=64

Step 9: On Windows, open up your browser and type in: http://192.168.40.129.

Let me know if it works.

EDIT:

This answer takes for granted a "normal" home networking setup with a simple subnet and a simple private addressing. Different/more complex setups (such as a corporate network etc) will require a few modifications to the commands in order to work and you might have to check for other things. In a Home scenario with a simple home router, this should work.

EDIT#2:

Fixed a typo. The virtual machine should have a different address in the same network. So the very last number to the right should change, everything else should remain the same.

EDIT#3:

Original Poster's setup is not common (lack of any kind of network whatsoever save from a 3G connection, which is not suitable) so the original solution involving bridged networking (which would have allowed the virtual machine to reach internet) was scrapped. Current solution uses the "host-only" virtual adapter. Less flexible but given the limited requirements of the poster, suitable.

Original solution attached for archival purpose:

--- ORIGINAL SOLUTION ---

Scrap the bit about dns, you do not need it.

Turn off the virtual machine and go into its settings and under the Network Adapter option choose "bridged networking" (rather than Host-ONly or NAT).

In Windows, find out your local IP address.

You can find it out by going into the system tray, bottom right, and right click on the "status" option for your network connection. There should be a button called "details" that will give you, among other data, your current IP Address.

It will be likely something on the line of 192.168.1.102 or 192.168.0.102 etc. Once you have your Windows IP address (for the sake of this we will assume it is 192.168.1.102),

Turn on again the virtual machine and if you have access to the linux command prompt, type this (logged in as root):

ifconfig eth0 address 192.168.1.103 netmask 255.255.255.0

If you don't have direct root access add "sudo" at the start of the line:

sudo ifconfig eth0 address 192.168.1.103 netmask 255.255.255.0

Then switch back to Windows and in your browser type http://192.168.1.103

--- END ---

Share:
78,503

Related videos on Youtube

Zach Saucier
Author by

Zach Saucier

Updated on September 18, 2022

Comments

  • Zach Saucier
    Zach Saucier almost 2 years

    I have just installed an Openbravo appliance on my Windows 7 VM Player host. I am now staring at a command prompt that tells me to go to http://localhost to access the ERP system, but I cannot find any browser on the appliance. I am guessing I should rather follow their advice to configure an IP address for the Linux VM and just access that from a Windows browser on my host. How do I go about this? More specifically,

    1. How do I choose a local IP address to assign?
    2. How do I set things up so that this IP address is visible to my Windows host?

    Their help says to assign an DNS, to make the server visible to the internet, but internet visibility per se is not needed. How should I interpret or adapt this help for that?

    Finally to make the IP address available to the Internet, assign some DNS servers to it: $ echo "nameserver IP_DNS1" >> /etc/resolv.conf $ echo "nameserver IP_DNS2" >> /etc/resolv.conf

  • Zach Saucier
    Zach Saucier almost 12 years
    I get a hostname lookup error with 'address' in the command line you suggest.
  • ItsGC
    ItsGC almost 12 years
    some distributions need to omit the "address" field, so it would be ifconfig eth0 192.168.1.103 netmask 255.255.255.0 Also,you need a proper network connection. It is enough to connect your pc to a network switch. In that case you will have to also assign a static IP to your Windows PC. I pointed out that it would have worked properly only in a "normal" situation :) There are several ways of obtaining what you want to do but this is the only one that is easily explainable without using documentation (i don't have VMWare on hand at the moment and i'm going by memory). I'll post more tonight.