LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to configure Wireless KEY automatically? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-configure-wireless-key-automatically-257175/)

enemorales 11-20-2004 06:32 AM

How to configure Wireless KEY automatically?
 
Hello,

I've an access point using WEP and every time I run linux I have to login as root and use iwconfig for provifind the HeXKey. How could I do it automatically in every startup?

Maybe it matters: I'm ussing Knoppix 3.4...

Thank you very much in advance...

PS: It looks like I'll never stop asking things. Just hope answers won't stop either. :-)

Hangdog42 11-20-2004 08:55 AM

In slackware you would just add the command to your /etc/rc.d/rc.local file. I know Knoppix has something similar. Try looking in your /etc/init.d directory. That should contain files that are executed at boot time with root privileges.

e11 11-20-2004 09:34 AM

Hi, you mean your WEP key isn't fix?


Regards,

Edwin

enemorales 11-21-2004 01:31 PM

Hi
 
No, no... the key is fixed, but I do not know where I have to provide it in order to configure it properly.

On the other hand, I've noticed that sometimes Knoppix does not detect my card. My only solution in that case is to reboot the system. Is there is a way to add it after the boot process?

Thak you...

Hangdog42 11-21-2004 02:55 PM

I suppose you could just write a script that loads any modules then configures the card. You could then su to root and run it when you need your card.

enemorales 11-22-2004 05:35 AM

HI...

Well, that's what I did, but I wonder if now I can make the script run in every startup, without need using "su"...

:-(

Hangdog42 11-22-2004 08:03 AM

Quote:

Originally posted by enemorales
HI...

Well, that's what I did, but I wonder if now I can make the script run in every startup, without need using "su"...

:-(

OK, well that gets back to my original answer.....Knoppix has a directory called /etc/init.d which contains files that are run at start-up. If you add your script to that directory, change its ownership to root, make it executable, and then call it from one of the start-up scripts, it should work. There should be a file similar to Slackware's rc.local that is called at the end of the boot sequence. Calling your script from there is as close as you can get to having it run "after the boot process". The other thing to investigate is which step causes the script to fail. For example, sometimes loading a module can take a second or two. Adding a sleep X command to the script (and replacing X with the number of seconds you want it to wait) can solve the problem sometimes.

enemorales 11-24-2004 03:30 AM

Thank you. I wrote a script and put it in /etc/init.d. Then I use "Sys-V-Init Editor" and ask it to load my protocol in several run-levels. I have modified the script so it configures the network at home (when it detects my acces point address, it provides the WEP key) or for the office, where there is no WEP encryption. I'm posting it here, because it could be useful for another person:

Code:

#!/usr/bin/perl

# myaccesspoint.pl
# Looks for my home access point and provides my WEP key if it is found.
# Otherwise, it disables WEP key

# Some "configurations"
# My card device
$card = "eth0";
# access point address
$AP = "xx:xx:xx:xx:xx";
# WEP KEY
$WEP = "yyyyyyyyyyyyyy";

# Checks for the access point
open( CHECK,"iwlist $card scan | grep $AP |" );

if(<CHECK>) {
  # Provides WEP key if my access point is found
  print STDERR "Configuring network with WEP key\n";
  system "iwconfig $card key $WEP";
} else {
  # Configures wireless network without key if my access point is not found
  print STDERR "Configuring network without WEP\n";
  system "iwconfig $card key off";
}

# Asks for IP (I have DHCP in both places).
print STDERR "Pumping for an IP\n";
system "pump -i $card";

Probably is not the best way to do it, but for me at least i works...


All times are GMT -5. The time now is 06:42 PM.