LoginSignup
1
1

More than 5 years have passed since last update.

Raspberry Pi で、au w01をブリッジモードでつなぐ

Posted at

2017/12時点では、何もしなくても、つながった。

インターネット直収になるので、アタックを食らっても大丈夫なように、ポートやID/PWの管理は、しっかりしてください。

Raspberry PiのOS情報

$cat /proc/version
Linux version 4.9.35+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #1014 Fri Jun 30 14:34:49 BST 2017

手順

  • モバイルルータ側を、ブリッジモードにする (本体を操作して、変更します)
  • Raspberry PiのUSBへつなぐ
  • Raspberry Piを起動する

詳細

ブリッジモードにしたあと、USBへつなぎ、Piを起動すると、次のように認識されています。
(dmesgでも確認できます)

[    3.679070] usb 1-1.3: new high-speed USB device number 5 using dwc_otg
[    3.832788] usb 1-1.3: New USB device found, idVendor=12d1, idProduct=14db
[    3.846652] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    3.860871] usb 1-1.3: Product: HUAWEI_MOBILE
[    3.872043] usb 1-1.3: Manufacturer: HUAWEI_MOBILE

うちの環境では、eth1として認識されたので、/etc/network/interfacesへ、eth1の設定を追記します。

#eth0がオンボードLAN
auto eth0
iface eth0 inet dhcp

#eth1がw01
auto eth1
iface eth1 inet dhcp

w01(eth1)は、当たり前ですが、dhcp必須です。

$ ifconfig eth1
eth1      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
          inet addr:XX.XX.XX.XX  Bcast:XX.XX.XX.XX  Mask:255.255.255.255
          inet6 addr: XX::XX:XX:XX:XX/64 Scope:Link
          inet6 addr: XX:XX:XX:XX:XX:XX:XX:XX/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:34 errors:0 dropped:0 overruns:0 frame:0
          TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2133 (2.0 KiB)  TX bytes:9084 (8.8 KiB)
$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

このままだと、Default Routeが設定されなかったので、設定スクリプトをrc.localへ記述します。
rc.localのexit 0の前に書けばOK

/etc/rc.local
$ ifconfig eth1 | grep -o -e "addr:[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" |  grep -o -e "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" | xargs -I{} sh -c "route add -net default gw {}"
$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         KDXXYYZZXX      0.0.0.0         UG    0      0        0 eth1
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

これで、無事に、インターネットへ抜けます。

traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  * * *
 2  * * *
 3  172.25.18.1 (172.25.18.1)  210.480 ms  210.963 ms  210.826 ms
 4  tm4BBML63.bb.kddi.ne.jp (27.90.203.81)  209.096 ms  214.269 ms  214.207 ms
 5  tm4BBAC01.bb.kddi.ne.jp (182.248.164.93)  218.982 ms  218.599 ms  218.251 ms
 6  27.80.242.61 (27.80.242.61)  219.988 ms  35.428 ms  34.657 ms
 7  27.85.137.90 (27.85.137.90)  42.891 ms  42.498 ms  38.794 ms
 8  74.125.51.213 (74.125.51.213)  38.366 ms  38.004 ms  39.013 ms
 9  * * *
10  108.170.233.14 (108.170.233.14)  39.770 ms 72.14.233.220 (72.14.233.220)  39.928 ms 216.239.62.220 (216.239.62.220)  48.342 ms
11  209.85.143.77 (209.85.143.77)  37.364 ms 108.170.236.187 (108.170.236.187)  38.771 ms 72.14.238.37 (72.14.238.37)  40.489 ms
12  google-public-dns-a.google.com (8.8.8.8)  39.022 ms  38.296 ms  31.147 ms

おしまい

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