Networking Forums

Networking Forums > Computer Networking > Linux Networking > Dynamic gateway roaming with IP aliasing, possible?

Reply
Thread Tools Display Modes

Dynamic gateway roaming with IP aliasing, possible?

 
 
JGB
Guest
Posts: n/a

 
      08-24-2003, 06:32 AM
Hi everybody.

I am having a little problem here with my laptop. I roam with it from
home to work, and I have configured eth0 (pcmcia) with IP aliasing,
for both the home LAN and the work LAN.

jgblintos:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:60:08:02:AE:1B
inet addr:172.27.101.67 Bcast:172.27.103.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6606518 errors:0 dropped:0 overruns:0 frame:0
TX packets:4339402 errors:0 dropped:0 overruns:0 carrier:613
collisions:10489 txqueuelen:100
Interrupt:11 Base address:0x100

eth0:0 Link encap:Ethernet HWaddr 00:60:08:02:AE:1B
inet addr:172.27.248.104 Bcast:172.27.255.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0x100

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:3924 Metric:1
RX packets:23 errors:0 dropped:0 overruns:0 frame:0
TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0


eth0 is for the home LAN, and eth0:0 is for the LAN at work.

The questions is the gateway. At home, the gateway is 172.27.100.1,
the ADSL router. At work, the gateway is 172.27.248.1.

In Windows XP I also have IP aliasing configured, and both gateways I have
them with the metric setting configured to "automatic", and Windows
somehow automagically finds out when to use one or the other.

In Linux, I would like not to have to configure manually the gateway each
time I arrive home or at work. So far, I've made two scripts to set the
gateway.

This one when I get home:

jgblintos:~# cat /usr/local/sbin/red-casa.sh
#!/bin/sh
# Baja el interfaz de red virtual de IP-alias en eth0:0
# y modifica el gateway por defecto para adaptarlo al de casa (Madrid).
gateway_casa=172.27.100.1
/sbin/ifconfig eth0:0 down
/sbin/route del default
/sbin/route add default gw $gateway_casa

And this one when I get at work:

jgblintos:~# cat /usr/local/sbin/red-curro.sh
#!/bin/sh
# Levanta un interfaz de red virtual mediante IP-alias en eth0:0
# y modifica el gateway por defecto para adaptarlo al del curro.
la_ip=172.27.248.104
la_mascara=255.255.252.0
el_gateway=172.27.248.1
/sbin/ifconfig eth0:0 $la_ip netmask $la_mascara
/sbin/route del default
/sbin/route add default gw $el_gateway
echo 'Actualizados el interfaz de red para IP-alias y el nuevo gateway.'


And that's it.

It is a little anoying, because I have to "su" as root to run those
scripts when I get home or at work, each time. Also, it is anoying
because using this solution, I have no reason to use IP aliasing at all -
I could just change the IP address of eth0 and the gateway with the
script, and that would be all it would take.

So, I guess that I want to know how to tell Linux to automagically use one
gateway or the other, depending on wich LAN it "senses" is at. Without any
further user intervention.

I have read the IP alias mini-howto, and I have googled the net, but found
nothing. Is it possible to do it?, how?

Thank you very much.
 
Reply With Quote
 
 
 
 
David Efflandt
Guest
Posts: n/a

 
      08-24-2003, 05:14 PM
On Sun, 24 Aug 2003 08:32:05 +0200, JGB <(E-Mail Removed)> wrote:
> Hi everybody.
>
> I am having a little problem here with my laptop. I roam with it from
> home to work, and I have configured eth0 (pcmcia) with IP aliasing,
> for both the home LAN and the work LAN.


Did it ever occur to you to set up your home LAN just like work, at least
as far as IPs and routing. Even if your nameservers are different, you
could keep a copy of resolv.work and resolv.home and when you get home,
simply: cp /etc/resolv.home /etc/resolv.conf

Or use aliases or scripts called 'homedns' and 'workdns' to do that.

--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
 
Reply With Quote
 
JGB
Guest
Posts: n/a

 
      08-24-2003, 06:07 PM
On Sun, 24 Aug 2003 17:14:19 +0000 (UTC)
(E-Mail Removed) (David Efflandt) wrote:

> On Sun, 24 Aug 2003 08:32:05 +0200, JGB <(E-Mail Removed)> wrote:
> > Hi everybody.
> >
> > I am having a little problem here with my laptop. I roam with it from
> > home to work, and I have configured eth0 (pcmcia) with IP aliasing,
> > for both the home LAN and the work LAN.

>
> Did it ever occur to you to set up your home LAN just like work, at least
> as far as IPs and routing.


Hello, David.

Yes, it did occur to me. In fact, that's why my eth0 (home LAN) has IP
172.27.101.67 - it was an IP matching the network at my work LAN, but
my company moved me from one building to another (different projects),
so now my home LAN doesn't match the work LAN any more. And yes, I guess
I could change IPs in all my home LAN, but I rather find a solution for
this to get solved now and for the future.

Thank you for your suggestion anyway.

--
JGB.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Default Gateway?? Sergio Henrique Windows Networking 10 07-15-2008 07:28 PM
IP aliasing in Linux Red Hat 2.4.20-8 Prabhu Linux Networking 2 06-28-2006 03:19 PM
lo aliasing problem krsyoung Linux Networking 1 10-01-2005 12:10 AM
ddclient to update dynamic DNS entries at a dynamic DNS service Larry Cohen Linux Networking 1 09-12-2004 01:47 AM
need howto get dynamic IP off wireless gateway/router Eric Linux Networking 3 02-21-2004 08:12 PM



1 2 3 4 5 6 7 8 9 10 11