Manual configuration of wireless interfaces

This is a discussion on Manual configuration of wireless interfaces within the Linux Networking forums, part of the Linux Forums category; Hi, I'm running XUbuntu 7.04 (i.e. the "light" version of Dapper Drake). What I would ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-16-2007
triffid@oink.co.uk
 
Posts: n/a
Default Manual configuration of wireless interfaces

Hi,

I'm running XUbuntu 7.04 (i.e. the "light" version of Dapper Drake).

What I would like to be able to do is to configure my ath0 (wireless)
interface from the command line, so that I can
- Set a static IP address (and network parameters)
- Specify the network, including the *WPA* password
- Bring up the interface (such that I can successfully ping any
machine on the Internet)

Actually, I just want to do that stuff full-stop; but since I can't
seem to do it via the supplied GUI tools (and since I'm doing this for
learning purposes), I think it makes more sense to learn how to do it
properly, in as general (and distro-independent) a way as possible.

My card is a D-Link DWL-AG650 (tri-band A/B/G, Atheros-based).

I can successfully connect to my wireless router using the Ubuntu "nm-
applet", but this only seems to allow DHCP (and appears to be quite
limited). The Ubuntu Wireless Assistant ("wlassistant") doesn't appear
to support WPA/WPA2.

Any suggestions would be appreciated. Thank you!

- Triffid

Reply With Quote
  #2 (permalink)  
Old 09-17-2007
nunya
 
Posts: n/a
Default Re: Manual configuration of wireless interfaces

On Sun, 16 Sep 2007 13:59:13 -0700, triffid wrote:

> Hi,
>
> I'm running XUbuntu 7.04 (i.e. the "light" version of Dapper Drake).
>
> What I would like to be able to do is to configure my ath0 (wireless)
> interface from the command line, so that I can
> - Set a static IP address (and network parameters)
> - Specify the network, including the *WPA* password
> - Bring up the interface (such that I can successfully ping any
> machine on the Internet)
>
> Actually, I just want to do that stuff full-stop; but since I can't
> seem to do it via the supplied GUI tools (and since I'm doing this for
> learning purposes), I think it makes more sense to learn how to do it
> properly, in as general (and distro-independent) a way as possible.
>
> My card is a D-Link DWL-AG650 (tri-band A/B/G, Atheros-based).
>
> I can successfully connect to my wireless router using the Ubuntu "nm-
> applet", but this only seems to allow DHCP (and appears to be quite
> limited). The Ubuntu Wireless Assistant ("wlassistant") doesn't appear
> to support WPA/WPA2.
>
> Any suggestions would be appreciated. Thank you!
>
> - Triffid

See wpa_supplicant for your WPA/WPA2 needs.
Reply With Quote
  #3 (permalink)  
Old 09-17-2007
Floyd L. Davidson
 
Posts: n/a
Default Re: Manual configuration of wireless interfaces

triffid@oink.co.uk wrote:
>Hi,
>
>I'm running XUbuntu 7.04 (i.e. the "light" version of Dapper Drake).
>
>What I would like to be able to do is to configure my ath0 (wireless)
>interface from the command line, so that I can
>- Set a static IP address (and network parameters)
>- Specify the network, including the *WPA* password
>- Bring up the interface (such that I can successfully ping any
>machine on the Internet)
>
>Actually, I just want to do that stuff full-stop; but since I can't
>seem to do it via the supplied GUI tools (and since I'm doing this for
>learning purposes), I think it makes more sense to learn how to do it
>properly, in as general (and distro-independent) a way as possible.
>
>My card is a D-Link DWL-AG650 (tri-band A/B/G, Atheros-based).
>
>I can successfully connect to my wireless router using the Ubuntu "nm-
>applet", but this only seems to allow DHCP (and appears to be quite
>limited). The Ubuntu Wireless Assistant ("wlassistant") doesn't appear
>to support WPA/WPA2.
>
>Any suggestions would be appreciated. Thank you!


