[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: /etc/interfaces for logical interfaces

On 12/27/05, Felix C. Stegerman <flx@hccnet.nl> wrote:

> I would recommend using laptop-net. It can automagically detect
> whether you're at home or at work and adjust the network settings
> accordingly.
> With my setup, it looks for ip (my router at home) and
> if it is found uses ip Otherwise it uses DHCP
> (at university).
Above is also good. However even for above, you need to set the static
IP of Home PC. See what IP your office net dhcp offers. If it is
192.168.1.x as mentioned above, then set home pc as
If you don't want to install additional package, use the following
script(taken from this list and modified) as getting host ip at home.
Else default will be dhcp at office.

#if [ `id -u` -ne 0 ] || [ "$1" = "" ]; then exit 1; fi

ARPING="/usr/sbin/arping -fqc5"


while read addr pingme scheme; do
        if [ "$which" ]; then continue; fi
        if [ $scheme = nolink ];then which=nolink;echo $which;exit 0;fi

        #echo "  Trying $addr & $pingme ($scheme)" >&2
        ip addr add $addr dev $iface  >/dev/null 2>&1
        ip link set $iface up         >/dev/null 2>&1
        if $ARPING $pingme >/dev/null 2>&1; then
        ip link set $iface down       >/dev/null 2>&1
        ip addr del $addr dev $iface  >/dev/null 2>&1

if [ "$which" ]; then echo $which; else exit 1;fi
put the above script in /usr/local/bin.(of course with chmod +x)
Then use following
iface lo inet loopback

mapping eth0
        script  /usr/local/bin/arpip.sh
        map home
# Home network configuration
iface home inet static
        gateway      //if you use you home pc for coonecting to net

 # If not is found, try DHCP
 iface none inet dhcp

linux user No.205042

Reply to: