osx - Address VMWare Fusion Linux guest by hostname?

01
2013-08
  • amrox

    I have a Ubuntu Server 9.04 image set up in VMWare Fusion 3.0.0, using the NAT option for the guest's network connection. From the Mac host, I can ssh to the linux guest just fine using it's IP address, but I would like to be able to refer to it by hostname for convenience. ie:

    mac-host:~ ssh [email protected]
    

    I had a similar setup using Parallels a couple years ago, but I don't remember how it was set up. It may have "just worked".

    Any suggestion on how to make this work?

  • Answers
  • Shannon Severance

    EDIT The first version of instructions I posted caused conflicts with the nameserver and gateway that VMware put on vmnet8. This version corrects the issue.

    Software versions:

    • MAC OS X Version 10.6.3
    • VMware Fusion Version 3.1.0 (261058)
    • Ubuntu 10.04 LTS

    What I have done:

    • During creation of the VM, set networking to NAT.

    • On Linux Guest: Run ifconfig to get the hardware address HWaddr, broadcast address Bcast, IPv4 internet address inet addr, and mask Mask being used.

      UbuntuGuest$ifconfig
      eth0      Link encap:Ethernet  HWaddr 00:0c:29:53:bf:e5  
                inet addr:192.168.213.129  Bcast:192.168.213.255  Mask:255.255.255.0
                       <snip>
      
    • On Linux Guest: Lookup the nameserver information

      UbuntuGuest$cat /etc/resolv.conf
      nameserver 192.168.213.2
      domain localdomain
      search localdomain
      
    • On Linux Guest: Lookup the gateway address: (Listed in the Gateway column of the line with 0.0.0.0 as Destination.)

      UbuntuGuest$route -n
      Kernel IP routing table
      Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
      192.168.213.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
      0.0.0.0         192.168.213.2   0.0.0.0         UG    100    0        0 eth0
      
    • On OS X Host: Edit the dhcpd.conf file for vmnet8 (The NAT virtual switch) to assign a static IP address to the Linux Guest. (Use your editor of choice on the fourth line)

      OSXHost$cd /Library/Application\ Support/VMware\ Fusion/vmnet8/
      OSXHost$sudo chmod u+w dhcpd.conf
      OSXHost$sudo cp dhcpd.conf dhcpd.conf.bak.20100619
      OSXHost$sudo emacs dhcpd.conf
      
    • On OS X Host: The file will start out looking something like:

      # Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet8.
      #
      # This file was automatically generated by the VMware configuration program.
      # See Instructions below if you want to modify it.
      #
      # We set domain-name-servers to make some DHCP clients happy
      # (dhclient as configured in SuSE, TurboLinux, etc.).
      # We also supply a domain name to make pump (Red Hat 6.x) happy.
      #
      
      
      ###### VMNET DHCP Configuration. Start of "DO NOT MODIFY SECTION" #####
      # Modification Instructions: This section of the configuration file contains
      # information generated by the configuration program. Do not modify this
      # section.
      # You are free to modify everything else. Also, this section must start
      # on a new line
      # This file will get backed up with a different name in the same directory
      # if this section is edited and you try to configure DHCP again.
      
      
      # Written at: 12/26/2009 10:35:10
      allow unknown-clients;
      default-lease-time 1800;                # default is 30 minutes
      max-lease-time 7200;                    # default is 2 hours
      
      
      subnet 192.168.213.0 netmask 255.255.255.0 {
            range 192.168.213.128 192.168.213.254;
            option broadcast-address 192.168.213.255;
            option domain-name-servers 192.168.213.2;
            option domain-name localdomain;
            default-lease-time 1800;         # default is 30 minutes
            max-lease-time 7200;             # default is 2 hours
        option routers 192.168.213.2;
      }
      host vmnet8 {
          hardware ethernet 00:50:56:C0:00:08;
          fixed-address 192.168.213.1;
          option domain-name-servers 0.0.0.0;
          option domain-name "";
          option routers 0.0.0.0;
      }
      ####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######
      

    Things to note:

    • The subnet section should match the IP information gathered on the Linux Guest. The inet addr will be within range, netmask will match Mask, option broadcast-address will match Bcast, option domain-name-servers and option domain-name will match the information gathered with cat /etc/resolv.conf and option routers will match Gateway from the route -n command.

    • We want to assign a static IP address, so that we can add an entry to the OS X Host's hosts file. The address must be within the subnet defined. Addresses that are not available to assign are the ones within range in subnet section, the broadcast address, the fixed-address for host vmnet8, the DNS server and the gateway. And I think the address equal to subnet is not allowed. In this example, the subnet is 192.168.213.0 So the available addressees are from 192.168.213.1 to 192.168.213.255 less 192.168.213.128 to 192.168.213.245 (range) less 192.168.213.255 (broadcast) less 192.168.213.1 (host vmnet8) less 192.168.213.2 (gateway and DNS server). The net is that addresses 192.168.213.3 to 192.168.213.127 are available.


    • ON OS X Host: Create a new host entry below the DO NOT MODIFY SECTION. This entry will assign a static IP to the Linux Guest. hardware ethernet needs to match HWaddr from ifconfig on the Linux Guest. Pick an available static address for fixed-address. option broadcast-address, option domain-name-servers, option domain-name and option routers need to match the options given in the subnet section of dhcpd.conf. (Which we have already matched against information gathered on the Linux Guest.) In this example the host entry is:

      ####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######
      host serpents-hold {
          hardware ethernet 00:0c:29:53:bf:e5;
          fixed-address 192.168.213.3;
          option broadcast-address 192.168.213.255;
          option domain-name-servers 192.168.213.2;
          option domain-name localdomain;
          option routers 192.168.213.2;
      }
      
    • On OS X Host Save dhcpd.conf and close your editor.

    • On OS X Host and all Guests: Shutdown all VMs and VMware.

    • On OS X Host: Restart the VMware services:

      OSXHost$cd /Library/Application\ Support/VMware\ Fusion/ 
      OSXHost$sudo ./boot.sh --restart 
      
    • On OS X Host: Look in Activity Monitor and make sure that two processes each named vmnet-dhcpd are running. (One is for the vmnet8, the NAT network, the other is for the host only network.) If you don't see both, there is probably a problem with the vmnet8/dhcpd.conf file on the OS X Host. Fix that and repeat the restart of VMware services.

    • On OS X Host: Start VMware and the Linux Guest VM.

    • On Linux Guest On the guest VM check that settings are as expected:

      UbuntuGuest$ifconfig
      eth0      Link encap:Ethernet  HWaddr 00:0c:29:53:bf:e5  
                inet addr:192.168.213.3  Bcast:192.168.213.255  Mask:255.255.255.0
                inet6 addr: fe80::20c:29ff:fe53:bfe5/64 Scope:Link
                UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                RX packets:103 errors:0 dropped:0 overruns:0 frame:0
                TX packets:71 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000 
                RX bytes:10961 (10.9 KB)  TX bytes:9637 (9.6 KB)
      lo <snip>    
      UbuntuGuest$cat /etc/resolv.conf
      nameserver 192.168.213.2
      domain localdomain
      search localdomain
      UbuntuGuest$route -n
      Kernel IP routing table
      Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
      192.168.213.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
      0.0.0.0         192.168.213.2   0.0.0.0         UG    100    0        0 eth0
      UbuntuGuest$
      
    • On Linux Guest: Check that the outside world is reachable:

      UbuntuGuest$ping google.com
      PING google.com (72.14.213.104) 56(84) bytes of data.
      64 bytes from pv-in-f104.1e100.net (72.14.213.104): icmp_seq=1 ttl=128 time=47.6 ms
      64 bytes from 2.bp.blogspot.com (72.14.213.104): icmp_seq=2 ttl=128 time=48.7 ms
      64 bytes from 2.bp.blogspot.com (72.14.213.104): icmp_seq=3 ttl=128 time=48.2 ms
      ^C
      --- google.com ping statistics ---
      4 packets transmitted, 3 received, 25% packet loss, time 3093ms
      rtt min/avg/max/mdev = 47.687/48.223/48.714/0.491 ms
      UbuntuGuest$
      
    • On OS X Host: Add a mapping for the hostname to the hosts file:

      OSXHost$cd /etc
      OSXHost$sudo emacs hosts
      

      Add a line to the end of the hosts file using the Linux Guest's hostname and the IP address assigned above.

      192.168.213.2   serpents-hold
      
    • On OS X Host: Save file and exit emacs.

    • On OS X Host: Test that the Linux Guest is reachable by hostname:

      OSXHost$ping serpents-hold
      PING serpents-hold (192.168.213.3): 56 data bytes
      64 bytes from 192.168.213.3: icmp_seq=0 ttl=64 time=0.169 ms
      64 bytes from 192.168.213.3: icmp_seq=1 ttl=64 time=0.244 ms
      ^C
      --- serpents-hold ping statistics ---
      2 packets transmitted, 2 packets received, 0.0% packet loss
      round-trip min/avg/max/stddev = 0.169/0.207/0.244/0.037 ms
      OSXHost$
      
  • Jon Lasser

    You could configure zeroconf using Avahi, which should allow the client to identify itself on a network without DNS registration.

  • Ahmad

    This Mac feature is called Bonjour. To enable the equivalent on Ubuntu, you need to install a package called libnss-mdns by entering this command in the Ubuntu guest machine:

    sudo apt-get install libnss-mdns

    Once the packages are installed, the feature should work instantly.

    The feature only works within the local network. If you are using NAT networking, this means that the feature will only work within the host machine and its VMs. If you want the feature to work across your larger home network, you need to use Bridged mode so that your VM participates in your home network by getting its IP address, etc, from the home networks router/DCHP server.

  • yanokwa

    assuming you just want to login over a command line, why not create an ssh config file? i do something like this for my vm.

    # ~/.ssh/config
    Host linux-box    
    Hostname localhost
    Port 8822
    

    then i can

    mac-box:~ ssh linux-box
    
  • William Hilsum

    If you are using NAT, it may try to register with DNS servers, however to computers other than the host, it's IP will be the same as your machines and can cause a few problems.

    I would recommend that you switch to bridged networking as this will give it its own IP address and to any machine, it will look and feel like any other machine on the network. If you set up all the IP settings correctly (or use DHCP), it should automatically register and you should not have a problem doing anything on any port via IP or hostname.



  • view all most popular Amazon Coupons
    .

    Related Question

    osx - Ubuntu 9.10 Virtual Machine does not respond in VMWare Fusion
  • Ye Lin Aung

    I've just installed Ubuntu 9.10 Edition in VMWare Fusion; the host is Mac OS X. I installed it successfully and I was even able to use. After shutting it down and reopening it, it no longer works. Here's what I see:

    alt text

    I've checked the Virtual Machine settings. It appears as running. I waited for a long time, but there no response yet. Is there anything I can do apart from reinstalling it?


  • Related Answers
  • Ye Lin Aung

    well, the only solution I've found out myself and due to above comments, reinstalling is the best and easy ..

  • lavamunky

    Are you sure it definitely installed? I had this problem once when it didn't actually install properly but it still took the disc out after (unmounted the ISO) and it just hung like that. Try going Virtual machine in menu bar-> settings-> CDs & DVDs and then set it to the ISO image (presuming that's what you used) And then try restarting it, it should hopefully boot to the live cd and then you can go about 'installing' again.

    It could be there's a problem with the ISO you are using.

    When it says 'running' this doesn't mean it installed properly, just that it's like you've physically turned on a computer. As a computer with no OS is still technically running