Tell you what... if you'll get a connection using
whatever that is (I dont use Ubuntu and have no
familiarity with it's GUI toolset), and then show what
that configuration is, I'm sure that I and/or others can
show you the various manual ways to provide that
configuration. From there you can write scripts that do
it, and modify them to provide variations as you like.

The configuration details needed are the output from
"ifconfig" and "iwconfig", plus a dump of your route
table with "route -n".

Knowing what modules get loaded to provide wireless
would also help. If I remember right it would show up
under lsmod as "wlan", "ath_pci", and "ath_hal". If you
can't figure it out otherwise... You might do "lsmod"
after a reboot but before doing anything with the
wireless, and then run it again after connecting the
wireless to see which modules were added to the list.

--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
Reply With Quote
  #4 (permalink)  
Old 09-17-2007
triffid@oink.co.uk
 
Posts: n/a
Default Re: Manual configuration of wireless interfaces

Okay! Here goes (^_^)

The MAC addresses have been changed to protect the innocent(!) but
I've replaced different addresses with different groups of letters
(and by implication duplicated ones with the same letters; e.g.
ZZ:ZZ:ZZ:ZZ:ZZ:ZZ always refers to the same thing).

BEGIN "ifconfig" OUTPUT (while wireless Internet working correctly)
===============

ath0 Link encap:Ethernet HWaddr ZZ:ZZ:ZZ:ZZ:ZZ:ZZ
inet addr:192.168.0.162 Bcast:192.168.0.255 Mask:
255.255.255.0
inet6 addr: fe80::205:5dff:fe9f:c344/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:27 errors:0 dropped:0 overruns:0 frame:0
TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4115 (4.0 KiB) TX bytes:9038 (8.8 KiB)

eth0 Link encap:Ethernet HWaddr YY:YY:YY:YY:YY:YY
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

eth0:avah Link encap:Ethernet HWaddr YY:YY:YY:YY:YY:YY
inet addr:169.254.8.204 Bcast:169.254.255.255 Mask:
255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1

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:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1544 (1.5 KiB) TX bytes:1544 (1.5 KiB)

wifi0 Link encap:UNSPEC HWaddr ZZ-ZZ-ZZ-ZZ-ZZ-
ZZ-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8050 errors:0 dropped:0 overruns:0 frame:196
TX packets:202 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:199
RX bytes:789048 (770.5 KiB) TX bytes:18730 (18.2 KiB)
Interrupt:11


END "ifconfig" OUTPUT ========================

BEGIN "ifconfig" OUTPUT (while wireless Internet working correctly)
===============

lo no wireless extensions.

eth0 no wireless extensions.

wifi0 no wireless extensions.

ath0 IEEE 802.11g ESSID:"whatever" Nickname:""
Mode:Managed Frequency:2.462 GHz Access Point:
MM:MM:MM:MM:MM:MM
Bit Rate:36 Mb/s Tx-Power:16 dBm Sensitivity=0/3
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality=44/94 Signal level=-49 dBm Noise level=-93
dBm
Rx invalid nwid:4228 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

END "iwconfig" OUTPUT ========================

BEGIN "route -n" OUTPUT (while wireless Internet working correctly)
===============

Kernel IP routeing table
Destination Gateway Genmask Flags Metric Ref
Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0
0 ath0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0
0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0
0 ath0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0
0 ath0
0.0.0.0 0.0.0.0 0.0.0.0 U 1000 0
0 eth0

END "route -n" OUTPUT ========================

BEGIN "lsmod" BEFORE GUI (XFCE) LOGIN =================
Module Size Used by
ipv6 268704 8
ppdev 10116 0
speedstep_smi 6672 0
speedstep_lib 6148 1 speedstep_smi
cpufreq_powersave 2688 0
cpufreq_userspace 5408 1
cpufreq_stats 7360 0
cpufreq_conservative 8200 0
cpufreq_ondemand 9228 0
freq_table 5792 3
speedstep_smi,cpufreq_stats,cpufreq_ondemand
dev_acpi 12292 0
tc1100_wmi 8068 0
sony_acpi 6284 0
pcc_acpi 13184 0
battery 10756 0
ac 6020 0
button 8720 0
dock 10268 0
sbs 15652 0
video 16388 0
asus_acpi 17308 0
container 5248 0
i2c_ec 5888 1 sbs
backlight 7040 1 asus_acpi
lp 12452 0
wlan_scan_sta 14976 1
ath_rate_sample 14080 1
ath_pci 97312 0
sg 36252 0
wlan 204484 4 wlan_scan_sta,ath_rate_sample,ath_pci
ath_hal 192592 3 ath_rate_sample,ath_pci
pcmcia 39212 0
sd_mod 23428 0
snd_es1968 30880 0
gameport 16520 1 snd_es1968
snd_ac97_codec 98336 1 snd_es1968
ac97_bus 3200 1 snd_ac97_codec
snd_pcm_oss 44544 0
snd_mixer_oss 17408 1 snd_pcm_oss
snd_pcm 79876 3 snd_es1968,snd_ac97_codec,snd_pcm_oss
parport_pc 36388 1
irtty_sir 9600 0
sir_dev 17156 1 irtty_sir
parport 36936 3 ppdev,lp,parport_pc
snd_page_alloc 10888 2 snd_es1968,snd_pcm
snd_mpu401_uart 9472 1 snd_es1968
irda 201276 2 irtty_sir,sir_dev
snd_seq_dummy 4740 0
snd_seq_oss 32896 0
snd_seq_midi 9600 0
snd_rawmidi 25472 2 snd_mpu401_uart,snd_seq_midi
pcspkr 4224 0
crc_ccitt 3072 1 irda
snd_seq_midi_event 8448 2 snd_seq_oss,snd_seq_midi
snd_seq 52592 6
snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_mid i_event
snd_timer 23684 2 snd_pcm,snd_seq
snd_seq_device 9100 5
snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi ,snd_seq
psmouse 38920 0
serio_raw 7940 0
snd 54020 11
snd_es1968,snd_ac97_codec,snd_pcm_oss,snd_mixer_os s,snd_pcm,snd_mpu401_uart,snd_seq_oss,snd_rawmidi, snd_seq,snd_timer,snd_seq_device
soundcore 8672 1 snd
radio_maestro 9088 0
intel_agp 25116 1
compat_ioctl32 2304 1 radio_maestro
i2c_piix4 9740 0
videodev 28160 1 radio_maestro
v4l2_common 25216 1 videodev
v4l1_compat 15236 2 radio_maestro,videodev
i2c_core 22784 2 i2c_ec,i2c_piix4
agpgart 35400 1 intel_agp
yenta_socket 27532 3
rsrc_nonstatic 14080 1 yenta_socket
pcmcia_core 40852 3 pcmcia,yenta_socket,rsrc_nonstatic
shpchp 34324 0
pci_hotplug 32576 1 shpchp
af_packet 23816 4
tsdev 8768 0
evdev 11008 3
ext3 133128 2
jbd 59816 1 ext3
mbcache 9604 1 ext3
usb_storage 72256 0
libusual 17936 1 usb_storage
ide_disk 17024 4
ide_cd 32672 0
cdrom 37664 1 ide_cd
floppy 59524 0
e100 36232 0
mii 6528 1 e100
uhci_hcd 25360 0
usbcore 134280 4 usb_storage,libusual,uhci_hcd
piix 10756 0 [permanent]
generic 5124 0 [permanent]
ata_generic 9092 0
libata 125720 1 ata_generic
scsi_mod 142348 4 sg,sd_mod,usb_storage,libata
thermal 14856 0
processor 31048 1 thermal
fan 5636 0
fbcon 42656 0
tileblit 3584 1 fbcon
font 9216 1 fbcon
bitblit 6912 1 fbcon
softcursor 3200 1 bitblit
vesafb 9220 0
capability 5896 0
commoncap 8192 1 capability
END "lsmod" BEFORE GUI (XFCE) LOGIN =================

BEGIN "lsmod" *AFTER* GUI (XFCE) LOGIN AND WIRELESS
WORKING=================
Module Size Used by
wlan_tkip 13568 2
ipv6 268704 8
ppdev 10116 0
speedstep_smi 6672 0
speedstep_lib 6148 1 speedstep_smi
cpufreq_powersave 2688 0
cpufreq_userspace 5408 1
cpufreq_stats 7360 0
cpufreq_conservative 8200 0
cpufreq_ondemand 9228 0
freq_table 5792 3
speedstep_smi,cpufreq_stats,cpufreq_ondemand
dev_acpi 12292 0
tc1100_wmi 8068 0
sony_acpi 6284 0
pcc_acpi 13184 0
battery 10756 0
ac 6020 0
button 8720 0
dock 10268 0
sbs 15652 0
video 16388 0
asus_acpi 17308 0
container 5248 0
i2c_ec 5888 1 sbs
backlight 7040 1 asus_acpi
lp 12452 0
wlan_scan_sta 14976 1
ath_rate_sample 14080 1
ath_pci 97312 0
sg 36252 0
wlan 204484 5
wlan_tkip,wlan_scan_sta,ath_rate_sample,ath_pci
ath_hal 192592 3 ath_rate_sample,ath_pci
pcmcia 39212 0
sd_mod 23428 0
snd_es1968 30880 1
gameport 16520 1 snd_es1968
snd_ac97_codec 98336 1 snd_es1968
ac97_bus 3200 1 snd_ac97_codec
snd_pcm_oss 44544 0
snd_mixer_oss 17408 1 snd_pcm_oss
snd_pcm 79876 3 snd_es1968,snd_ac97_codec,snd_pcm_oss
parport_pc 36388 1
irtty_sir 9600 0
sir_dev 17156 1 irtty_sir
parport 36936 3 ppdev,lp,parport_pc
snd_page_alloc 10888 2 snd_es1968,snd_pcm
snd_mpu401_uart 9472 1 snd_es1968
irda 201276 2 irtty_sir,sir_dev
snd_seq_dummy 4740 0
snd_seq_oss 32896 0
snd_seq_midi 9600 0
snd_rawmidi 25472 2 snd_mpu401_uart,snd_seq_midi
pcspkr 4224 0
crc_ccitt 3072 1 irda
snd_seq_midi_event 8448 2 snd_seq_oss,snd_seq_midi
snd_seq 52592 6
snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_mid i_event
snd_timer 23684 2 snd_pcm,snd_seq
snd_seq_device 9100 5
snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi ,snd_seq
psmouse 38920 0
serio_raw 7940 0
snd 54020 13
snd_es1968,snd_ac97_codec,snd_pcm_oss,snd_mixer_os s,snd_pcm,snd_mpu401_uart,snd_seq_oss,snd_rawmidi, snd_seq,snd_timer,snd_seq_device
soundcore 8672 1 snd
radio_maestro 9088 0
intel_agp 25116 1
compat_ioctl32 2304 1 radio_maestro
i2c_piix4 9740 0
videodev 28160 1 radio_maestro
v4l2_common 25216 1 videodev
v4l1_compat 15236 2 radio_maestro,videodev
i2c_core 22784 2 i2c_ec,i2c_piix4
agpgart 35400 1 intel_agp
yenta_socket 27532 3
rsrc_nonstatic 14080 1 yenta_socket
pcmcia_core 40852 3 pcmcia,yenta_socket,rsrc_nonstatic
shpchp 34324 0
pci_hotplug 32576 1 shpchp
af_packet 23816 8
tsdev 8768 0
evdev 11008 3
ext3 133128 2
jbd 59816 1 ext3
mbcache 9604 1 ext3
usb_storage 72256 0
libusual 17936 1 usb_storage
ide_disk 17024 4
ide_cd 32672 0
cdrom 37664 1 ide_cd
floppy 59524 0
e100 36232 0
mii 6528 1 e100
uhci_hcd 25360 0
usbcore 134280 4 usb_storage,libusual,uhci_hcd
piix 10756 0 [permanent]
generic 5124 0 [permanent]
ata_generic 9092 0
libata 125720 1 ata_generic
scsi_mod 142348 4 sg,sd_mod,usb_storage,libata
thermal 14856 0
processor 31048 1 thermal
fan 5636 0
fbcon 42656 0
tileblit 3584 1 fbcon
font 9216 1 fbcon
bitblit 6912 1 fbcon
softcursor 3200 1 bitblit
vesafb 9220 0
capability 5896 0
commoncap 8192 1 capability
END "lsmod" *AFTER* GUI (XFCE) LOGIN AND WIRELESS
WORKING=================


- Triffid

Reply With Quote
  #5 (permalink)  
Old 09-17-2007
triffid@oink.co.uk
 
Posts: n/a
Default Re: Manual configuration of wireless interfaces

On Sep 17, 5:05 am, nunya <busin...@127.0.0.1> wrote:
> See wpa_supplicant for your WPA/WPA2 needs.


Will check that out, assuming I'm not already using it indirectly.
Thank you,

- Triffid

Reply With Quote
  #6 (permalink)  
Old 09-17-2007
triffid@oink.co.uk
 
Posts: n/a
Default Re: Manual configuration of wireless interfaces

On Sep 17, 5:05 am, nunya <busin...@127.0.0.1> wrote:
> See wpa_supplicant for your WPA/WPA2 needs.


Thank you; will check that out assuming I'm not already using it
indirectly.

- Triffid

Reply With Quote
  #7 (permalink)  
Old 09-18-2007
Floyd L. Davidson
 
Posts: n/a
Default Re: Manual configuration of wireless interfaces

triffid@oink.co.uk wrote:
>Okay! Here goes (^_^)


Okay. Let me sort through this... and snip everything
except the parts we want.

>ath0 Link encap:Ethernet HWaddr ZZ:ZZ:ZZ:ZZ:ZZ:ZZ
> inet addr:192.168.0.162 Bcast:192.168.0.255 Mask:


Okay, the IP address is going to be 192.168.0.162. (Or you
can uncomment the dhcpcd command and use dhcp.)

> inet6 addr: fe80::205:5dff:fe9f:c344/64 Scope:Link


I'm going to ignore inet6. If you actually need that, your on
your own... :-)

