DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 20th August 2011
woomia woomia is offline
New User
 
Join Date: Mar 2011
Posts: 6
Default Ifconfig and open wifi hotspots

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?
Reply With Quote
  #2   (View Single Post)  
Old 20th August 2011
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,503
Default

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
Reply With Quote
  #3   (View Single Post)  
Old 20th August 2011
sepuku's Avatar
sepuku sepuku is offline
Real Name: Vizard Sepuku
Package Pilot
 
Join Date: Jun 2011
Location: Athens & Chania,Greece
Posts: 143
Default

Also check the ifconfig manual:

Code:
man ifconfig
Reply With Quote
  #4   (View Single Post)  
Old 20th August 2011
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

Quote:
Originally Posted by woomia View Post
What am I missing?
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:
But there is no key to put in since it's open.
If you need to clear a prior WEP key or WPA passphrase, add the -nwkey or -wpakey operands to your ifconfig command.
Reply With Quote
  #5   (View Single Post)  
Old 20th August 2011
woomia woomia is offline
New User
 
Join Date: Mar 2011
Posts: 6
Default

Quote:
Originally Posted by jggimi View Post
A dhclient(8) command.

The assignment of an IP address, subnet mask, routing information, and domain name server addresses comes from a service on the McDonalds network.

# ifconfig rum0 nwid mcdonalds
# dhclient rum0
If you need to clear a prior WEP key or WPA passphrase, add the -nwkey or -wpakey operands to your ifconfig command.
Ah, I was missing the -nwkey and -wpakey commands.

I did read man ifconfig but I didn't quite see what I was looking for, or what even to look for.

Thanks, all!
Reply With Quote
  #6   (View Single Post)  
Old 20th August 2011
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

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.
Reply With Quote
  #7   (View Single Post)  
Old 4th October 2011
puffy
-Guest-
 
Posts: n/a
Wink

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.
Reply With Quote
  #8   (View Single Post)  
Old 12th March 2013
sysfu sysfu is offline
Port Guard
 
Join Date: Jun 2008
Posts: 36
Default

Quote:
Originally Posted by shep View Post
At the time of this post I believe that this link is succinct and accurate
openbsd-restart-network/
I like to run the following command with the -x switch when restarting the network so I can view detailed output:

Code:
sudo sh -x /etc/netstart <your interface>
Reply With Quote
  #9   (View Single Post)  
Old 3rd April 2013
Overrider Overrider is offline
Real Name: Dave
New User
 
Join Date: Dec 2012
Location: Virtually everywhere
Posts: 6
Default

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.
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PF - ifconfig problem ripp3r OpenBSD Security 5 12th December 2010 04: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


All times are GMT. The time now is 07:37 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick