LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   network interface automatics (http://www.linuxquestions.org/questions/linux-networking-3/network-interface-automatics-304242/)

mafiltenborg 03-21-2005 07:22 AM

network interface automatics
 
Got myself a laptop, an Atheros-based wlan-NIC, a dock with internal NIC and an urge to make this setup go online witout me doing too much manual work everytime i want to connect.

But how? Manually enabling the interfaces and assigning ip-adresses to them using dhclient is possible. The dock-NIC works if i power-cycle the machine, but the wireless NIC doesn't do anything but load the ath_pci.o module. I must manually assign ssid using iwconfig, execute wpa_supplicant and dhclient ath0 in that order to get wireless connection.

I haven't figured out how to make the various installed subsystems (hotplug, network daemons etc) do this work for me, let alone figured out how to prioritize connections.

How do i engage auto-management? I figure hotplug and cardmgr will autoload modules all right, but what is the mechanism driving higher-level network-setup?

My setup: Dell C600, Dell Latitude C/Dock w. 3com NIC, Proxim 8470-WD PCCard wlan-NIC and a Linksys WRT54G router. On top of this a debian Sarge, supplied by manually compiled madwifi-module for the Proxim-NIC.

I've seen people running WinXP do this; pop in a card, go online. Exchange it for a cable, go online again instantly. 'Aber so ein ding müssen wir auch haben!' i think.

But how? So far, reading howto's brought me nowhere, as they tend to *not* deal with the dynamics of networking.

Thanks in advance,
Martin

fr_laz 03-22-2005 08:53 AM

Hi,

on windows things are not so automatic as they appear :
you can set up different connexion profiles, but profile managers are just scripts that read the conf file and apply it... nothing you cannot do with a shell script.
You talk about wpa... no windows user can plug in a card and use a wifi network protected by wpa without doing a bit of configuration (or if he can, then the network admin must have forgotten a few security settings ;) )
as for the exchange of wire/wireless... I must tell that if I had to do this, I would create a small dameon that looks which interfaces have link... and enables the best one. There may be better solutions (I'm not a programming guru), like using the calls generated by your system when a NIC comes up...
But I think all this is pretty complex (and a useless way of consuming ressources) when compared to the problem you have : when you plug/unplug your cable, it's not very complicated to run a shell script that reconfigure your network !

scowles 03-22-2005 09:19 AM

In the redhat world, there is a "work in progress" RPM called NetworkManager that seems to address your post. According to the arcticle, it says it works with Debian.

Good Luck!

mafiltenborg 03-23-2005 03:35 AM

scowles: I'll look into NetworkManager. It appears to address the issue all right, although my curiosity regarding the way Linux is cut out to do this using its existing structure will remain unsatisfied.

Writing my own daemon-thing doing this job would be redoing NetworkManager functionality - which doesn't make the idea wrong or anything like that. Thanks.

A few scripts to do the job simpler/easier? Yes. Already halfway there. If NetworkManager doesn't cut it, this is what i'll do.

fr_laz: I've failed to express myself correctly. The automatics in XP of course only works on preconfigured interfaces. I've seen it work on my brother in law's laptop, where enabling the internal Wlan nic makes XP apply a preconfigured profile including securitysettings etc. Online in a snap! Disabling the wlan nic gets you offline, and plugging in a cable causes you to go online again. There are even little icons in the system tray telling you which interfaces are up/down.

Now i think i'll go tinkering for a while :study:

fr_laz 03-23-2005 08:05 AM

Re,

I didn't want to be rude in my last message ;)
Actually, I'm using such kind of tools on my windows laptop (professional so I've to use as it is), but this "access connexion tool" just keeps bugging me : it's just unstable. It will work ten times, and then without any real reason it hangs... so that I used scripts to do this with windows too.
But of course, even though I prefer doing things by hand (by script), it's just cool that things like network manager are being developped, so that Linux can become more and more user friendly for those who want it this way. I'll take a look to the project !

See you

mafiltenborg 03-23-2005 09:38 AM

I didn't take your words for being rude in any way :)

Yeah, using W2K myself here at work. I don't mind, actually it works quite nice. Especially when you consider what i do to it...

Regarding the direction Linux as a whole is taking: Well, I have no ambitions on behalf of Linux to 'Conquer the world'. I might even think it's all right the way it is. Being overly userfriendly usually means removing all the mysterious and nasty handles and knobs, newbies tend to hurt themselves on - which is exactly what i think is good about linux; all the handles and possibilities. Not that i don't get a few bruises; once in a while i stumble upon something which gets me scratching my head, completely clueless as to 'where to now'. But then i reckon this is what makes me learn stuff, right?

Which is what i think is the negative side of stuff like NetworkManager: It lets me accomplish my task, but doesn't teach me anything about how the system works under the hood.

Taking this opinion to the extreme, GUI-frontends will over time reduce the user population to drooling zombies, not knowing the first thing about anything.

I'd much rather like to know about the mechanics of how the module-cardmgr-hotplug-blablabla-system works. Then, writing scripts etc. is just work to get over with.

I've read somewhere about the ifupdown-subsystem. Scripts 'n stuff i need to get sorted, 'alias ifname drivermodule' statements in whichfiledidyousay to do and such.

Oh well. I'll get it sorted out eventually :study:

Meanwhile, all you guys/gals out there can drool over this wee setup of mine :D

Athlon64 Winchester 3000+
Asus A8N SLI
Corsair Dual DDR400 512 MB 2-2-2-5
NVidia 6600 PCIe graphics board

fueling a debian Sarge. All systems go!

mafiltenborg 04-10-2005 04:19 AM

Intermediate - but working solution found!
 
Ha!

This morning - at 2AM - i got it working. At least to a level that will make me use the machine for real work ;)

I've written a very small - and dumb - script, setting up WPA-PSK encryption for my atheros-wlan-nic.
It is to be executed before bringing up the interface ath0.

Now, investigating the ifupdown thing i stumbled upon the file /etc/network/interfaces. Doing 'man interfaces' got me wondering if it was possible to make the boot-scripts (executes 'ifup -a' to bring up interfaces present) also run my little script.

It was possible.

/etc/network/interfaces file now reads
------
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
name Ethernet kort (lan)

# my wlan...
iface ath0 inet dhcp
pre-up /root/wlan_up & #> /dev/null
name Wireless kort (wlan)
wireless_essid <name>

auto ath0
------

Now, at boot-time the wlan-nic first gets setup by my wee script, and then brought up using DHCP from my router - automatically.

The script? Well, setting up WPA-PSK turned out to be real easy. I feared this, as WPA requires yet another package to be installed and used: wpa_supplicant. Usually this means more complexity, but here it merely meant exchanging one complexity for another. You'll have to do your own bit of reading to get acquainted with wpa_supplicant, but having done that you might want to see how i've done my bit. The script file goes like this:

/root/wlan_up
------
#!/bin/sh
iwconfig ath0 essid <my-essid>
wpa_supplicant -i ath0 -D madwifi -d
------

wpa_supplicant takes a settings-file-thing which goes like this:

/etc/wpa_supplicant.conf
-----
network={
ssid="<my_ssid"
scan_ssid=1
psk="my_preshared_key"
}
-----

So, what happens is that the bootscripts execute ifup -a, which executes /root/wlan_up, which again assigns a essid to ath0 and runs wpa_supplicant - which uses the conffile to setup encryption. Finally ifup brings up ath0 and assigns a dhcp-address to it (dhclient?). All systems go!

Not perfect yet though... There's no automatics in this, as ifup appears to not know whether the wlan-nic is present before executing my script. If it isn't there (because i've physically removed the nic), the script fails, generating garbage onscreen. And it's oh-so-hardwired all of it :(

But it works.

doing iwconfig now gets me
----
# iwconfig
lo no wireless extensions.

ath0 IEEE 802.11g ESSID:"my_essid"
Mode:Managed Frequency:2.417 GHz Access Point: 00:01:02:04:08:0A
Bit Rate:54 Mb/s Tx-Power:50 dBm Sensitivity=0/3
Retry:off RTS thr:off Fragment thr:off
Encryption key:you-d-like-to-know-wouldnt-you Security mode:restricted
Power Management:off
Link Quality=33/94 Signal level=-62 dBm Noise level=-95 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

sit0 no wireless extensions.
----
and doing ifconfig gets me
----
# ifconfig
ath0 Link encap:Ethernet HWaddr 00:10:20:40:80:A0
inet addr:10.63.24.100 Bcast:10.63.24.255 Mask:255.255.255.0
inet6 addr: yuck Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3186 errors:9379 dropped:0 overruns:0 frame:9379
TX packets:1393 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:199
RX bytes:629934 (615.1 KiB) TX bytes:181365 (177.1 KiB)
Interrupt:11 Memory:e093a000-e094a000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:132 errors:0 dropped:0 overruns:0 frame:0
TX packets:132 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:8340 (8.1 KiB) TX bytes:8340 (8.1 KiB)
----

Just my 0.002 euros

//mA


All times are GMT -5. The time now is 04:26 PM.