Wi-Fi　raspberrypi ubuntu 固定ip備忘録

```
ozaki@raspberrypi:~$ ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether dc:a6:32:89:ff:c5 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether dc:a6:32:89:ff:c6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.141/24 metric 600 brd 192.168.2.255 scope global dynamic wlan0
       valid_lft 172373sec preferred_lft 172373sec
    inet6 2001:268:c145:965b:dea6:32ff:fe89:ffc6/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 288sec preferred_lft 288sec
    inet6 fe80::dea6:32ff:fe89:ffc6/64 scope link
       valid_lft forever preferred_lft forever



ozaki@raspberrypi:/etc/netplan$ sudo cat 50-cloud-init.yaml
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    wifis:
        renderer: networkd
        wlan0:
            access-points:
                elecom2g-df0113:
                    password: パスワード
            dhcp4: true
            optional: true



ozaki@raspberrypi:/etc/netplan$ sudo nano 54-cloud-init.yaml
  GNU nano 7.2                                                                                    54-cloud-init.yaml *                                                                                           # This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    wifis:
        renderer: networkd
        wlan0:
            access-points:
                elecom2g-df011:
                    password: パスワード
            dhcp4: false
            optional: true
            addresses: [192.168.2.154/24]
            nameservers:
                addresses: [192.168.2.1]

ozaki@raspberrypi:/etc/netplan$ sudo netplan apply
Cannot call Open vSwitch: ovsdb-server.service is not running.

sudo apt-get install openvswitch-switch

ozaki@raspberrypi:/etc/netplan$ sudo systemctl start openvswitch-switch
Failed to start openvswitch-switch.service: Unit openvswitch-switch.service not found.

ozaki@raspberrypi:/etc/netplan$ sudo rm 54-cloud-init.yaml

ozaki@raspberrypi:/etc/netplan$ sudo netplan apply
Cannot call Open vSwitch: ovsdb-server.service is not running.

sudo apt-get install openvswitch-switch
sudo systemctl start openvswitch-switch
ozaki@raspberrypi:/etc/netplan$ sudo netplan apply

ozaki@raspberrypi:/etc/netplan$ sudo cp 50-cloud-init.yaml 54-cloud-init.yaml
ozaki@raspberrypi:/etc/netplan$ sudo nano 54-cloud-init.yaml
  GNU nano 7.2                                                                                    54-cloud-init.yaml *                                                                                           # This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    wifis:
        renderer: networkd
        wlan0:
            access-points:
                elecom2g-df011:
                    password: パスワード
            dhcp4: false
            optional: true
            addresses: [192.168.2.154/24]
            nameservers:
                addresses: [192.168.2.1]

ozaki@raspberrypi:/etc/netplan$ sudo netplan apply

ozaki@raspberrypi:/etc/netplan$ ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether dc:a6:32:89:ff:c5 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether dc:a6:32:89:ff:c6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.154/24 brd 192.168.2.255 scope global wlan0
       valid_lft forever preferred_lft forever
    inet6 2001:268:c145:965b:dea6:32ff:fe89:ffc6/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 273sec preferred_lft 273sec
    inet6 fe80::dea6:32ff:fe89:ffc6/64 scope link
       valid_lft forever preferred_lft forever
```