This site is now 100% read-only, and retired.

XML logo

Networking and anachron on a Laptop
Posted by endecotp on Wed 27 Aug 2008 at 18:51
I've recently been installing Debian on a laptop - an ASUS Eee 901 - for the first time. Mostly it's been just like any other installation, but there have been a couple of challenges that I've not properly solved yet so I thought I'd see if anyone here has any suggestions.

Firstly, I need to deal with networking. Compared to every other box I have there are two differences: it has two network interfaces (wired and wireless) and they can be connected and disconnected at any time. So I have marked neither interface as "auto" but both as "allow-hotplug" in /etc/network/interfaces. But this isn't quite sufficient, as the wired interface is always present : it's just the cable that comes and goes. After a lot of searching I found ifplugd, which waits for cable attach/detach events and does the necessary work in response; the Debian package integrates nicely with /etc/network/interfaces so that it works out-of-the-box.

Now I just need to work out how to manage having two network interfaces. I think it's right to say that the two interfaces should have different IP addresses, but that I can associate both IP addresses with the same hostname. Is that right? Ideally, I want to be able to ssh to the machine using its hostname without having to worry about which interface is up at the moment. Will the client automatically try each possible IP address in turn until it finds one that works? I doubt it! Any ideas anyone?

The other thing that I need to set up is anachron, so that the jobs that run daily (such as an over-the-net backup) only run when the network is up. I think I need to somehow couple the if-up hooks into anacron somehow. Has anyone ever done anything like that?

Thanks for any suggestions.

 

Comments on this Entry

Re: Networking and anachron on a Laptop
Posted by Anonymous (201.20.xx.xx) on Wed 27 Aug 2008 at 23:12
Hello,

Try network-manager* packages. They will catch up network related events and make network "just work" for you, I am using it with my EEE 900.

I personally never used anacron, but afaik, remove cron, install anacron, and voila.

BTW, join the Debian EEE mailing list / IRC / Wiki: http://wiki.debian.org/DebianEeePC .

Bye.

[ Parent ]

Re: Networking and anachron on a Laptop
Posted by endecotp (86.7.xx.xx) on Wed 27 Aug 2008 at 23:54
[ View Weblogs ]
network-manager is gnome thing, right? I'm more of a command line sort of person. BTW, ratpoison is great on the Eee. Does "just work" mean that you can ssh in to the machine without having to worry about which network is connected? And if both are connected, which does it prefer?

anacron will try to run jobs if the machine is on, even if the network is not connected. A bit more magic is needed.

Yes, I've joined that list.

[ Parent ]

Re: Networking and anachron on a Laptop
Posted by diveli (150.101.xx.xx) on Thu 28 Aug 2008 at 00:35
[ View Weblogs ]
If you've got two network interfaces and either could be up at either time, then what you probably want to do is tell your DNS server that 'your-eeepc-hostname' (for example) has two A records, that are the two different IPs, and go for a 'round robin' sort of approach when trying to ping or ssh to 'your-eeepc-hostname'

No idea if it'll work though :)

Can't help you on the anacron stuff unfortunately :/

[ Parent ]

Re: Networking and anachron on a Laptop
Posted by mcortese (213.70.xx.xx) on Thu 28 Aug 2008 at 13:39
[ View Weblogs ]

I think that the issue with the association between hostname and IP is more at the DNS than at the machine itself. What kind of DNS do you rely upon for your local network?

Another thing: who decides the IP address of the wired and wireless cards? Do you have a DHCP server? If you have a wifi router, have you tried configure it to serve the same IP to both your wired and wireless MAC addresses?

Regarding anachron, I used to have a similar problem with fetchmail,which I wanted to be running only when I was online. I had resorted to a rather rough solution with a temporary file acting as a flag: the if-up/down script would create/delete it, while the anachron script would test its presence before starting.

[ Parent ]

Re: Networking and anachron on a Laptop
Posted by endecotp (86.7.xx.xx) on Thu 28 Aug 2008 at 15:01
[ View Weblogs ]
> I think that the issue with the association between hostname and
> IP is more at the DNS than at the machine itself.

Yes, absolutely.

> What kind of DNS do you rely upon for your local network?
> Another thing: who decides the IP address of the wired and
> wireless cards? Do you have a DHCP server?

Yes, I'm using DHCP, but the DHCP server is configured to allocate fixed IP addresses based on the MAC addresses. So it's almost like using static IPs.

> If you have a wifi router, have you tried configure it to
> serve the same IP to both your wired and wireless MAC addresses?

That doesn't sound like a good idea to me; my understanding was that you should never have duplicate IP addresses. Is there anyone who really understands this stuff who can comment?

[ Parent ]

Re: Networking and anachron on a Laptop
Posted by AJxn (90.227.xx.xx) on Wed 17 Sep 2008 at 03:21
[ View Weblogs ]
I would go for network-manager for this. And there are front end for KDE too.

If not, there is no problem with many IP on a machine. How do you think routers work, do you :)
You already have more than one address. loopback (127.0.0.1), your broadcast address and your ordinary address.

You can use any one to talk to your machine. DNS can have many A-records for same name. Clients, as ssh, is supposed to use them in a round robin fashion.

You can have cron and anacron installed at the same time. If you start your net conenctions with ifup, you can always run scripts when network is up, like sending mail, dynamic setting DNS A record to your machine etc.

[ Parent ]

Re: Networking and anachron on a Laptop
Posted by endecotp (86.7.xx.xx) on Thu 28 Aug 2008 at 15:10
[ View Weblogs ]
> Regarding anachron [...]

I've noticed in the anacron man page that it can take an optional command-line parameter that is matched against the names of the jobs (and defaults to '*'). So presumably I could name my anacron jobs as e.g. either net-xxxx or nonet-xxxx, and then run anacron 'net-*' from ifup and anacron 'nonet-*' for the regular daily thing. Has anyone ever done anything like that?

> temporary file acting as a flag: the if-up/down script would
> create/delete it, while the anachron script would test its
> presence before starting.

The trouble with that is that, AFAICT, the script has no way to report to anacron that it didn't really run and that it should be retried sooner than the normal 24 hours.

[ Parent ]

Re: Networking and anachron on a Laptop
Posted by endecotp (86.7.xx.xx) on Fri 29 Aug 2008 at 13:29
[ View Weblogs ]
Delving more into how Debian runs anacron, I see that /etc/init.d/anacron tries to detect whether the machine (i.e. the laptop) is on AC power, and doesn't start anacron if it isn't. Presumably the idea here is to avoid doing intensive jobs that might run down the battery. But there may well be jobs that I'd like to run irrespective of the power source [for example, critical backups]. So here again we could use anacron's facility to match job names to specify which ones are critical and which aren't.

[ Parent ]

Re: Networking and anachron on a Laptop
Posted by endecotp (86.7.xx.xx) on Sun 14 Sep 2008 at 00:13
[ View Weblogs ]
Well I'm going to try to implement the anacron thing. Here's approximately what I'm trying. It's not finished yet. Comments welcome.

1. I want to run anacron when the network comes up, so I put a script in /etc/network/interfaces/if-up.d/anacron that invokes anacron.

2. I remove the existing hard-coded test for ac power in init.d/anacron.

3. I want to run anacron when mains power comes on. I haven't worked out how to do that yet; I think I need an "acpi action", or something. Anyone know?

I'm a bit concerned that the network, or the mains power, could come on and go off before the anacron jobs have finished and that in this case they will have been marked as done. It would surely be better to mark them as done once they're finished, wouldn't it? The culprit is /etc/cron.daily/0anacron: what's it for?

So anacron will now get invoked in 4 conditions:
- At boot.
- At 0730 each day.
- When the network comes up.
- When the mains power comes on.

4. Now I change /etc/anacrontab so that it calls a script, rather than invoking
run-parts directly, and the script does something like this psuedo-code:

suffix=""
if the network is up
then
suffix+=".net-up"
else
suffix+=".net-down"
fi
if mains power is on
then
suffix+=".mains"
else
suffix+=".battery"
fi
nice run-parts --report /etc/cron.$interval$suffix

I may need more fine-grain control over the network condition, as some scripts might not want to be run over a pay-per-megabyte connection...

4. Now I symlink all of the scripts in /etc/cron.{daily|weekly|monthly} into directories with names that indicate the conditions in which they should be run.

et voila.

I'll let you know how I get on...

[ Parent ]