If anyone is interested - This is my Script to do this job (I've linked it into rc2.d/): (Sorry for the german messages)

it detects if my LAN PC Card is plugged in, and if it is, is sets up the network to my Linux Router at home. It also restores the resolv.conf file, because dhclient overwrites it everytime I go online with my Wireless LAN card at my university.

----------------------------------------------------------------
#!/bin/bash

# Aktiviert Zuhause die 3com-Netzwerkkarte (auf eth0)

case "$1" in
    start)
        if (grep "3c574_c" /var/lib/pcmcia/stab | grep "eth0")
                then
                echo Aktiviere Interface...
                ifconfig eth0 192.168.1.4 netmask 255.255.255.0 up mtu 1400
                echo Setze Route zum Heimnetzwerk...
                route add -net 192.168.1.0 netmask 255.255.255.0 eth0
                echo Setze Route ins Internet...
                route add default gw 192.168.1.3 eth0
                echo Stelle DNS-Eintraege fuer T-Online ein...
                cp /etc/resolv.conf.home /etc/resolv.conf
                echo Fertig !
        else
                echo "\b\b die Karte ist nicht eingesteckt, oder wurde nicht 
als"
                echo "eth0 initialisiert !!!"
        fi
        ;;
    stop)
        echo Entferne Default-Gateway...
        route del default gw 192.168.1.3 eth0
        echo Entferne Route zum Heimnetzwerk...
        route del -net 192.168.1.0 netmask 255.255.255.0 eth0
        echo Deaktiviere Interface...
        ifconfig eth0 192.168.1.0 netmask 255.255.255.0 down
        if (grep "3c574_c" /var/lib/pcmcia/stab | grep "eth0")
                then
                echo
                echo "*** Die Karte kann bei Bedarf jetzt entfernt werden ! ***"
                echo
        else
                echo "\b\b **** Die Karte wurde anscheinend bereits entfernt !!! 
***"
                echo "Nicht nochmal machen ;-)"
        fi
        ;;
    *)
        echo $0
        echo "home-net <COMMAND>"
        echo
        echo "home-net start       Aktiviert das Netzwerk bei Martin zuhause"
        echo "home-net stop        Deaktiviert es wieder"
        echo
        echo "Die 3Com-Karte muss als eth0 geladen und aktiv sein !!!"
        ;;
esac
-------------------------------------------------------------

If you think you might find it useful, I could translate and re-post it.

Martin

dman wrote:

On Thu, Dec 13, 2001 at 12:51:19PM -0800, Greg Wiley wrote:
| On Thursday, December 13, 2001 12:26 PM, dman wrote:
| | > Usually this means your network interface isn't up. (like if I turn
| > on the laptop, but forget to "sudo ifup eth0" first)
| | In case you're interested, here's a strategy to configure laptop
| ethernics automatically--even if you have a hardware config
| that changes regularly (docking, PCMCIA, whatever).
| | http://www.orthogony.com/gjw/lap/lap-ether-intro.html

Thanks for the examples!  Now I understand how the mapping thing is
supposed to work.  Also that check-link.sh script is really cool.

The only problem left (for me) is :  how can it automatically
determine whether or not to use DHCP (that is, is the link from home
or not).  I don't think that can be automated (GPS ;-)?).  What I
really need to do is configure dhcpd at home sometime.

-D




Reply via email to