7
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

何でもOKなカレンダーAdvent Calendar 2020

Day 13

NervesをWiFiを使って固定IPでネットワークに追加します(Elixir)

Last updated at Posted at 2020-12-30

はじめに

config/target.exs
config :vintage_net,
  regulatory_domain: "US",
  config: [
    {"usb0", %{type: VintageNetDirect}},
    {"eth0",
     %{
       type: VintageNetEthernet,
       ipv4: %{method: :dhcp}
     }},
    {"wlan0",
     %{
       type: VintageNetWiFi,
       vintage_net_wifi: %{
         networks: [
           %{
             key_mgmt: :wpa_psk,
             ssid: System.get_env("NERVES_NETWORK_SSID"),
             psk: System.get_env("NERVES_NETWORK_PSK")
           }
         ]
       },
       ipv4: %{
         method: :static,
         address: "192.168.1.200",
         prefix_length: 24,
         gateway: "192.168.1.1",
         name_servers: ["8.8.8.8", "8.8.4.4"]
       }
     }}
  ]
  • (ノート) 192.168.1.200 は、あくまでも例です。ご自身のネットワーク設定やすでに割り当て済みのものとはかぶらないように設定してください。
  • prefix_lengthgatewayname_serversの値もあくまでも例です。

memo

  • mix uploadしたときに**ヤバい、こわしたか:interrobang:**と焦ったことがあったので書いておきます
  • もともとはipv4: %{method: :dhcp}に設定したファームウェアで動かしていました
  • そこに固定IP address: "192.168.1.200" の変更を加えて、mix firmware && mix uploadしました
$ mix upload
...

fwup: Upgrading partition B
100% [====================================] 50.38 MB in / 57.66 MB outReceived disconnect from 192.168.1.12 port 22:11: Terminated (shutdown) by supervisor
Disconnected from 192.168.1.12 port 22
** (Mix) ssh failed with status 255
  • ** (Mix) ssh failed with status 255はIPが変わって、単にssh接続がきれただけでした
$ ssh 192.168.1.200

iex> ping "nerves-project.org"
Press enter to stop
Response from nerves-project.org (185.199.108.153): time=58.574ms
Response from nerves-project.org (185.199.108.153): time=61.568ms
Response from nerves-project.org (185.199.108.153): time=56.253ms
Response from nerves-project.org (185.199.108.153): time=45.763ms
  • sshできるし、ちゃんと外にもつながる :bangbang::bangbang::bangbang:

Wrapping Up :christmas_tree::santa::santa_tone1::santa_tone2::santa_tone3::santa_tone4::santa_tone5::christmas_tree:

https___qiita-user-contents.imgix.net_https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F240349%2F5ef22bb9-f357-778c-1bff-b018cce54948.png_ixlib=rb-1.2.png

7
1
3

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?