Reply to comment

FreeBSD i386 Install (Part 2, Internet)

After the FreeBSD system has booted for the first time, after logging in as the non-root user created, the first thing needed in the modern world is internet access, since I had a cheapo TP-LINK TL-WN321G hanging around, which is based on the Ralink chipset I just used that.

After inserting the thing into the USB, see if it is recognized, by looking at the system message buffer via dmesg, and pipe it to tail in this case since I only care about the last few lines:

$ dmesg | tail -n 3
ugen3.2: <Ralink> at usbus3
rum0: <Ralink 54M.USB......., class 0/0, rev 2.00/0.01, addr 2> on usbus3
rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528

OK, so it is a rum0 device, so let us have a look, we are going to need to su to root at some point so we will do that now too:

$ su
Password:
# ifconfig rum0
rum0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether 00:1f:e2:3d:40:05
        media: IEEE 802.11 Wireless Ethernet autoselect <adhoc> (autoselect <ad
hoc>)
        status: no carrier

Not really my MAC of course. FreeBSD requires the creation of a pseudo wlan device for wireless:

# ifconfig wlan1 create wlandev rum0

Which says to create the pseudo-device wlan1 using the parent device rum0. Note that I already had another device setup when I was writing this, so I used wlan1 instead of wlan0, since the latter already existed. Sometimes the devices don't go UP, so just to be sure:

# ifconfig rum0 up
# ifconfig wlan1 up
rum0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether 00:1f:e2:3d:40:05
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
        status: associated
# ifconfig wlan1
wlan1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:1f:e2:3d:40:05
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
        ssid "" channel 4 (2427 Mhz 11g)
        country US authmode OPEN privacy OFF txpower 0 bmiss 7 scanvalid 60
        bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5
        protmode CTS bintval 0

So you can see both devices are UP. Now you need information about the network you are connecting to. I'm connecting to a WPA2 encrypted network. If you already know the SSID, great, otherwise you need to scan:

# ifconfig wlan1 list scan
SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
WIFIGATE        00:15:31:b4:82:90    1   54M -87:-95  100 EP   WPA

Now edit /etc/wpa_supplicant.conf to provide some data about the access point. There are a ton of options, but for a standard WPA2 AP you can hopefully get away with the following:

network={
   ssid="WIFIGATE"
   psk="PASSWORD"
}

Note "network={" can have no spaces. Now you need to start wpa_supplicant:

# wpa_supplicant -iwlan1 -c /etc/wpa_supplicant.conf
CTRL-EVENT-SCAN-RESULTS 
Trying to associate with 00:15:31:b4:82:90 (SSID='SKY01839' freq=2412 MHz)
Associated with 00:1f:e2:3d:40:05
WPA: Key negotiation completed with 00:1f:e2:3d:40:05 [PTK=TKIP GTK=TKIP]
CTRL-EVENT-CONNECTED - Connection to 00:1f:e2:3d:40:05 completed (auth)
[id=2 id_str=]

I did that in the foreground because I wanted to watch it, you can use -d for additional information. Now that it is connected, we need to get an IP, suspend wpa_supplicant with CTRL-Z it and then put it to the background:

 ^Z[1] + Suspended               wpa_supplicant -iwlan1 -c /etc/wpa_supp
licant.conf
# bg
[1] wpa_supplicant -iwlan1 -c /etc/wpa_supplicant.conf

Get an IP using dhclient:

# dhclient wlan1
DHCPREQUEST on wlan1 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.6 -- renewal in 43200 seconds.

Test:

# ping -c 2 www.google.co.uk
PING www-tmmdi.l.google.com (66.102.9.103): 56 data bytes
64 bytes from 66.102.9.103: icmp_seq=0 ttl=55 time=38.546 ms
64 bytes from 66.102.9.103: icmp_seq=1 ttl=55 time=37.888 ms

--- www-tmmdi.l.google.com ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 37.888/38.217/38.546/0.329 ms

Now you might get annoyed by messages from wpa_supplicant, even though it is in the background, so you probably want to run it with the -B flag for daemon operation in the future. Of course, you don't really want to have to do this ever again, but it is worth seeing how to do it (because for some reason you will end up doing this many times on many machines for various stupid reasons). To make all this happen automatically at boot, add the following to /etc/rc.conf :

wlans_rum0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP"

Which says to create the pseudo device wlan0 attached to rum0 and then configure it automatically via wpa_supplicant and dhclient. The synchronous_dhclient it I needed because background dhclient didn't seem to work for me, perhaps you will have more luck.

Now I don't use this rum0 because it sticks out of the laptop which is annoying. Instead I have a mini-pci:

iwi0: <Intel(R) PRO/Wireless 2200BG> mem 0xe0105000-0xe0105f4a irq 10 at device
4.0 on pci2

Which uses the antenna built into the laptop. I bought this of ebay for six pounds inc delivery. The laptop did have an Ambit T60N871 inside it, but I couldn't get WPA2 to work with ndiswrapper and the ancient Acer windows drivers, so I thought fuckit and just bought the 2200BG which I looked up to be supported withFreeBSD. Hint: you might need to turn the device on first, check for a 1 with sysctl:

# sysctl -a | grep iwi | grep radio
dev.iwi.0.radio: 1

OK well that is it, connected to the internet, if you wanted to use ethernet it should be as simple as typing ifconfig to see what the device is, and then dhclient-ing it. Right, so we now have a non-gui box, connected to the internet, woo hoo. Next time, setting up the GUI and some other stuff.

Reply

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
Are you human? Or are you dancer?
Fill in the blank