Re: setting up network
Hi.
On Sun, 23 Jan 2005 19:07:54 +0000
Pollywog <linux-debian@shadypond.com> wrote:
> On 01/23/2005 06:50 pm, Alan Pope wrote:
> > On Sun, 23 Jan 2005 18:37:02 +0000, Pollywog
> > <linux-debian@shadypond.com>
> wrote:
> > > I am planning to stay at a hotel which has Internet access but I
> > > know nothing about the IP addresses they use. I am assuming they
> > > use dhcp. If I know nothing of their network, what is the most
> > > convenient way to get my laptop connected?
>
> [...]
>
> > So you currently use static IP addresses?
>
> Yes, at home I use static addresses.
>
I use the map-scheme to decide which connection has to be used. If you
have an Internet router at home your laptop can ping on this should
work.
You have to define a mapping in /etc/network/interfaces:
<snip>
mapping eth0
script /usr/local/sbin/map-scheme
map HOME eth0-home
map HOTEL eth0-hotel
iface eth0-home inet static
address 192.168.1.3
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if
installed dns-nameservers 192.168.1.1
dns-search your-nework.de
iface eth0-hotel inet dhcp
</snip>
And of course the file /usr/local/sbin/map-scheme:
#!/bin/sh
#
# Check whether I am at home or at hotel
#
# your NIC
DEV=eth0
# your ip-address
ADDR=192.168.1.2/24
# ip-address of host to ping on
GATEWAY=192.168.1.1
if [ `id -u` -ne 0 ]; then exit 1; fi
if [ -x /usr/bin/fping ]; then
PING="/usr/bin/fping"
else
PING="/bin/ping -c 2"
fi
ip addr add $ADDR dev $DEV >/dev/null 2>&1
ip link set $DEV up >/dev/null 2>&1
if $PING $GATEWAY >/dev/null 2>&1; then
IFACE="eth0-home"
else
IFACE="eth0-hotel"
fi
ip link set $DEV down >/dev/null 2>&1
ip addr del $ADDR dev $DEV >/dev/null 2>&1
echo $IFACE
# EOF
Probably this is what you want?
Regards
Kai
Reply to: