#!/bin/sh # Script by Ypnose - http://ywstd.fr set -ex if [ "$#" -lt 2 ] || [ "$1" = "-h" ]; then printf "usage: %s [INTERFACE] [-d] [IP] [ROUTE]\n" "${0##*/}" exit fi if [ "$2" = "-d" ]; then ip link set dev "$1" down ip addr flush dev "$1" exit fi ip addr add "$2" dev "$1" ip link set dev "$1" up if [ -n "${3:+s}" ]; then ip route add default via "$3" fi exit