Skip to content

Instantly share code, notes, and snippets.

@Tronde
Last active August 29, 2015 14:24
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 Tronde/49dd8507f9c3b1a58b2e to your computer and use it in GitHub Desktop.
Save Tronde/49dd8507f9c3b1a58b2e to your computer and use it in GitHub Desktop.
Standardgateway unter Linux hinzufügen
#!/bin/ash
# Default Gateway mit dem Kommando route hinzufügen
# Author: Joerg Kastning
# Lizenz: GPLv3
# Funktionen ##################################################################
usage()
{
cat << EOF
usage: $0 OPTIONS
Dieses Script fügt der Routing-Tabelle den Eintrag für
ein Standardgateway hinzu.
OPTIONS:
-h Zeigt diese Nachricht an.
-a <IP-Adresse> Gibt die IP-Adresse des Standardgateways an.
-i <Interface> Gibt die Schnittstelle (z.B. wlan0) an.
EOF
}
# Beginn des Skripts ##########################################################
while getopts .h:a:i:. OPTION
do
case $OPTION in
h)
usage
exit;;
a)
address="${OPTARG}"
;;
i)
interface="${OPTARG}"
;;
?)
usage
exit;;
esac
done
if [[ -z $address ]]; then
read -p "Bitte die IP-Adresse des Standardgateways eingeben: " address
fi
if [[ -z $interface ]]; then
read -p "Bitte die Schnitstelle (z.B. wlan0) eingeben: " interface
fi
route | grep default > /dev/null
if [[ $? == 1 ]]; then
route add default gw $address $interface
fi
exit
@Tronde
Copy link
Author

Tronde commented Jul 5, 2015

Ich nutze dieses Skript, um auf meiner Synology Diskstation DS213air das Standardgateway wieder hinzuzufügen, wenn das NAS dieses nach einem Neustart verloren hat.

Eine ausführliche Beschreibung dazu habe ich in meinem Blog veröffentlicht.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment