Page 1 of 30

Improved Network Wizard (and rc.network)

Posted: Fri 18 Jul 2008, 18:36
by Dougal
I've overhauled the way the network-wizard saves configurations, in
conjunction with re-writing rc.network, to make it more flexible and
be able to support both different HW (when running off USB drive) and
different locations (for laptops).

The only thing left is to test it...

(Note that you might want to use a special pup_save for it, or at least
backup the files that are overwritten: /etc/rc.d/rc.network,
/usr/sbin/net-setup.sh, /usr/sbin/wag-profiles.sh and
/usr/sbin/ndiswrappergui.sh )


Here's how it now works (you don't need to know this to use the wizard...):

Interface configuration
Interfaces have configuration files named after the HW address of the
network adapter, as seen in the output of ifconfig (eg. 00:10:60:BD:4A:D7).

This way we are not dependent on the interface name, which would most
likely be the same (eth0, wlan0) on different machines. (if the HWaddres
isn't unique enough, I can easily add the module name or something...)

- When every interface is configured, a config file is created:
/etc/network/interfaces/$HWADDRESS.conf
This file might be empty, or include some info, such as the details of
a static ip address (in case it was configured that way).

- In case of a wireless interface, another config file will be created:
/etc/wireless/interfaces/$HWADDRESS.conf
This file might include information like whether to use wlanctl-ng
instead of iwconfig/wpa_supplicant (in case of devices using the prism2
drivers), or which wpa_supplicant driver to use.

Both of these files are used as markers, to let us know that the interface
has actually been "configured" by the user -- so we don't try and use an
interface that the user doesn't want us to.


Network configuration
Unlike previously, the different "profiles" you save when configuring
wireless networks are not saved in the same file.
Now a directory (/etc/wireless/profiles) is used, with each profile having
its own config file, named after the MAC address and the type of encryption
used. For example:
/etc/wireless/profiles/00:1B:9E:6F:61:F6.WPA.conf

In case of WPA/WPA2, an appropriate wpa_supplicant.conf file is created
in /etc/wireless/wpa_profiles. Example:
/etc/wireless/wpa_profiles/00:1B:9E:6F:61:F6.WPA.conf

This way, at bootup, a wireless scan is performed and each detected network
is checked, to see if there is a profile matching it (and its encryption
mode!)

Note: this should mean that you can have profiles for your home router
in different modes, without them interfering with each other.

Now, if none of the detected networks matches an existing profile (or if
some do, but fail to connect), then an attempt will be made to connect
to each of the detected open networks, so theoretically you should be able
to just go somewhere and boot and it will connect you to something...


I have also added the option of giving priority to certain networks (i.e.
your home network) over the rest, but that isn't incorporated into the
guy yet...
What you need to do is add to the wireless config file (the one for the
interface, in /etc/wireless/interfaces!) a line such as:

Code: Select all

PRIORITY_LIST='00:1B:9E:6F:61:F6 00:0E:2E:7B:E5:D8'
Connecting to the addresses in the list will be attempted before all
others (assuming they were detected by the scan, of course...).


That's about it, at the moment.

There are some things I'm still not completely sure about, including some
other modifications I made to the wizard, which people might help me with:
- Tempestuous mentioned once that running "iwlist $INTERFACE ap" will
return a list of access-points with their signal quality (and listed by
decreasing signal strength).
Is the order the networks are listed "normally" (iwlist $INTERFACE scan)
the same (i.e. listed by decreasing signal strength)?

- I took some code from Wicd, which is used to "clean up" every time before
an interface is configured: dhcpcd killed, wpa_supplicant killed, routing
table flushed etc.
This kills all instances of dhcpcd every time. Is this safe to
do? Could a user run more than one instance of dhcpcd at once, connecting
via more than one interface?

- Do people ever use static ip addresses with wireless??

UPDATE July 21st: fix some bugs and updated the attachment.
UPDATE July 22nd: updated the attachment.
UPDATE july 23rd: a few fixes (see post on page 3)
UPDATE july 25th: modify wireless profiles dialog and add "connect" argument (see post on page 3)
UPDATE july 28th: a bunch of fixes and added a loop for bootup sleep (see page 4)

Re: Improved Network Wizard (and rc.network)

Posted: Fri 18 Jul 2008, 19:05
by Arvi Pingus
Dougal wrote:I've overhauled the way the network-wizard saves configurations, in
conjunction with re-writing rc.network, to make it more flexible and
be able to support both different HW (when running off USB drive) and
different locations (for laptops).

The only thing left is to test it...
How can one participate in testing?
(I am not a fan of tar.gz binary stuff. Like to install with the help of a packetmanager.)
Dougal wrote:Do people ever use static ip addresses with wireless??
Me, myself and I, including all members of my family on our home LAN.

Posted: Fri 18 Jul 2008, 22:04
by kirk
Sounds great.

Works fine with my wide-open network. I'll try it next week on a wpa network.

Posted: Sat 19 Jul 2008, 12:45
by tempestuous
Dougal, while you're overhauling the Network Wizard, what about this small enhancement -
http://www.murga-linux.com/puppy/viewto ... 545#208545
I think that the "Supplic" "Driver" "Hidden" labels are too technical. They refer to the underlying tecnology of wpa_supplicant, and are not useful to the user.

I believe those 3 options should instead be labelled:
"SSID broadcast" "Driver" "SSID Hidden"

... or since "Hidden" is the default setting, a more logical order would be:
"SSID Hidden" "SSID broadcast" "Driver"

Re: Improved Network Wizard (and rc.network)

Posted: Sun 20 Jul 2008, 08:55
by Dougal
Arvi Pingus wrote:How can one participate in testing?
(I am not a fan of tar.gz binary stuff. Like to install with the help of a packetmanager.)
I didn't make into a dotpet intentionally, so people won't just download it and click to install, then, if they can't connect anymore, complain to me... since it doesn't back up the old files.
You can always just turn the tarball into a .pet by running in a terminal
"tgz2pet" on it.
Dougal wrote:Do people ever use static ip addresses with wireless??
Me, myself and I, including all members of my family on our home LAN.
Ok. It isn't supported at the moment, but shouldn't be hard to add.

The main problem I have with static ip is that it ties up the interface (well, at least with ethernet, I guess with wireless I can save it as part of the wireless network config).
What I mean is that if you configure your laptop ethernet to one network, then, trying to connect with it somewhere else, it will just try that static ip address, not trying dhcp.
Is there a way to find out if to use the static ip address? (like the address of the service provider?)
Could I test, via ping or something, if the static connection worked and if not -- try auto dhcp?

Posted: Sun 20 Jul 2008, 09:04
by Dougal
tempestuous wrote:Dougal, while you're overhauling the Network Wizard, what about this small enhancement -
http://www.murga-linux.com/puppy/viewto ... 545#208545
I think that the "Supplic" "Driver" "Hidden" labels are too technical. They refer to the underlying tecnology of wpa_supplicant, and are not useful to the user.

I believe those 3 options should instead be labelled:
"SSID broadcast" "Driver" "SSID Hidden"

... or since "Hidden" is the default setting, a more logical order would be:
"SSID Hidden" "SSID broadcast" "Driver"
Sure.
I would have liked to do a proper overhaul of the wizard UI, using tooltips to cut down on the text and simplify things, but it seems like gtkdialog only supports tooltips when using glade, which I've never done (I'm also not sure it will be worth the effort -- at least not if we need to generate the glade files on-the-go, rather than just having a static one.
(I actually took the .glade file from wicd and run gtkdialog with it and it brought up a gui! the only question if we can use variables to fill in the parts that need filling in).

Posted: Sun 20 Jul 2008, 09:30
by paulh177
I was having problems with network setup persisting between reboots on my laptop, running Puppy4.1alpha4 (Lin'n'Win on WinXP SP3 VFAT).

Installed your update and that seems to have resolved.

paul

Working with Static IP configuration dynamically

Posted: Sun 20 Jul 2008, 17:21
by hanishkvc
Hi Dougal,

I noticed above that you have asked if there is a way to identify a static IP configuration uniquely with respect to its network so that when booting you can decide whether to apply that particular static ip configuration or force going for DHCP.

The solution
------------------
What I feel is if one captures/stores the MAC ID associated with the GATEWAY IP address of a static configuration. Then when booting or starting networking on a machine with Static IP configuration, it can be varified as to whether the system is still running on the SAME network or not by using ARP and based on that one can decide whether to apply that particular Static configuration on that run or switch to DHCP for that run.

Hope that helps.

Keep ;-)
HanishKVC

Posted: Sun 20 Jul 2008, 17:51
by prit1
@Dougal:

I downloaded and installed the files provided. Tried running net-setup.sh and get the following error when saving the profile:

/usr/sbin/wag-profiles.sh: line 706: /etc/wireless/profiles/00: No such file or directory

Posted: Sun 20 Jul 2008, 18:32
by Keef
I'm using this with Fat Free 3.01 (frugal install) on a Dell 610 laptop with a NetgearWG111T.
I've found that it won't save a profile - if I try to save, the program closes.
The program seems to detect the wlan0 on alternate boots - but when it does detect it, it will connect to a network far quicker than previously. It has done it first time once I've entered the parameters. This could take several attempts before, so there is a definite improvement.

Re: Working with Static IP configuration dynamically

Posted: Mon 21 Jul 2008, 08:24
by Dougal
hanishkvc wrote:What I feel is if one captures/stores the MAC ID associated with the GATEWAY IP address of a static configuration. Then when booting or starting networking on a machine with Static IP configuration, it can be varified as to whether the system is still running on the SAME network or not by using ARP and based on that one can decide whether to apply that particular Static configuration on that run or switch to DHCP for that run.
Haa, but how do I do that... I really don't know much about networking.
A little code snippet is all I need.

Posted: Mon 21 Jul 2008, 08:26
by Dougal
prit1 wrote:I downloaded and installed the files provided. Tried running net-setup.sh and get the following error when saving the profile:

/usr/sbin/wag-profiles.sh: line 706: /etc/wireless/profiles/00: No such file or directory
Ok, I'll look into it.

Posted: Mon 21 Jul 2008, 08:28
by Dougal
Keef wrote:I'm using this with Fat Free 3.01 (frugal install) on a Dell 610 laptop with a NetgearWG111T.
I've found that it won't save a profile - if I try to save, the program closes.
Could you try tunning it from a terminal and see what kind of error message it give when closing? Just run "net-setup.sh -d".

Posted: Mon 21 Jul 2008, 15:27
by nic2109
- Do people ever use static ip addresses with wireless??
Yes, I do.

This is because my household has 4 wireless laptops, one or two of which which run The Devil's Own Operating System. If 'Doze hibernates it (obviously) discards the lease on its I/P address but when it is woken up later it will try to re-lease the same address. If in the meantime one of the other devices has been auto-allocated the same address (because it was available) then there's a conflict straight away.

I can solve this in my Router by allocating a fixed I/P address to the MAC Address of each device and then use "Automatic" DHCP to get an address.

I imagine this scenario is not unique so I can see the need to retain the static address option for simialr situations but where changing router settings isn't possible.
Could a user run more than one instance of dhcpcd at once, connecting via more than one interface?
Yes, I do.

But I'd rather not! If you ever connect both wirelessly and wired, then you'll get both interfaces activated at bootup from then on. It's always struck me as a minor flaw that it does the second connection even if the first was successful.

It doesn't seem to "matter" until you want to switch mode; say you started wired but wish to move to working wirelessly. I haven't found how to cancel/disable/de-activate the first one you used and switch to the other without re-booting.

It's a small thing, but would add to the general friendliness of the experience.

Posted: Mon 21 Jul 2008, 18:11
by Dougal
I've updated the attachment in the parent post.
It should fix the bugs reported and enable support for static ip with wireless networks (the ip info is included in the network profile).

Posted: Mon 21 Jul 2008, 18:25
by urban soul
Hi, sounds great. - can you put the WPA driver specs into a separate config-file ? Otherwise every time a new driver is compiled by tempestuous the wizard itself has to be modified.

Posted: Mon 21 Jul 2008, 20:31
by Keef
Dougal,

When I run it from the command line I get:-
/usr/bin/net-setup.sh: line 1341: scanpci: command not found

When I try to save a profile I get:-
/usr/sbin/wag-profiles.sh: line 706: : No such file or directory


This was with the original version - I have since tried the new one, but could not get a connection (did not detect wlan0) even after several reboots. Now reverted to the first, and have got back on-line. No save though!

Posted: Tue 22 Jul 2008, 05:43
by prit1
@Dougal:

I tried your latest version. This time, it created the network connection. This is better than the last time.

But when I rebooted, the network did not get enabled. I had to load the profile again, and run auto dhcp to get the network running. Tried rebooting once again with the same result.

Here is an error message I noticed when running net-setup.sh from the prompt.

Code: Select all

Failure (Operation not supported)
/usr/sbin/net-setup.sh: line 622: 4171 Terminated  gxmessage -center -bg "orange" -buttons "" -title "Puppy Network Wizard" "Configuring interface..."
Error, ra0: dhcpd not running

Posted: Tue 22 Jul 2008, 09:11
by Dougal
urban soul wrote:Hi, sounds great. - can you put the WPA driver specs into a separate config-file ? Otherwise every time a new driver is compiled by tempestuous the wizard itself has to be modified.
It would be easy to do, but I'm not sure worth it, since that will just have to be updated, just like the wizard, and it just makes things more scattered...

Posted: Tue 22 Jul 2008, 09:18
by Dougal
Keef wrote:When I run it from the command line I get:-
/usr/bin/net-setup.sh: line 1341: scanpci: command not found
That means that Barry hasn't included scanpci in Dingo (which is part of the Xorg package).
When I try to save a profile I get:-
/usr/sbin/wag-profiles.sh: line 706: : No such file or directory
Ok, I'll have another look at it.