# [Wireless LAN at startup] Custom command at startup

## MaartenZz

Hello,

Is there a way to run a specific command at startup that is not in /etc/init.d?

I have this command:

(/usr/local/sbin/wlan-up)

 *Quote:*   

> iwconfig wlan0 essid "Wireless" mode Ad-Hoc
> 
> ifconfig wlan0 192.168.2.1 broadcast 192.168.2.255 netmask 255.255.255.0
> 
> 

 

I want to run /usr/local/sbin/wlan-up automaticly at boot. This command has to be started before Shorewall starts up. (Else Shorewall will error, and the firewall will be down.)

Thank you for reading, and maybe with helping me out  :Wink: 

Maarten.

----------

## UberLord

baselayout-1.11.10-r2 has the features you need to configure an interface with the wireless options you need

----------

## MaartenZz

So this will replace my handmade script?  :Cool: 

----------

## Xamindar

Yes, your wireless interface can be brought up with configurations in the /etc/conf.d/net file.

If you want to run a custom command on startup just add it to /etc/conf.d/local.start

oh, but i think local.start stuff is run last on bootup.

----------

## raluke

 *UberLord wrote:*   

> baselayout-1.11.10-r2 has the features you need to configure an interface with the wireless options you need

 

But 1.11 is in testing.  Is there no other way?  I've been burned before by installing masked packages.  Admittedly, I'm no expert...

Thanx,

-Robert

----------

## UberLord

 *raluke wrote:*   

>  *UberLord wrote:*   baselayout-1.11.10-r2 has the features you need to configure an interface with the wireless options you need 
> 
> But 1.11 is in testing.  Is there no other way?  I've been burned before by installing masked packages.  Admittedly, I'm no expert...
> 
> 

 

It's been in testing for some time now, and it fixes way more bugs than it creates.

http://gentoo-wiki.com/HOWTO_Wireless_Configuration_and_Startup

Instructions on what else you need  :Smile: 

----------

## ronmon

UberLord knows what he's talking about. I recently set up a new router box using the new baselayout. Now you can do the whole shebang in one file. Here's the conf.d/net from that box.

```

modules=( "iproute2" )

config_eth0=( "dhcp" )

dhcpcd_eth0="-N -t 30"

config_eth2=( "192.168.3.1/24 brd 192.168.3.255" )

fallback_eth0=( "192.168.0.2 netmask 255.255.255.0" )

fallback_route_eth0=( "default via 192.168.0.1" )

bridge_br0="eth1 wlan0"

config_eth1=( "null" )

config_wlan0=( "null" )

config_br0=( "192.168.2.1/24 brd 192.168.2.255" )

depend_br0() {

    need net.eth1 net.wlan0

}

modules_wlan0=( "iwconfig" )

essid_wlan0="clubhouse"

mode_wlan0="Master"

channel_wlan0="2"

iwpriv_wlan0="maccmd 1"

iwpriv_wlan0="addmac 00:00:00:00:00:00"

iwpriv_wlan0="addmac FF:FF:FF:FF:FF:FF"

```

Everything from bridging to wireless. It's pretty spiffy.

----------

## MaartenZz

The baselayout update worked great for me! It took some etc-configgin' but it was wearth it  :Wink:  Long live /etc/conf.d/wireless! Thank you all for helping me out.

----------

## mOjO_420

hey.. my question kind of relates to this subject so I'll ask it here.

I don't think this is a baselayout problem per se but...

when i plug both my wireless NIC (ath0) and my wired nic (eth0) in they both dhcp and both set a default gw with the same metric.  Since it is actually the same LAN, I end up with two default gw's for different interfaces with the same metric.... this confuses the heck out of things because then all traffic beyond the LAN ceases.  of course i have no real *need* to be on the same network twice (its a laptop, i'm not bridging) but I checked in windows (dual-boot) and windows is smart enough to always automatically give the wireless interface a higher metric... i want my gentoo install to be as smart as windows of course so i'm here asking this question.  

now as some of you may know setting the metric via ifconfig is broke due to some bug or soemthing in ifconfig (at least thats what i read on the net and sure enough it doesnt work for me either).  setting the metric via the route command however works very well and immediately fixes the problem.

i'd like to see this put in as an option in baselayout... soemthing like:

metric_ath0=20

i cant really code very well.. so i'm stuck begging for this.  :Wink: 

and the other part of the problem is that i think its dhcpcd which is setting the default gw right?  not really baslayout's job... but i didnt see an option to pass to dhcpcd which would always set the metric of a given interface to XX for all routes created.

well.. thats where my thought process is stuck... wanted to run it by you guys for a reccomendation on how to approach this...

----------

## UberLord

 *mOjO_420 wrote:*   

> 
> 
> i'd like to see this put in as an option in baselayout... soemthing like:
> 
> metric_ath0=20
> ...

 

Hopefully we'll do this in baselayout-1.12.x  :Smile: 

----------

## mOjO_420

cool... i've seen a couple of people post with similar issues in different areas of the forums.

on a side note, I think theres ton's of new wireless support being included into new KDE 3.4.0... anyone tried it yet?

would be nice to have a windows-like gui for displaying detected networks and just click and type password etc to connect to wireless networks... but to be usable to me it would have to get along nicely with the gentoo baselayout, wpa_supplicant, and ifplugd.

----------

## UberLord

 *mOjO_420 wrote:*   

> would be nice to have a windows-like gui for displaying detected networks and just click and type password etc to connect to wireless networks... but to be usable to me it would have to get along nicely with the gentoo baselayout, wpa_supplicant, and ifplugd.

 

Nice yes, but not essential

From time 2 time, I play with NetworkManager from RedHat but I cannot get it to work :/

The upside is, for simple net connection it's great. Ease of use + good GUI.

Downside is there's nothing for vlan, bridging, bonding + others which Gentoo baselayout 1.11.10 supports

Also, there's no easy way to configure that with a GUI compared to our configuration in /etc/conf.d/net

(note - that is the ease of configuring it, not understanding it)

Hopefully when baselayout-1.11.x goes stable, some bright spark can write a GUI config thats easy for users yet gives the power of network configuration that baselayout can provide....

Until then, it's pretty much Read Teh Docs and do it on the CLI

----------

## mkrisch

i have a slightly similar scenario to mOjO_420.  i also have both the wired and wireless interfaces set up, but they actually connect to differet interfaces.

in the simplest scenario, i'd just like to keep it that the wireless network doesn't come up unless the wired network is down.  but despite having net.eth0 set to start in the default group, and net.eth1 not set, the wireless interface always starts up when i boot, and i need to manually shut it down (and sometimes restart eth0) in order to get the network running.

as an aside, it'd also be nice if there was a gnome applet that i could use to quickly /etc/init.d/net.eth? start/stop for different interfaces.  anyone know of something like that?

--mk

----------

## UberLord

Use ifplugd to manage your wired network devices.

ifplugd may also be able to manage your wireless too - but YMMV on that.

----------

## mOjO_420

 *mkrisch wrote:*   

> i have a slightly similar scenario to mOjO_420.  i also have both the wired and wireless interfaces set up, but they actually connect to differet interfaces.
> 
> in the simplest scenario, i'd just like to keep it that the wireless network doesn't come up unless the wired network is down.  but despite having net.eth0 set to start in the default group, and net.eth1 not set, the wireless interface always starts up when i boot, and i need to manually shut it down (and sometimes restart eth0) in order to get the network running.
> 
> as an aside, it'd also be nice if there was a gnome applet that i could use to quickly /etc/init.d/net.eth? start/stop for different interfaces.  anyone know of something like that?
> ...

 

yes.. ifplugd works great... just "emerge ifplugd" and edit /etc/conf.d/ifplugd once.

like Uberlord said it may not work that well for the wireless card, depends on your card, but i actually find that on my system (udev, hald, hotplug) that inserting the wireless card magically starts the wifi anyway without me running ifplugd even, and it sounds like yours is doing the same. you dont have to stop the wireless interface if you give it a lower metric... (hence the discussion). normally you would give the whole interface a lower metric with ifconfig but this is broken in ifconfig for reasons i dont remember... you can either switch to iproute2 or just use the regular "route" command.

when they are both plugged in, instead of shutting down try something like:

# route metric 5 eth1 

(or whatever your wireless nic is instead of eth1)

not sure if that will work without the full "default gw x.x.x.x netmask y.y.y.y" stuff... and im too lazy to get my laptop and try right this minute.

----------

## BDickson

UberLord wrote: 

    "baselayout-1.11.10-r2 has the features you need to configure an interface with the wireless options you need "

Does it include the ebuild for 0.3.8?

BD

----------

## UberLord

 *BDickson wrote:*   

> UberLord wrote: 
> 
>     "baselayout-1.11.10-r2 has the features you need to configure an interface with the wireless options you need "
> 
> Does it include the ebuild for 0.3.8?
> ...

 

What is 0.3.8? If you're referring to wpa_supplicant, it's an a seperate ebuild called ..... wpa_supplicant  :Wink: 

----------

## BDickson

UberLord:

Yes, I meant WPA_Supplicant, but I have no internet access except wifi, which isn't working.

When I try the 1.10.11 baselayout, I get no ebuild available. When I try just wpa_supplicant, i get no ebuild available.

I put 

     "Sys-apps/Baselayout ~86" in "/etc/portage/package.keyword", and still get no ebuilds available.

I've read all your recent posts, but no thing works.

BD

----------

## UberLord

 *BDickson wrote:*   

> 
> 
>      "Sys-apps/Baselayout ~86" in "/etc/portage/package.keyword", and still get no ebuilds available.
> 
> 

 

 :Shocked: 

It's case sensitive - all lower case! Also, it's x86, not 86

sys-apps/baselayout ~x86

Lastly, it's package.keywords, not package.keyword

I kinda get the impression that you're going to be posting a lot about wireless configuration ....  :Wink: 

----------

## BDickson

The caps were from me typing on this screen while looking at the other PC. They are all lower case in the file, which I also mis-typed. There were 5 file names in package.keywords when I first opened it, and sys-apps/baselayout ~x86 is one of them.

As to lots of posts, i can't seem to emerge baselayout-1.11.10-r2, which I've seen you recommend, and I'm  2 weeks past the only time I was able to ping my router using ifconfig and iwconfig. DHCP doesn't work at all, and I am really hopeful that wpa_supplicant will simplify things, because I don't even know what I did wrong 2 weeks ago.

My 80211g works fine in Win98SE, but my DWL-G520 doesn't seem responsive in Gentoo. The only way it will accept an IP address is from ifconfig within /etc/conf.d/net, not from a prompt, but that's as far as I get. I can ping ath0, localhost, hostname but etc/resolv.conf  and /etc/hosts must be messed up somewhere, but they look OK from posts I've viewed.

I've followed up on lots of suggestions, but I can't get 1.11.10 to emerge to try wpa_supplicant.

AND, I just booted up the box and my password doesn't work anymore!

Start over?

BD

----------

## UberLord

 *BDickson wrote:*   

> As to lots of posts, i can't seem to emerge baselayout-1.11.10-r2, which I've seen you recommend

 

baselayout-1.11.10-r2 isn't in portage anymore - earliest 1.11.x is 1.11.10-r3

baselayout-1.11.10-r6 is what I recommend. Well, the latest 1.11.x release really  :Wink: 

----------

## BDickson

Thanks for the update.

Can you tell me how I can get 1.11.10-r6 onto this W2000 box so I can CD-R it to Gentoo?

My /etc/conf.d/net file was overwritten, so I'm ready to go from scratch.

BD

----------

## UberLord

You need to somehow get the file rc-scripts-1.6.10.tar.bz2 from a Gentoo mirror into the /usr/portage/distfiles directory

BTW, If you have a Windows partition you can configure Gentoo to read from FAT/FAT32/NTFS - so you don't need to CD-R it  :Smile: 

----------

## BDickson

UberLord Posted: 2005 12:43 am Fri Apr 08,    Post subject:  

You need to somehow get the file rc-scripts-1.6.10.tar.bz2 from a Gentoo mirror into the /usr/portage/distfiles directory 

     That was easy: It fit on a floppy. HOWEVER, if say "emerge baselayout", it starts on 1.10.4 (again).

     When I try "emerge /etc/portage/distfiles/baselayout-1.11.10-r6" I get "there are no ebuilds available.

UberLord Posted: 2005 12:43 am Fri Apr 08,    Post subject:  

BTW, If you have a Windows partition you can configure Gentoo to read from FAT/FAT32/NTFS - so you don't need to CD-R it  

     I have Fat32 support in the kernel, but I'd have to reboot, download, reboot, etc, as networking isn't set up yet,  nor is Samba

AHA! Just read the HOWTO Wireless Configuration and Startup:

Installation

>=sys-apps/baselayout-1.11.0 now has wireless support. We also need to install wireless-tools. 

This version of baselayout relies on a few other packages being unmasked too - namely sysvinit, bash and sys-libs/readline. 

Code:  

mkdir -p /etc/portage

echo "sys-apps/baselayout ~x86" >> /etc/portage/package.keywords -Done

echo "sys-apps/sysvinit ~x86" >> /etc/portage/package.keywords -Done

echo "app-shells/bash ~x86" >> /etc/portage/package.keywords -Done

echo "sys-libs/readline ~x86" >> /etc/portage/package.keywords -Done

emerge -uav sys-apps/baselayout net-wireless/wireless-tools sys-libs/readline bash - Lists 17 files I need, ~117MB.

Guess I'll get started, eh? OK, that took a while. I now have 15 (some are _patch) of the files required, and versions of the 5 I couldn't find are in  /usr/portage/sys-apps, etc.

All files are now in /usr/portage/disfiles, or sys-apps, etc. When I try "emerge --usepkg -uav sys-apps/baselayout net-wireless/wireless-tools sys-libs/readline bash", it wants another file, "patch.4.2.52.2". This appears to be a script,  and I think it's associated with "db-4.2.52.tar.gz". I saved the file as .txt, then renoved the .txt before putting it in /distfiles. HOWEVER, the emerge doesn't recognize it, even with PKGDIR=/usr/portage/distfiles/"

'Normally', I just keep going, file by file, until the emerge completes, but now I'm stuck.

Thanks so far,

 :Question:  :Question:  :Question:  :Question:  BD

----------

## eagle_cz

 *ronmon wrote:*   

> UberLord knows what he's talking about. I recently set up a new router box using the new baselayout. Now you can do the whole shebang in one file. Here's the conf.d/net from that box.
> 
> ```
> 
> modules=( "iproute2" )
> ...

 

Did you make sure, that you access list is working ?

I made similar setup and HostAP didnt get locked

from /etc/conf.d/wireless

essid_wlan0="lalalala"

mode_wlan0="master"

channel_wlan0="13"

iwconfig_wlan0="retry 30 enc 2580-afeb"

iwpriv_wlan0="reset 1"

iwpriv_wlan0="reset 2"

iwpriv_wlan0="maccmd 3"

iwpriv_wlan0="maccmd 4"

iwpriv_wlan0="maccmd 1"

iwpriv_wlan0="addmac 00:60:B3:6B:6F:25" # Bird

iwpriv_wlan0="addmac 00:60:B3:6D:79:99" # aaa

#iwpriv_wlan0="addmac 00:60:B3:6E:10:E4" # bbb

maccmd are simply ignored.

Even if i put all iwpriv command on the one line, it work from bash, but doesnt work via script.

----------

