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