Also, this is going to use WEP encryption. If you want WPA,
you'll have to figure it out.

>eth0 Link encap:Ethernet HWaddr YY:YY:YY:YY:YY:YY

....
>eth0:avah Link encap:Ethernet HWaddr YY:YY:YY:YY:YY:YY
> inet addr:169.254.8.204 Bcast:169.254.255.255 Mask:


I'm not sure what this is. It is probably just
leftovers that mean nothing. But if you need to have
eth0 configured also... that can be done too.

>wifi0 Link encap:UNSPEC HWaddr ZZ-ZZ-ZZ-ZZ-ZZ-
>ZZ-00-00-00-00-00-00-00-00-00-00


This one is part of the wireless, but we don't actually
need anything from it.


>BEGIN "ifconfig" OUTPUT (while wireless Internet working correctly)


Typo alert: I'm sure this is iwconfig output, not ifconfig.

>ath0 IEEE 802.11g ESSID:"whatever" Nickname:""
> Mode:Managed Frequency:2.462 GHz Access Point:
>MM:MM:MM:MM:MM:MM


This is the interface for the wireless. Useful info needed:

ESSID: "whatever"
AP: "MM:MM:MM:MM:MM:MM"
Freq: 2.462 GHz

Necessary information not seen: encryption

Here's your routing table, edited to shorten up the lines.

