How to Set Up a Local Loopback Alias

This guide shows you how to add a loopback alias on macOS so a locally installed platform is reachable at a fixed address, and how to confirm the alias took effect.

Type

How-to guide

Goal

Reach a locally installed Axual Platform at a stable IP address from the host machine.

Audience

Anyone running the platform on their own macOS machine, with sudo on it.

When to use

Use this guide before a local installation, and again after every restart of the machine.

This applies to local installations on macOS only. A cluster installation needs none of it. Some local cluster tools provide their own tunnel process to expose LoadBalancer Services to the host instead; where yours does, the quick-setup guides cover it.

The alias does not survive a restart. Run the script again after every reboot, or the platform’s host names stop resolving.

Contents

The sections below cover each task in this guide:

Prerequisites

Confirm the following before you begin.

Access and permissions required

You need the following access and permissions:

  • sudo on the macOS machine. Changing an interface with ifconfig needs it, and so does writing to /etc/hosts.

Tools and versions required

The commands below use ifconfig, which ships with macOS, and a text editor that can save /etc/hosts as root. Nothing has to be installed.

Resources that must exist before starting

This guide runs before you install the platform, so nothing has to exist on a cluster first. You do need the host name you will reach the platform at, platform.<domain> in the example below, because the hosts entry maps that name to the alias address.

Add the alias

The script below removes the alias if it is already present and then adds it, so it is safe to re-run. It uses 192.168.99.100 as an example address, and any other free address in the 192.168.99.0/24 range works as well. Whichever you pick, use the same address in the script, in the hosts entry, and everywhere you reach the platform.

  1. Save the following script as loopback-alias.sh. It adds a loopback alias on the address at the top of the file.

    #!/bin/bash
    
    ITF=lo0
    ADDRESS=192.168.99.100
    
    ifconfig "$ITF" | grep inet | grep "$ADDRESS" >/dev/null
    if [ "$?" = "0" ]; then
    	echo "Removing alias $ADDRESS from interface $ITF"
    	sudo ifconfig "$ITF" -alias "$ADDRESS"
    	echo "Adding alias $ADDRESS to interface $ITF"
    	sudo ifconfig "$ITF" alias "$ADDRESS/32" up
    else
    	echo "Adding alias $ADDRESS to interface $ITF"
    	sudo ifconfig "$ITF" alias "$ADDRESS/32" up
    fi
  2. Run the script. It prompts for your password, because ifconfig runs under sudo.

    bash ./loopback-alias.sh
    A loopback alias is dropped when the machine reboots, so run the script again after every restart. None of the other steps have to be repeated.
  3. Add the following entry to your /etc/hosts file, using the same address as the script.

    192.168.99.100 platform.<domain>

Verify the alias

Confirm the address is on the loopback interface.

ifconfig | grep 192.168.99.100

The command reports the address on lo0:

	inet 192.168.99.100 netmask 0xffffffff

No output means the alias is not there: the script ran against a different interface, or sudo did not authenticate.