LoginSignup
10
10

More than 5 years have passed since last update.

SORACOM Air SIMカード + FS01BU + Debian 7.5 (VirtualBox/Vagrant)

Last updated at Posted at 2015-10-06

概要

SORACOM Air SIMカードをUSBモデムFS01BUを使って通信します。検証環境の構築を兼ねてVagrantで構築したDebian上で作業を行います。本稿の大部分はすでに他の方が実現していることを参考にしたもので、手元環境で再現するまでの作業メモです。

ホストOS: MacOS X 10.11
Vagrant: 1.7.4
VirtualBox: 5.0.6r103037 with Extension Pack
※ VirtualBoxにインストールするOSはHashicorp Atlasから取得

手順

Vagrant/VirtualBoxをインストール

ゲストOS側でUSBを使用するためにVirtualBoxにExtension Packを追加
https://www.vagrantup.com/
https://www.virtualbox.org/wiki/Downloads

VagrantでDebian環境を構築

$ vagrant init puphpet/debian75-x64

VirtualBoxでUSBを有効化するためにVagrantに以下の記述を追加

Vagrantfile

config.vm.provider "virtualbox" do |vb|
  vb.customize ['modifyvm', :id, '--usb', 'on']
end

仮想環境を作成

$ vagrant up --provider virtualbox
$ vagrant ssh

Debian環境設定

$ lsusb
-bash: lsusb: command not found

lsusbがないのでusbutilsをインストール

$ sudo apt-get install usbutils
$ lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

まだUSBモデムを接続していないので認識されていない様子
VagrantBox設定からUSBモデムを追加

01.png

追加したUSB Modemをダブルクリックして設定値を確認

02.png

Vagrantから再起動

$ vagrant reload

再度lsusbを実行するとデバイスが確認できる

$ lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 1c9e:98ff OMEGA TECHNOLOGY

ここでプロダクトIDが98ffのままだとUSB Modemとしては認識されていないので、usb_modeswitchを使って設定を変更する

sub_modeswitchインストール

$ apt-get install usb-modeswitch

(usb_modeswitchコマンドはインストールされないのでソースからコンパイルしたが、最終的には使わなくて済む様子。ただし環境依存条件かもしれない)

ttyデバイスとして設定

Vagrantから再起動してVirtualBox設定からUSB Modemをもうひとつ追加
Product IDが6801になっていることを確認

03.png

Debianからlsusbを実行してProduct IDが6801になっていることを確認。USBを認識していない場合、ホストOS側のマウントを解除するか、USBポートから一度取り出して再接続する

lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 1c9e:6801 OMEGA TECHNOLOGY

ttyデバイス設定

(以下は概ね参考にした方々の手順と同じです)

$ modprobe usbserial vendor=0x1c9e product=0x6801
$ ls -al /dev/ttyU*
crw-rw---T 1 root dialout 188, 0 Oct  6 02:46 /dev/ttyUSB0
crw-rw---T 1 root dialout 188, 1 Oct  6 02:46 /dev/ttyUSB1
crw-rw---T 1 root dialout 188, 2 Oct  6 02:46 /dev/ttyUSB2

wvdialで通信

$ apt-get install wvdial

404 Not Foundが出力される場合はapt-get updateを実行してから再インストール

/etc/wvdial.confを編集

/etc/wvdial.conf
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","soracom.io"
Dial Attempts = 3
Modem Type = Analog Modem
Dial Command = ATD
Stupid Mode = yes
Baud = 460800
New PPPD = yes
Modem = /dev/ttyUSB2
ISDN = 0
APN = soracom.io
Phone = *99***1#
Username = sora
Password = sora
Carrier Check = no
Auto DNS = 1
Check Def Route = 1

wvdialを実行

$ sudo wvdial
--> WvDial: Internet dialer version 1.61
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: AT+CGDCONT=1,"IP","soracom.io"
AT+CGDCONT=1,"IP","soracom.io"
OK
--> Modem initialized.
--> Sending: ATD*99***1#
--> Waiting for carrier.
ATD*99***1#
CONNECT 14400000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Tue Oct  6 02:54:09 2015
--> Pid of pppd: 5393
--> Using interface ppp0
--> pppd: �[7f]
--> pppd: �[7f]
--> pppd: �[7f]
--> pppd: �[7f]
--> pppd: �[7f]
--> pppd: �[7f]
--> local  IP address 10.211.142.198
--> pppd: �[7f]
--> remote IP address 10.64.64.64
--> pppd: �[7f]
--> primary   DNS address 169.254.0.53
--> pppd: �[7f]

ifconfigを見るとppp0が追加されている

$ ifconfig
ppp0      Link encap:Point-to-Point Protocol
          inet addr:10.211.142.198  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:124 (124.0 B)  TX bytes:169 (169.0 B)

ppp0をデフォルトに設定

$ route add default dev ppp0

コンソールを別に立ち上げ、tracerouteで動作確認

$ traceroute google.com
traceroute to google.com (216.58.220.174), 30 hops max, 60 byte packets
 1  ec2-175-41-192-134.ap-northeast-1.compute.amazonaws.com (175.41.192.134)  116.654 ms ec2-175-41-192-128.ap-northeast-1.compute.amazonaws.com (175.41.192.128)  126.426 ms ec2-175-41-192-132.ap-northeast-1.compute.amazonaws.com (175.41.192.132)  127.928 ms
 2  27.0.0.172 (27.0.0.172)  137.003 ms 27.0.0.154 (27.0.0.154)  146.751 ms 27.0.0.172 (27.0.0.172)  166.521 ms
 3  27.0.0.154 (27.0.0.154)  156.830 ms 27.0.0.136 (27.0.0.136)  167.794 ms  176.028 ms
 4  15169.tyo.equinix.com (203.190.230.31)  186.205 ms 27.0.0.136 (27.0.0.136)  196.077 ms 15169.tyo.equinix.com (203.190.230.31)  206.633 ms
 5  72.14.239.202 (72.14.239.202)  216.972 ms  218.396 ms  226.533 ms
 6  72.14.239.202 (72.14.239.202)  236.539 ms 72.14.237.227 (72.14.237.227)  109.254 ms 72.14.239.202 (72.14.239.202)  240.481 ms
 7  72.14.237.227 (72.14.237.227)  241.910 ms nrt13s35-in-f14.1e100.net (216.58.220.174)  241.883 ms  241.874 ms

参考

先人の記録なしには到達できませんでした。ありがとうございました!
http://qiita.com/osada9000/items/012962f6ed92b501bed5
http://qiita.com/dietposter/items/bf3b0311a044eaf36df8
https://gist.github.com/j3tm0t0/65367f971c3d770557f3
http://fagoken.hatenablog.com/entry/2015/10/04/211145

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10