Destination Gateway Genmask Flags Metric Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 ath0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 ath0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 ath0
0.0.0.0 0.0.0.0 0.0.0.0 U 1000 eth0

Hmmm... I would have look up what the metric being set to
1000 accomplishes. (I suspect nothing useful.)

>BEGIN "lsmod" BEFORE GUI (XFCE) LOGIN =================


This was interesting. Your wireless device driver modules
were already loaded. It also confirmed that you are in fact
using the atheros/madwifi drivers, so we know we've got the
same thing.

Now, lets step through what I do on my laptop to
configure the wireless, except I'll switch to your
configured parameters. Hmmm... I think I'll basically
just post the entire script. This was set up as an rc
script that can be run at boot time, except I don't
actually use it that way (because I typically boot the
laptop in about 4 or 5 different environments, and have
a big, and very complex, menu script which selects
different ways of doing things. This script is just one
part of one menu selection them).

I'll put comments that are added just for you behind "##",
rather than just one '#'.

#!/bin/bash
#
# wifinet -- start, stop or restart wireless connection
#

PATH=/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:

mac1=MM:MM:MM:MM:MM:MM ## Put your AP's real MAC address there

##
## This next is just a way to store this data someplace
## that I can easily find it.
##
# WEP Keys (key_string_is_here):
#
# 3085...9A3 ## This lists the WEP keys that I use
# 6088...E85 ## for this particular configuration
# 4E93...069 ## The string that generated it is in
# 9240...6A9 ## the comment above.
#

wifi_start() {
## Start fresh, get rid of whatever existed.
wifi_stop

## This looks to see if the atheros driver module
## is loaded, and if not loads it.
##

# Attach the wireless device
if ! lsmod | /bin/grep -q "^ath_pci" ; then
modprobe ath_pci || exit 100
fi

if ifconfig ath0 >& /dev/null; then
## ath0 exists... proceed

## bind an IP address to the eth0 interface
##
## Note that using the minimum posible number of
## command line parameters results in a default
## route entry being made too. It may or may not
## actually be suitable for what you want.
##
## Also, you can bind whatever address you like here,
## and either use it or have dhcpcd reconfigure it
## later with another IP address.
##
ifconfig ath0 192.168.0.162 || exit 101

ESSID="essid whatever"
MODE="mode Managed"
FREQ="freq 2.462G" # chan 11
KEY="key 000102030405..." ## put your WEP key here
AP="ap $mac1" ## you can also us "ap auto"

## This can be commented out... it just show what
## command the script is actually running.
CMD="iwconfig ath0 $ESSID $MODE $FREQ $KEY $AP"
echo "$CMD"

## This is the actual execution of the command
$CMD || exit 102

## At this point, the wirelss should have a connection.
## However, the route table will almost certainly be
## in a state of uselessness.

# This route is set by ifconfig:
# /sbin/route add -net 192.168.0.0 netmask 255.255.255.0 dev ath0

## This may need some fine tuning. The purpose it serves is
## to clean up a route table that may have previously been
## configured for a different wireless driver, a different
## wireless configuration, or for an ethernet connection.
##
## It is specifically looking for 192.168.1.x as wireless, and
## 192.168.0.x as a LAN ethernet connection. If you use something
## else, this needs to be changed to match.

# Adjust the route table
/sbin/route -n | while read ip gw mask flags metric ref use dev junk ; do

## Loop through the table, looking for specific
## routes to delete
##
## This deletes anything set up with a gateway
##
# remove all gateways to 192.168.1.x or 192.168.0.x IP addresses
if [ "${gw:0:10}" = "192.168.1." -o "${gw:0:10}" = "192.168.0." ] ; then
route del -net $ip netmask $mask dev $dev >& /dev/null
continue
fi

##
## These specifics command delete various firewall
## routes that are likely to be found on networks
## that I connect to. You'll have your own set of
## specific addresses you want deleted.
##

# remove all host routes to firewall's

if [ "${ip}" = "192.168.1.103" ] ; then
route del -net $ip netmask $mask dev $dev >& /dev/null
continue
fi

if [ "${ip}" = "192.168.1.1" ] ; then
route del -net $ip netmask $mask dev $dev >& /dev/null
continue
fi

if [ "${ip}" = "192.168.0.1" ] ; then
route del -net $ip netmask $mask dev $dev >& /dev/null
continue
fi
done

##
## This will add the right gateways.
##
## You might want other routes too, depending on how
## your LAN is segmented. For example, the default
## route that ifconfig set is only for the 192.168.0.x
## subnet, but your original route table is showing
## all 192.168.x.x addresses routed to ath0. To have
## that, use the alternet set of route command below.
##

# add a new default route
route add default gw 192.168.0.1 ath0
# route -n

## Alternate set of route commands:
##
## route del -net 192.168.0.0 netmask 255.255.255.0 dev ath0
## route add -net 192.168.0.0 netmask 255.255.0.0 dev ath0
## route add default gw 192.168.0.1 ath0

## A second alternate set of route commands.
## This one adds to only a single host, which is
## the gateway and is added because it is not on
## the 192.168.0.x subnet. In order to use it as
## a gateway there has to be a route to it, but in
## this case only the single host is getting a route.
##
## route add -host 192.168.5.1 dev ath0
## route add default gw 192.168.5.1 ath0

## You'll need to set the right IP addresses here
## This sets up DNS. If just set it to get DNS
## from your gateway, which may or may not be right.

# make sure we like /etc/resolv.conf
echo "nameserver 192.168.0.1" > /etc/resolv.conf
##
## And this will use dhcpcd to get an IP address for your
## interface. It can be commented out if you want the
## static IP address as set above
##
## Note that dhcpcd may or may not change your /etc/resolv.conf
## file or do other odd things, such as change the route table.
## You'll have to look and see what it has changed, and customize
## the script to match as necessary.
##
# dhcpcd -d ath0
fi
}


wifi_stop() {
killall dhcpcd &> /dev/null

if ifconfig ath0 >& /dev/null ; then
ifconfig ath0 down
fi

# only remove ath_pci if ath1 is also down
if ! ifconfig ath1 >& /dev/null ; then
if grep -q "^ath_pci" /proc/modules ; then
rmmod ath_pci
fi
fi
}

wifi_restart() {
wifi_stop
sleep 1
wifi_start $mac
}

case "$1" in
'start' | 'up')
wifi_start
;;
'stop' | 'down')
wifi_stop
;;
'restart')
wifi_restart
;;
*)
echo "usage $0 start|stop|restart"
;;
esac




--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
Reply With Quote
  #8 (permalink)  
Old 09-20-2007
triffid@oink.co.uk
 
Posts: n/a
Default Re: Manual configuration of wireless interfaces

Much appreciated; I'll take a closer look at that when I have more
time to do it justice, but it certainly appears to be along the lines
of what I was looking for. Thanks!

- Triffid

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:17 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0