VMware Communities
deeps_10
Contributor
Contributor

how do I create a loopback adapter on mac?

Hi,

I use vmplayer on windows quite often.  On Window when I don't have an active network adapter, I normally create a loopback adapter which I assign an IP address to. I then assign an IP address to my VM(s) in the same range of the IP address I gave to my loopback adapter.  This then allows my VM to communicate with the Host and one another over IP.

I am looking to do the same on OSX.  However after doing some research online I can't seem to find a way to create a loop back adapter, can anyone point me in the right direction or have I missed something?

Remember I am looking to do this when I don't have any of my network adapters active e.g. when my ethernet and wifi have been disabled on my mac

thanks

0 Kudos
11 Replies
wila
Immortal
Immortal

Hello,

I was under the impression that the Host-Only network still worked even without a network connection, but I am rarely without a network and not quite willing to disrupt my current connections (and thus work) to test.

Anyways.. setting up localhost network addresses on OS X is fairly straightforward.


Here's the main contents of a script I have used to connect SSH connections to a loopback address:

if [ "$UID" -ne "0" ]

then

echo -e "You must be root to run this script.\nYou can use 'su -' or 'sudo' to get root access"

exit 1

fi

# create local aliases

ifconfig lo0 alias 127.0.0.88 up

ssh -N user@server

ifconfig lo0 alias 127.0.0.88 down

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos
deeps_10
Contributor
Contributor

Between the host and the individual VM(s) there is a host netowrk, but I need an IP path between host and also need the multiple VM(s) to be able to ping each once I assign a static IP to each of the VM network interfaces

0 Kudos
wila
Immortal
Immortal

Hi,

The "Host- only" network is a bit of a misnomer.

If you assign two VMs as host-only then they will be in the same network and can ping each other.

So they can communicate with each other AND with the host, but there's no route out of that virtual network.

Just to make sure I've verified this down here quickly and I can indeed ping without any trouble between the 2 VMs.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos
deeps_10
Contributor
Contributor

Hi Wila,

Good info thanks for the reply.  So you the two's VM can ping one another over IP, but I also need the VM's to ping to host over IP.  If I don't have an active network adapter e.g my wifi and ethernet is disabled, I have no way of assigning an IP adddress.

Looks like I will need to do what you said previously and setup up a local network address using the script you posted?

This will give me a virtual IP which I can assigned an IP too and this will achieve what I do with windows when creating a loopback adapter on the host.

0 Kudos
wila
Immortal
Immortal

Hello,

No, you asked for how-to setup a loopback network adapter and I gave you a way.

That won't work for connecting your VMs.

However you don't need it either.

As I was not working now I just plugged the network cable here and made sure that WiFi was disabled.

If you got your VMs in host-only networking then you CAN also access the host via the address as you can see for vmnet1 when running ifconfig in OSX. There is no problem, it should just work.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos
deeps_10
Contributor
Contributor

You are correct I did ask for this Smiley Happy

To confirm what I am trying to achieve is the follwing.

I have client software on the host and server software on the VM(s).  In the configuration of the client and server applications, static IP address need to be entered of all known computers for communication over IP

This is my work laptop and I travel a lot planes, trains and cannot not always have an active network connection on my laptop, if I have no active network connection then my host has no IP address assigned.

With my windows laptop because of the restriction on having an active network connection, I create a loopback adapter on the host which I assign a static IP address to, this loopback adapter is always active.  I then assign a static IP address to the VM(s).

Now I can ping over IP from the host to the VM (s), and the VM(s) can ping one another.

Is the above achievable with OSX, or do I keep using bootcamp with Windows and VM player?

As a workaround when traveling I create a hot spot on my phone and connect the wifi on my host to this hot spot, but this a work around, which I want to avoid.

0 Kudos
wila
Immortal
Immortal

Hi,

Somehow I guessed your environment involved planes and hotels Smiley Happy

Yes, that's correct. Just use host-only networking.

In addition you can also use NAT networking as that also keeps up a network interface with the added benefits that your guests now also have internet (look at vmnet8 for the IP to use for the host).

Actually that is what I use when in hotels on either Fusion or Workstation.

In my case I've got a firewall VM between it all as I consider hotel networks hostile (IOW I have an extra network that has only the guests and the firewall VM to route out to NAT or bridge depending on my needs)

Another benefit of the tiny firewall VM is that I can easily determine what IP my guests will end up with. No need to mess with static IPs.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos
deeps_10
Contributor
Contributor

Thanks for all the info wila, its been a real help!

I will have a go with this tomorrow, I don't have access the machine until then.  I am still little confused as to where would I set the static IP on the host macbook for this config?

thanks!

0 Kudos
wila
Immortal
Immortal

Hi,

You don't need to set the static IP of your host Macbook, it has already been set.

Just run this command in the terminal and it will show you the ip's

ifconfig -a | grep -A2 "vmnet"

vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500

    ether 00:50:56:e2:a1:05

    inet 172.16.31.1 netmask 0xffffff00 broadcast 172.16.31.255

--

vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500

    ether 00:50:56:f2:e2:08

    inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255

In the example here vmnet1 is the "host-only" network and you can access your host on IP 172.16.31.1

and vmnet8 is the "NAT" network and the host there is accessible on 192.168.0.1

Check the IP on your host as it will be different as what I display here.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos
deeps_10
Contributor
Contributor

Understood, the problem is I have a DNS server running on one of my VM(s) as communication is over IP and FQDN.  The name of the host and predefined IP is in that DNS table and my IP range for all my VM are already in the 10.134.103.X range, so I need my host also to be in that range too.

0 Kudos
wila
Immortal
Immortal

There's two ways... it is technically possible to muck around with VMware Fusion configuration files and adjust the NAT configuration to be in your preset IP range. As you can guess from my wording, I'm not a fan of that (updates might break your manual configuration etc..)

Another way is by using the network editor in VMware Fusion Pro.

This is a feature that is only available in the pro version, but you can create your own networks from the GUI.

Menu VMware Fusion -> Preferences -> Network tab

Click the lock to make changes

Click the "+" to add a new network

Then fill it out depending on what you need.

Screen Shot 2015-07-02 at 21.25.59.png

You talk about having a DNS server, if you also have a DHCP server running then you can uncheck the "Provide addresses via DHCP" choice.

As I said.. this is what I'm using myself, but then with a firewall VM for providing NAT/DNS and DHCP, so I don't have those options checked.

Now you not only have the options for NAT, Host Only and bridged to connect your network adapter to, but also (in my example above) vmnet2 and vmnet3.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos