Pidora2014(Fedora20)で無線LAN対応
□Pidora2014(Fedora20)で無線LAN対応(BUFFALO WLI-UC-GNM)
参考URL:
https://wiki.archlinux.org/index.php/Beginners’_Guide_(%E6%97%A5%E6%9C%AC%E8%AA%9E)#.E7.84.A1.E7.B7.9A
https://wiki.archlinux.org/index.php/Wireless_Setup_(%E6%97%A5%E6%9C%AC%E8%AA%9E)#.E3.83.AF.E3.82.A4.E3.83.A4.E3.83.AC.E3.82.B9.E7.AE.A1.E7.90.86
980円で買える無線LANドングルを認識させる…挿せばいいだけ。:-)
/var/log/messagesを見ると
> Jul 31 11:13:26 pidora kernel: [ 118.796952] usb 1-1.2: new high-speed USB device number 6 using dwc_otg
> Jul 31 11:13:26 pidora kernel: [ 118.913085] usb 1-1.2: New USB device found, idVendor=0411, idProduct=01a2
> Jul 31 11:13:26 pidora kernel: [ 118.913121] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> Jul 31 11:13:26 pidora kernel: [ 118.913141] usb 1-1.2: Product: 802.11 n WLAN
> Jul 31 11:13:26 pidora kernel: [ 118.913160] usb 1-1.2: Manufacturer: Ralink
> Jul 31 11:13:26 pidora kernel: [ 118.913175] usb 1-1.2: SerialNumber: 1.0
> Jul 31 11:13:28 pidora kernel: [ 120.140693] cfg80211: Calling CRDA to update world regulatory domain
> Jul 31 11:13:28 pidora kernel: [ 120.179155] cfg80211: World regulatory domain updated:
> Jul 31 11:13:28 pidora kernel: [ 120.179198] cfg80211: (start_freq – end_freq @ bandwidth), (max_antenna_gain, max_eirp)
> Jul 31 11:13:28 pidora kernel: [ 120.179219] cfg80211: (2402000 KHz – 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm)
> Jul 31 11:13:28 pidora kernel: [ 120.179232] cfg80211: (2457000 KHz – 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm)
> Jul 31 11:13:28 pidora kernel: [ 120.179245] cfg80211: (2474000 KHz – 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm)
> Jul 31 11:13:28 pidora kernel: [ 120.179258] cfg80211: (5170000 KHz – 5250000 KHz @ 80000 KHz), (N/A, 2000 mBm)
> Jul 31 11:13:28 pidora kernel: [ 120.179272] cfg80211: (5735000 KHz – 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm)
> Jul 31 11:13:28 pidora kernel: [ 120.179285] cfg80211: (57240000 KHz – 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm)
> Jul 31 11:13:28 pidora kernel: [ 120.376829] usb 1-1.2: reset high-speed USB device number 6 using dwc_otg
> Jul 31 11:13:28 pidora kernel: [ 120.486094] ieee80211 phy0: rt2x00_set_rt: Info – RT chipset 3070, rev 0201 detected
> Jul 31 11:13:28 pidora kernel: [ 120.531225] ieee80211 phy0: rt2x00_set_rf: Info – RF chipset 0005 detected
> Jul 31 11:13:28 pidora kernel: [ 120.575342] usbcore: registered new interface driver rt2800usb
というように一発認識、lsusbも
> Bus 001 Device 005: ID 04d9:1400 Holtek Semiconductor, Inc. PS/2 keyboard + mouse controller
> Bus 001 Device 006: ID 0411:01a2 BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNM Wireless LAN Adapter [Ralink RT8070]
> Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
> Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
このとおり。
ip aしてみると
> # ip a
> 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
> link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
> inet 127.0.0.1/8 scope host lo
> valid_lft forever preferred_lft forever
> inet6 ::1/128 scope host
> valid_lft forever preferred_lft forever
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
> link/ether b8:27:eb:f3:7a:43 brd ff:ff:ff:ff:ff:ff
> inet 192.168.100.113/24 brd 192.168.100.255 scope global dynamic eth0
> valid_lft 259134sec preferred_lft 259134sec
> inet 192.168.100.81/24 brd 192.168.100.255 scope global secondary eth0:81
> valid_lft forever preferred_lft forever
> inet6 fe80::ba27:ebff:fef3:7a43/64 scope link
> valid_lft forever preferred_lft forever
> 3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
> link/ether b0:c7:45:a9:ca:0b brd ff:ff:ff:ff:ff:ff
としてwlan0が認識されていればOK。
もしくはiwコマンドで
> # iw dev
> phy#0
> Interface wlan0
> ifindex 3
> wdev 0x1
> addr b0:c7:45:a9:ca:0b
> type managed
としてwlan0が認識されていればOK。
そしたらipコマンドでwlan0を起動する
ip link set wlan0 up
すると
iw dev wlan0 scan
でアクセスポイントが見えるので、自分が接続したいAPに接続する。
WEPなら
iw dev wlan0 connect your_essid key 0:your_key
WPAなら
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
※もちろんどちらも接続したいAPに合わせてSSIDとかKEYとか書くこと
どっちにしても接続できたかどうかはipかiwコマンドで
> # iw dev wlan0 link
> Connected to 00:07:40:f1:2f:04 (on wlan0)
> SSID: BIGNETSHIBUYA
> freq: 2457
> RX: 17109 bytes (291 packets)
> TX: 945 bytes (15 packets)
> signal: -57 dBm
> tx bitrate: 6.0 MBit/s
>
> bss flags: short-slot-time
> dtim period: 1
> beacon int: 100
> # ip a
> 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
> link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
> inet 127.0.0.1/8 scope host lo
> valid_lft forever preferred_lft forever
> inet6 ::1/128 scope host
> valid_lft forever preferred_lft forever
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
> link/ether b8:27:eb:f3:7a:43 brd ff:ff:ff:ff:ff:ff
> inet 192.168.100.113/24 brd 192.168.100.255 scope global dynamic eth0
> valid_lft 257567sec preferred_lft 257567sec
> inet 192.168.100.81/24 brd 192.168.100.255 scope global secondary eth0:81
> valid_lft forever preferred_lft forever
> inet6 fe80::ba27:ebff:fef3:7a43/64 scope link
> valid_lft forever preferred_lft forever
> 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
> link/ether b0:c7:45:a9:ca:0b brd ff:ff:ff:ff:ff:ff
> inet6 2001:3e0:c000:5600:b2c7:45ff:fea9:ca0b/64 scope global dynamic
> valid_lft 14353sec preferred_lft 14353sec
> inet6 fe80::b2c7:45ff:fea9:ca0b/64 scope link
> valid_lft forever preferred_lft forever
のようにして判る。
IPv4アドレスを取得する場合には
dhclient wlan0
もしくは
ip addr add 192.168.0.2/24 dev wlan0
ip route add default via 192.168.0.1
のようにして固定IPをべたべたとすればいいらしい
で、これは面倒なので、カスタムサービスを作ることになる。
cat > /etc/systemd/system/network-wireless@.service
----------
[Unit]
Description=Wireless network connectivity (%i)
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/ip link set dev %i up
ExecStart=/usr/sbin/iw dev wlan0 connect your_essid key 0:your_key
###ExecStart=/usr/sbin/wpa_supplicant -B -i %i -c /etc/wpa_supplicant.conf
ExecStart=/usr/sbin/dhclient %i
ExecStop=/usr/bin/ip link set dev %i down
[Install]
WantedBy=multi-user.target
----------
あとは
systemctl unmask network-wireless@wlan0.service
systemctl enable network-wireless@wlan0.service
で自動起動するようにしておいて、かつ
cat > /etc/sysconfig/network-scripts/ifcfg-wlan0
----------
DEVICE=wlan0
ONBOOT=no
#
NM_CONTROLLED=no
#
# for firewalld
ZONE=trusted
----------
として再起動すれば、WiFiドングルがあれば自動的に接続するようになる。
(network.service では起動しない(ONBOOT=no)が、カスタムサービスで起動するのでOK)
ちなみに手動で起動する場合には
systemctl start network-wireless@wlan0.service
とすればよい。
いやー、コマンド覚えるのめんどくさー(というかカスタムサービス書くのもめんどくさー)