Skip to content

Instantly share code, notes, and snippets.

@toonetown
Last active August 29, 2017 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toonetown/6015487b1ba11c69afad0b6429ecdd28 to your computer and use it in GitHub Desktop.
Save toonetown/6015487b1ba11c69afad0b6429ecdd28 to your computer and use it in GitHub Desktop.
Aliases localhost to an address
#!/bin/bash
if [ "$(id -u)" != "0" ]; then sudo "${0}" "$@"; exit $?; fi
if [ "${1}" == "-d" ]; then
[ -n "${2}" ] || { echo "Usage $0 [-d] <addr> [iface]"; exit 1; }
ifconfig ${3:-lo0} -alias ${2}
else
[ -n "${1}" ] || { echo "Usage $0 [-d] <addr> [iface]"; exit 1; }
ifconfig ${2:-lo0} alias ${1} 255.255.255.255
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment