Ubuntu Netplan network config ethernet wireless wlan

General

  • vi /etc/netplan/01-netcfg.yaml
  • netplan apply

Ethernet static

Example:

  • cat /usr/share/doc/netplan.io/examples/static.yaml
    • network:
        version: 2
        renderer: networkd
        ethernets:
          enp3s0:
            addresses:
              - 10.10.10.2/24
            gateway4: 10.10.10.1
            nameservers:
                search: [mydomain,otherdomain]
                addresses: [10.10.10.1, 1.1.1.1]

Wireless

Required packages

  • apt install wireless-tools wpasupplicant

General Info

  • iwconfig
  • iwlist wlp5s0 scan

Example config from package:

  • cat /usr/share/doc/netplan.io/examples/wireless.yaml
    • network:
        version: 2
        renderer: networkd
        wifis:
          wlp2s0b1:
            dhcp4: no
            dhcp6: no
            addresses: [192.168.0.21/24]
            gateway4: 192.168.0.1
            nameservers:
              addresses: [192.168.0.1, 8.8.8.8]
            access-points:
              "network_ssid_name":
                password: "**********"

Configure Wireless with DHCP

  • iwconfig -> get device name e.g. "wlp5s0"
  • vi /etc/netplan/01-netcfg.yaml
    • network:
        version: 2
        renderer: networkd
        ethernets:
          enp6s0:
            dhcp4: yes
        wifis:
          wlp5s0:
            dhcp4: yes
            access-points:
              "network_ssid_name":
                password: "**********"
      
  • netplan --debug generate

  • netplan apply
  • networkctl status enp6s0
    • -> when changing from dhcp to a static ip, the dhcp ip is not removed.
      Any other way than a reboot to fix this?
  • ifconfig
  • dmesg