0

I Ubuntu 20.04 Desktop OS running on Raspberry Pi 4. I have connected a printer to the Pi's ethernet port, and I have troubles in assigning a static IP using netplan. The problem is I cannot find the name of the interface card. Right now I have created a static IP using Network Manager and with the below command I can see that it is on eth0 with IP 192.168.123.101. The problem is I can't find the interface card name.

hd2900@hd2900:~$ ip add show
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,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether e4:5f:01:49:85:7f brd ff:ff:ff:ff:ff:ff
    inet 192.168.123.101/24 brd 192.168.123.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether e4:5f:01:49:85:80 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.94/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0
       valid_lft 50472sec preferred_lft 50472sec
    inet6 fe80::5d0a:3259:a2fc:a0d4/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

In /etc/netplan/0-rpi-ethernet-eth0.yaml I have this content, and I suspect that driver bcmgenet smsc95xx and lan78xx is causing the problem.

hd2900@hd2900:/etc/netplan$ cat 10-rpi-ethernet-eth0.yaml 
    network:
      ethernets:
        eth0:
          # Rename the built-in ethernet device to "eth0"
          match:
            driver: bcmgenet smsc95xx lan78xx
          set-name: eth0
          dhcp4: true
          optional: true

To set up a static IP address I need to edit /etc/netplan/01-network-manager-all.yaml and I need to know the name of the network interface card.

hd2900@hd2900:/etc/netplan$ cat 01-network-manager-all.yaml 
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager 

As suggesteed by Simon Banks, I changed my file as below. However, I need to add a wifi connection.

network:
  version: 2
  renderer: networkd
  ethernets:
      eth0:
          dhcp4: false
          addresses: [192.168.123.101/24]
          gateway4: 192.168.123.1
          match:
              driver: bcmgenet smsc95xx lan78xx
          set-name: eth0

In order to add a wifi will below addition to the code work?

network:
  version: 2
  renderer: networkd
  ethernets:
      eth0:
          dhcp4: false
          addresses: [192.168.123.101/24]
          gateway4: 192.168.123.1
          match:
              driver: bcmgenet smsc95xx lan78xx
          set-name: eth0
  wifis:
      wlan0:
          dhcp4: true
          access-points: "SSID NAME"
          password: "password"
          

According to the suggests by Simon, I have changed the file /etc/netplan/01-network-manager-all.yaml to

cat /etc/netplan/01-network-manager-all.yaml

Let NetworkManager manage all devices on this system

network: version: 2 renderer: networkd ethernets: eth0: dhcp4: false addresses: [192.168.123.101/24] gateway4: 192.168.123.1 match: driver: bcmgenet smsc95xx lan78xx set-name: eth0 version: 2 wifis: wlan0: dhcp4: yes optional: true access-points: "HiddenDimsum2900_24Ghz": password: "mysecretPassword"

Hereafter I did sudo netplan --debug apply and got this output

sudo netplan --debug apply
** (generate:161651): DEBUG: 20:57:29.401: Processing input file /etc/netplan/01-network-manager-all.yaml..
** (generate:161651): DEBUG: 20:57:29.402: starting new processing pass

** (generate:161651): WARNING **: 20:57:29.402: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.
** (generate:161651): DEBUG: 20:57:29.402: wlan0: adding wifi AP 'HiddenDimsum2900_24Ghz'
** (generate:161651): DEBUG: 20:57:29.402: Processing input file /etc/netplan/10-rpi-ethernet-eth0.yaml..
** (generate:161651): DEBUG: 20:57:29.403: starting new processing pass
** (generate:161651): DEBUG: 20:57:29.403: We have some netdefs, pass them through a final round of validation
** (generate:161651): DEBUG: 20:57:29.403: wlan0: setting default backend to 1
** (generate:161651): DEBUG: 20:57:29.403: Configuration is valid
** (generate:161651): DEBUG: 20:57:29.403: eth0: setting default backend to 1
** (generate:161651): DEBUG: 20:57:29.403: Configuration is valid
** (generate:161651): DEBUG: 20:57:29.405: Generating output files..
** (generate:161651): DEBUG: 20:57:29.405: openvswitch: definition eth0 is not for us (backend 1)
** (generate:161651): DEBUG: 20:57:29.405: NetworkManager: definition eth0 is not for us (backend 1)
** (generate:161651): DEBUG: 20:57:29.405: Creating wpa_supplicant config
** (generate:161651): DEBUG: 20:57:29.406: wlan0: Creating wpa_supplicant configuration file run/netplan/wpa-wlan0.conf
** (generate:161651): DEBUG: 20:57:29.406: Creating wpa_supplicant unit /run/systemd/system/netplan-wpa-wlan0.service
** (generate:161651): DEBUG: 20:57:29.421: Creating wpa_supplicant service enablement link /run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wlan0.service
** (generate:161651): DEBUG: 20:57:29.421: openvswitch: definition wlan0 is not for us (backend 1)
** (generate:161651): DEBUG: 20:57:29.421: NetworkManager: definition wlan0 is not for us (backend 1)
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:eth0 not found in {}
DEBUG:wlan0 not found in {}
DEBUG:eth0 exists in {'eth0': {'dhcp4': False, 'addresses': ['192.168.123.101/24'], 'gateway4': '192.168.123.1', 'match': {'driver': 'bcmgenet smsc95xx lan78xx'}, 'set-name': 'eth0'}}
DEBUG:Merged config:
network:
  ethernets:
    eth0:
      addresses:
      - 192.168.123.101/24
      dhcp4: true
      gateway4: 192.168.123.1
      match:
        driver: bcmgenet smsc95xx lan78xx
      optional: true
      set-name: eth0
  renderer: networkd
  version: 2
  wifis:
    wlan0:
      access-points:
        HiddenDimsum2900_24Ghz:
          password: mySecretPassword
      dhcp4: true
      optional: true

