![]() |
|
|||||||
| OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|||
|
After RTFM I can't figure how to connect to an open wifi hotspot. For example, mcdonalds's:
I try ifconfig rum0 nwid mcdonalds But there is no key to put in since it's open. What am I missing? |
|
|||
|
Most open wifi hotspots assign DHCP addresses AFTER you
1) Bring the network up 2) Request the address with dhclient. OpenBSD has a script that does all this at boot and reads the values in /etc/hostname.rum0 At the time of this post I believe that this link is succinct and accurate openbsd-restart-network/ Last edited by shep; 20th August 2011 at 03:19 PM. Reason: spelling |
|
|||
|
Quote:
Code:
sudo sh -x /etc/netstart <your interface> |
|
||||
|
A dhclient(8) command.
The assignment of an IP address, subnet mask, routing information, and domain name server addresses comes from a DHCP service on the McDonalds network. # ifconfig rum0 nwid mcdonalds # dhclient rum0 Quote:
__________________
OpenBSD LiveCDs/LiveDVDs |
|
|||
|
Quote:
I did read man ifconfig but I didn't quite see what I was looking for, or what even to look for. Thanks, all! |
|
|||
|
That's only required, as jggimi said, if the kernel was previously associated with another WEP access point.. the output of ifconfig rum0 would show them as still set, same goes for wpa options.
I find for painless associating it's good to provide as much information to ifconfig as possible, i.e: specify the nwid and the channel. |
|
|||
|
The OP does not give us the output of `ifconfig`, which would be useful to determine whether the rum0 interface has to be marked 'up'. My assumption would be that he does NOT have an /etc/hostname.rum0 file that runs on startup because he is typing in
# ifconfig rum0 nwid mcdonalds If he does have an /etc/hostname.rum0 file, then he should do something like: # pgrep dhclient >/dev/null && sudo pkill dhclient; sudo dhclient rum0 Heck that could even be an alias... At any rate, I hope the following script automates your next wifi connection: HTML Code:
#!/bin/sh
#
# BSD license and disclaimers apply.
#
# Do not change to zsh; it will break. There are subtle differences.
#
# This script should be installed with execute permissions, and
# be invoked by name.
#
#-------------------------------------------------------------------------
#
# helper functions
#
#-------------------------------------------------------------------------
function parseit
{
local therest
shift 1
wifiname=$1
shift 1
therest=$*
IFS=" "
set $therest
shift 4
sigstrength=$1
}
function readprobe
{
#
# this was not as easy to write as it looks
#
local input
while read input
do
IFS=" "
if echo $input | grep -q \"; then
IFS="\""
fi
parseit $input
ap[nwifi]=$wifiname
decibel[nwifi]=${sigstrength%dB}
nwifi=$(($nwifi+1))
done
}
function sortandprint
{
typeset tempnm
typeset tempst
integer i
integer j
integer inc
integer n
integer s
s=$1
n=$2
# s is offset in arrays where sort starts
# n is number of items to sort
# In other words, sort elements $s to $s + $n
#
# Implement a Shell sort. In ksh. Painful. All the write-only jive-notation
# of perl, none of the functionality.
#
if [ $n -eq 0 ]; then
echo $MSG10
return
fi
inc=$(($n/2))
while [ $inc -gt 0 ]
do
i=$inc
while [ $i -lt $n ]
do
j=$i
tempst=${decibel[$(($i+$s))]}
tempnm=${ap[$(($i+$s))]}
#
# to change the sense of the sort, change the second test.
# use -lt for biggest first, -gt for smallest first.
#
while [[ $j -ge $inc && ${decibel[$(($j+$s-$inc))]} -lt $tempst ]]
do
decibel[$(($j+$s))]=${decibel[$(($j+$s-$inc))]}
ap[$(($j+$s))]=${ap[$(($j+$s-$inc))]}
j=$(($j-$inc))
done
decibel[$(($j+$s))]=$tempst
ap[$(($j+$s))]=$tempnm
i=$(($i+1))
done
if [ $inc -eq 2 ]; then
inc=1
else
inc=$(($inc/2))
fi
done
i=$s
while [ $i -lt $(($n+$s)) ]
do
printf "%4d %-32s\t%3d%s\n" $(($i+1)) "${ap[$i]}" ${decibel[$i]} "dB"
i=$(($i+1))
done
}
function cleanup
{
if [ -t 0 -a -t 1 ]; then
stty sane
fi
rm -f $TMPPROBE
exit
}
#-------------------------------------------------------------------------
#
# "main" part of the script
#
#-------------------------------------------------------------------------
progname=${0##*/}
ifname=`ifconfig |
awk '{lines[NR]=$0} /IEEE802.11/ {print substr(lines[NR-4],1,4)}'`
MSG1="usage: $progname"
MSG2="$progname: Wireless access point selection for device:"
MSG3="Available public wifi . . . . . . . . . score"
MSG4="Available secured wifi . . . . . . . . .score"
MSG5="$progname: no wireless access points found"
MSG6="choice out of range"
MSG7="try again"
MSG8="public wifi selected"
MSG9="$progname: not interactive and no public wifi"
MSG10="none probed"
CHOOSEPROMPT="Select wifi> "
PASSPROMPT="Password for"
PROBECMD="sudo ifconfig $ifname scan"
if [ $# -gt 0 ]; then
echo $MSG1 \\nextra arguments: $@ >&2
exit 1
fi
TMPPROBE=`mktemp -t $ifname.XXXXXXXX` || exit 1
if pgrep dhclient >/dev/null; then
sudo pkill dhclient
fi
trap cleanup EXIT INT PIPE
integer nwifi=0
integer private=0
if [ -t 0 -a -t 1 ]; then
mypager=$PAGER
else
mypager=cat
fi
# generate a menu
# Do this even for batch use, to log results during, say, boot/rc
#
# if this script is used in another script and output is not
# wanted, then invoke it with </dev/null >/dev/null and perhaps
# 2>/dev/null
#
echo $MSG2 $ifname
echo
echo $MSG3
echo "-----------------------------------------------------------------"
eval \$PROBECMD \| sed -n \'/privacy/!s/^[[:space:]]*//\;/^nwid/p\' \> \$TMPPROBE
readprobe < $TMPPROBE
sortandprint 0 $nwifi > $TMPPROBE
eval \$mypager \$TMPPROBE
# for obscure reasons of scoping, do not "simplify" the preceding
# two lines by discarding the temp file and putting readprobe on the
# end of the pipe.
#
# Put no function in a pipe (wrecks scope)
#
# the dividing point between public and private:
private=$nwifi
echo
echo $MSG4
echo "-----------------------------------------------------------------"
eval \$PROBECMD \| sed -n \'/privacy/s/^[[:space:]]*//\;/^nwid/p\' \> \$TMPPROBE
readprobe < $TMPPROBE
sortandprint $private $(($nwifi-$private)) > $TMPPROBE
eval \$mypager \$TMPPROBE
# the "if" establishes whether stdin and stdout are ttys.
# This is not flawless, of course, but tends to guess whether
# an operator is present.
# It would be better if a variable asserting batchness were present
# on the command line or in the environment.
integer choice=-1
if [ $nwifi -eq 0 ]; then
echo $MSG5 >&2
cleanup
fi
if [ -t 0 -a -t 1 ]; then
while [ 0 ]
do
read choice?"$CHOOSEPROMPT"
if [ $choice -eq 0 ]; then
break
elif [ $choice -gt $nwifi ]; then
echo $MSG6 $choice
echo $MSG7
else
break
fi
done
if [ $choice -eq 0 ] ; then
cleanup
fi
#
# decrement choice to accommodate zero-based arrays
#
choice=$(($choice-1))
if [ $choice -ge $private ]; then
stty -echo
read pass?"$PASSPROMPT ${ap[$choice]}> "
stty echo
echo
wpakey="wpakey $pass"
else
echo $MSG8 ${ap[$choice]}
fi
else # non-interactive
if [ $private -eq 0 ]; then
echo $MSG9 >&2
cleanup
else # configure the first (strongest) public wifi
choice=1
fi
fi
eval sudo ifconfig \$ifname nwid \"${ap[$choice]}\" \$wpakey up
sudo dhclient $ifname
cleanup
Last edited by puffy; 18th April 2012 at 12:13 PM. |
|
|||
|
May i point to https://github.com/overrider/wireless , which is a very simple connection helper of my own humble creation. It's incredibly simple, basically add SSID and WPA Key to a config file, then connect to a wireless network by issuing ./wireless SSID . As i said its nothing fancy, but because i am traveling A LOT between different networks, i use it every single day.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PF - ifconfig problem | ripp3r | OpenBSD Security | 5 | 12th December 2010 03:10 PM |
| need some basic help on ifconfig | daemon-dd | FreeBSD General | 4 | 29th July 2008 03:21 PM |
| FreeBSD's Ifconfig for WEP | tz24 | FreeBSD General | 15 | 13th June 2008 02:17 AM |
| hard lock on ifconfig wi0 up | reuteler | OpenBSD General | 11 | 25th May 2008 06:22 PM |
| ifconfig problem | ichigo | OpenBSD General | 3 | 20th May 2008 10:59 PM |