VMWare Fusion Linux-Gast über den Hostnamen ansprechen?

9730
amrox

Ich habe ein Ubuntu Server 9.04-Image in VMWare Fusion 3.0.0 eingerichtet, das die NAT-Option für die Netzwerkverbindung des Gasts verwendet. Vom Mac-Host aus kann ich ssh mit dem Linux-Gast problemlos über seine IP-Adresse verbinden, aber ich möchte aus Gründen der Bequemlichkeit mit dem Hostnamen darauf verweisen können. dh:

mac-host:~ ssh user@linux-guest.local 

Ich hatte vor einigen Jahren ein ähnliches Setup mit Parallels, aber ich weiß nicht mehr, wie es eingerichtet wurde. Es kann "gerade geklappt haben".

Irgendwelche Vorschläge, wie das funktioniert?

11

5 Antworten auf die Frage

14
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$ 
Das ist großartig ... wenn Sie einen OSX-Host verwenden. Ich wünschte, ich könnte die Fenster irgendwo finden. tj111 vor 13 Jahren 0
Tolle Infos. Vielen Dank. 2 Updates für v4.x 1. Der Speicherort von dhcpd.conf ist jetzt: "/ Library / Preferences / VMware Fusion /" 2. In Fusion 4 wird der Netzwerkdienst nicht ausgeführt, wenn Fusion heruntergefahren wird. Starten Sie Fusion neu, um den Netzwerkdienst neu zu starten. sym3tri vor 12 Jahren 1
8
hashemi

Die einzige Antwort auf die ursprüngliche Frage besteht darin, diesen Befehl auszuführen:

$ sudo apt-get install libnss-mdns

Durch die Installation dieses Pakets sollte die Funktion sofort aktiviert werden. Sie können dann auf Ihre VM unter zugreifen your-vm-hostname.local. Dies funktioniert nur innerhalb des lokalen Netzwerks der VM, je nachdem, wie Sie es in Ihrer Virtualisierungssoftware konfiguriert haben.

Diese Funktion wird von allen anderen Bonjour von Apple und Zeroconf genannt. Es ist in OS X und iOS integriert. Der einfachste Weg unter Windows ist die Installation von iTunes für Windows.

Damit muss ich '.local' an den Namen des Gastrechners anhängen, z. B. `ubuntu-guest.local ', wenn ich von der Host-Seite auf ihn verweise. Abgesehen davon funktioniert das wunderbar! Nathaniel Waisbrot vor 10 Jahren 0
@ NathanielWaisbrot Das stimmt. Das wollte das ursprüngliche Poster. hashemi vor 10 Jahren 0
3
Jon Lasser

Sie können zeroconf mithilfe von Avahi konfigurieren, wodurch sich der Client ohne DNS-Registrierung in einem Netzwerk identifizieren kann.

2
yanokwa

Wenn Sie sich nur über eine Befehlszeile anmelden möchten, erstellen Sie eine ssh-Konfigurationsdatei . ich mache so etwas für meine vm.

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

dann kann ich

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

Wenn Sie NAT verwenden, wird möglicherweise versucht, sich bei DNS-Servern zu registrieren. Bei anderen Computern als dem Host ist die IP-Adresse jedoch dieselbe wie für Ihre Computer und kann zu einigen Problemen führen.

Ich würde Ihnen empfehlen, auf Bridged Networking umzusteigen, da dies ihm eine eigene IP-Adresse gibt und für jeden Computer wie jeder andere Computer im Netzwerk aussieht. Wenn Sie alle IP-Einstellungen korrekt eingerichtet haben (oder DHCP verwenden), sollte sich dies automatisch registrieren, und Sie sollten an keinem Port über IP oder Hostnamen Probleme haben.

Ja, ich denke, das würde funktionieren, aber ich würde ein stabiles privates Netzwerk vorziehen. Die VM befindet sich auf einem Laptop, der sich bewegt und manchmal keine Internetverbindung hat. Wenn ich den Bridged-Modus verwendet habe, kann ich ihn nicht kontaktieren, wenn der Host offline war. amrox vor 14 Jahren 1