DEBUG:netplan generated NM configuration changed, restarting NM
DEBUG:eth0 not found in {}
DEBUG:wlan0 not found in {}
DEBUG:eth0 exists in {'eth0': {'dhcp4': False, 'addresses': ['192.168.123.101/24'], 'gateway4': '192.168.123.1', 'match': {'driver': 'bcmgenet smsc95xx lan78xx'}, 'set-name': 'eth0'}}
DEBUG:Merged config:
network:
  ethernets:
    eth0:
      addresses:
      - 192.168.123.101/24
      dhcp4: true
      gateway4: 192.168.123.1
      match:
        driver: bcmgenet smsc95xx lan78xx
      optional: true
      set-name: eth0
  renderer: networkd
  version: 2
  wifis:
    wlan0:
      access-points:
        HiddenDimsum2900_24Ghz:
          password: mysecretPassword
      dhcp4: true
      optional: true

INFO:[]
WARNING:Cannot find unique matching interface for eth0: {'driver': 'bcmgenet smsc95xx lan78xx'}
DEBUG:Link changes: {}
DEBUG:netplan triggering .link rules for lo

From the output above I am wondering if the issue that I cannot connect to wlan0 is because wlan0 is not found in the first place?

When I do ip addr I got below output

ip addr
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,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether e4:5f:01:49:85:7f brd ff:ff:ff:ff:ff:ff
    inet 192.168.123.101/24 brd 192.168.123.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether e4:5f:01:49:85:80 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.94/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0
       valid_lft 51306sec preferred_lft 51306sec
    inet6 fe80::5d0a:3259:a2fc:a0d4/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

iwconfig yields this output

lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11  ESSID:"HiddenDimsum2900_24Ghz"  
          Mode:Managed  Frequency:2.462 GHz  Access Point: 90:F8:91:3F:5F:5F   
          Bit Rate=72.2 Mb/s   Tx-Power=31 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=64/70  Signal level=-46 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:93  Invalid misc:0   Missed beacon:0
2
  • I think you are going about it the wrong way. You should set a static IP address for the printer (in the printer), not in Raspberry Pi. See this answer for a brief how to. The linked answer is for a laptop, but it should work for a Pi as well.
    – user68186
    Jan 29, 2022 at 18:07
  • The printer part works fine now. It is the wifis part that does not work.
    – jxw
    Jan 29, 2022 at 18:30

1 Answer 1

0

I use netplan on my raspberry pi's via ubuntu and RPI OS.. Here is a direct cut and paste from my home servers netplan for its static configuration.. So just change the IP/Subnets to match your loca. Netplan does moan about not being able to match the drivers but it does seem to work so don't worry about them.

In order for this to work and not conflict with the broadband routers DHCP assignmentsI've configured it to not use the range 192.168.0.32-192.168.0.253 for DHCP.

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            dhcp4: false
            addresses: [192.168.0.10/24]
            gateway4: 192.168.0.254
            nameservers:
                addresses: [192.168.0.254]
            match:
                driver: bcmgenet smsc95xx lan78xx
            set-name: eth0
        wlan1:
            match:
                name: wlx0013eff402eb
            set-name: wlan1
    wifis:
        wlan0:
            dhcp4: yes
            optional: true
            access-points:
                RedactedEESID:
                    band: 5GHz
                    password: "REDACTED PASSWORD"
15
  • Thanks Simon. I tested it today and it works! Can you add to the script if I also want to connect to wifi using my wlan0? Basically there I need to connect to my router with ssid, password and dhcp4 is set to true. Should I add that under the ethernets section?
    – jxw
    Jan 28, 2022 at 13:12
  • Yes instead of ethernets: section you have a wifi: section.. dev.to/raine/… Jan 31, 2022 at 14:00
  • I tried to mofidy the /etc/netplan/01-network-manager-all.yaml - see the edited post. I still can't connect to router and I think the problem is with the dhcp4 which is deprecated. I am not sure how to get around this?
    – jxw
    Jan 31, 2022 at 22:25
  • dhcp4 and dhcp6 default to false and are not deprecated.. IMHO Its unlikey your router only supports dhcp6 as that would cause untold compatibility issues. Most likely you there is a typo / spelling mistake in the pass-phrase or ESSID you've configured. Had the same a couple of weeks ago and after a couple of hours I discovered it was the ESSID. when you run netplan --debug apply what is output? Feb 1, 2022 at 8:26
  • I've updated my the netplan example with a full example from my RPI4 home server. Which acts has 1GB ethernet, 5GHZ Wifi and also uses wlan1 via wifi-ap as its own access point. Feb 1, 2022 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .