/etc/mygate

hashier

Well-Known Member
Hi,

ich will den default gateway an meiner OBSD Box setzen:


Code:
bash-3.00# echo 192.168.245.55 > /etc/mygate
bash-3.00# cat /etc/mygate
192.168.245.55
bash-3.00#


Dann ein reboot:

Code:
bash-3.00# netstat -r|grep 254
192.168.254/24     link#4             UC          0        0      -   dc1
bash-3.00# route show |grep 254
192.168.254/24     link#4             UC          0        0      -   dc1
bash-3.00# route add default 192.168.254.55
add net default: gateway 192.168.254.55
bash-3.00# route add default 192.168.254.55
route: writing to routing socket: File exists
add net default: gateway 192.168.254.55: File exists
bash-3.00#


Ich muss den Gateway also immernoch per Hand setzen, wasist noch falsch?
 
beim booten wird /etc/netstart ausgeführt wo folgender code drinstehen sollte

Code:
root@firewall:~$ cat /etc/netstart  | grep gate

# /etc/mygate, if it exists, contains the name of my gateway host
if [ -f /etc/mygate ]; then
        route -qn add -host default `cat /etc/mygate`

für den rest zu diesem script "man netstart"

ich könnte mir vorstellen das dieses script eventuell nicht geladen wird ....
 
eine sache wär da noch ...

das netstart script wird in der "/etc/rc" aufgerufen

auszug hier ...

Code:
echo 'starting network'
. /etc/netstart
 
bash-3.00# cat /etc/netstart | grep gate
# /etc/mygate, if it exists, contains the name of my gateway host
if [ -f /etc/mygate ]; then
route -qn add -host default `stripcom /etc/mygate`

bash-3.00# stripcom
bash: stripcom: command not found



double-p, ja! Ok. Das ist auch ne moeglichkeit.
Komisch ich hab die datei zich mal angelegt aber jedesmal konsequent 245 getippt aber mit route add default 254.
Wenn man was falsch macht, dann auch richtig durchgaengig.

Mal rebooten mit richtiger nummer. Mal schauen vll wars das schon.
 
hashier schrieb:
bash-3.00# cat /etc/netstart | grep gate
# /etc/mygate, if it exists, contains the name of my gateway host
if [ -f /etc/mygate ]; then
route -qn add -host default `stripcom /etc/mygate`

bash-3.00# stripcom
bash: stripcom: command not found
stripcom ist kein Befehl, sondern eine Funktion im Script /etc/netstart :)
Deswegen kannst du es auch nicht von der Console aus direkt starten.
 
PlantMan schrieb:
stripcom ist kein Befehl, sondern eine Funktion im Script /etc/netstart :)
Deswegen kannst du es auch nicht von der Console aus direkt starten.
außer natürlich du kopierst sie dir raus :) ist recht nützlich...

Code:
# Strip comments (and leading/trailing whitespace if IFS is set)
# from a file and spew to stdout
stripcom() {
        local _file="$1"
        local _line

        {
                while read _line ; do
                        _line=${_line%%#*}                # strip comments
                        test -z "$_line" && continue
                        echo $_line
                done
        } < $_file
}

ist übrigens auch in /etc/rc

auf bald
oenone
 
Zurück
Oben