3

I have a computer that is connected to the router with DHCP and is in fully working order, what I am having issues with adding raspberry pi zero's in link-only mode. First I can get the pi's to connect by just editing the connection from DHCP to link-only but then I obviously lose internet as I can only have one wired device connected at a time and they aren't DHCP like my main ethernet connection. I then though it would be a simple job of adding a new connection with link-only set that I could use to connect the pi's while leaving my internet intact, this is where the issue started I was able to make the connection but for some reason unable to get it to assign itself to the pi, I get two different messages one is activation of network connection failed and the other is Unable to find a connection with UUID ('null').

I searched the internet and didn't find much as sugested in one of the posts I ran nmcli c show which returns a list of connections and here new connection all seem to have a UUID. I am stuck with this issue and would appreciate any help.

  • Do these raspberry pi zeros have a USB to Ethernet adapter, a USB Wifi adapter, or are they "pi zero Wifis" ? Do you mean link-local, IP 169.254.0.0 network? Are you trying to avoid having the Pi units connect to the Internet, but still be connected to the LAN? Why can you only have one wired connection? – RubberStamp Oct 31 '17 at 17:43
  • They are using the OTG so they are connected to the computer with USB but show up as ethernet devices, I was following a guide online that says because of the way OTG mode works you need to set it as link-local. I am not trying to stop them from connecting to the internet if fact I would like them connected to the internet. I mean when I have the pi connected that I can only have one interface connected to the connection so it's either the pi or my ethernet and creating the new connection creates the errors I listed above. Hope this helps – bobthemac Oct 31 '17 at 19:23
  • Heres a link to the guide that talks about setting up OTG dev.webonomic.nl/… – bobthemac Oct 31 '17 at 19:26
  • You'll need to setup a network bridge... something like this: Network Manager Bridge – RubberStamp Oct 31 '17 at 20:48
  • The instructions you provided include the step which provides the network bridge: "...change the method to 'Shared to other computers'... " I have a few Pi Zeros. I'll set it up and post a complete answer tomorrow, if it still doesn't work for you by then... Today is Halloween! – RubberStamp Oct 31 '17 at 21:20
5

How to setup Networking via Network Manager's nmcli for a Raspberry Pi connected to a host PC via the USB port running in OTG mode.

I successfully setup a bridged network to a Raspberry Pi Zero using Network Manager via the nmcli commandline interface.

Raspberry Pi Setup

I followed these instructions listed in the comments above to setup the Pi for OTG Ethernet connection.

Modify the Pi's MiniSD card's filesystem

Add the following to the SD card's /boot/config.txt

# Enable USB OTG like ethernet
dtoverlay=dwc2

Create an empty file called ssh in the SD card's /boot directory

touch ssh

And append the OTG ethernet module onto the boot loader via adding the following to the SD card's /boot/cmdline.txt after rootwait

` modules-load=dwc2,g_ether `

Setup Host PC Network Bridge

Then I setup a bridge network interface on my PC's wired ethernet port.

nmcli con add type bridge ifname br0
nmcli con modify bridge-br0 bridge.stp no
nmcli con add type bridge-slave ifname eth1 master bridge-br0

Plugged in the Raspberry Pi Zero to the PC using the OTG port on the Pi. Checked the interface name using ifconfig. And then added the OTG interface to the network bridge.

nmcli con add type bridge-slave ifname enp0s29f7u1u4u3 master bridge-br0

With everything set, I enabled the connections:

nmcli con up bridge-br0
nmcli con up bridge-slave-eth1
nmcli con up bridge-slave-enp0s29f7u1u4u3

Verified all interfaces green with nmcli connection

root@local:/etc/ssh# nmcli con
NAME                          UUID                                  TYPE            DEVICE          
bridge-br0                    ab1fab48-2c31-4ccc-90bf-db444751c080  bridge          br0             
bridge-slave-enp0s29f7u1u4u3  5efed614-89c7-48d4-996e-0a2e6e616846  802-3-ethernet  enp0s29f7u1u4u3 
bridge-slave-eth1             53c4d66a-3f9e-49f4-b954-92b13ecf96f8  802-3-ethernet  eth1            

Watch DHCP server for Raspberry Pi Address

And then watched my DHCP server for the Raspberry Pi network address assignment. On your configuration, that information would be available via your router. SSH to Pi success:

SSH into Pi

root@local:/etc/ssh# ssh pi@192.168.xxx.xxx
pi@192.168.xxx.xxx's password: 

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Nov  1 19:33:48 2017 from 192.168.xxx.xxx
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.4.38+ #938 Thu Dec 15 15:17:54 GMT 2016 armv6l GNU/Linux
pi@raspberrypi:~ $ ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:724 errors:0 dropped:0 overruns:0 frame:0
          TX packets:724 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:58980 (57.5 KiB)  TX bytes:58980 (57.5 KiB)

usb0      Link encap:Ethernet  HWaddr 8e:31:5b:06:db:bb  
          inet addr:192.168.xxx.xxx  Bcast:192.168.xxx.xxx  Mask:255.255.255.0
          inet6 addr: fe80::xxx:/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:756 errors:0 dropped:0 overruns:0 frame:0
          TX packets:430 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:90941 (88.8 KiB)  TX bytes:76278 (74.4 KiB)

pi@raspberrypi:~ $ route
Kernel IP routing table
Destination     Gateway           Genmask         Flags Metric Ref    Use Iface
default         192.168.xxx.xxx   0.0.0.0         UG    202    0        0 usb0
192.168.xxx.0     *               255.255.255.0   U     202    0        0 usb0

pi@raspberrypi:~ $ sudo -s
root@raspberrypi:/home/pi# ping unix.stackexchange.com
PING unix.stackexchange.com (151.101.65.69) 56(84) bytes of data.
64 bytes from 151.101.65.69: icmp_seq=1 ttl=55 time=27.2 ms
64 bytes from 151.101.65.69: icmp_seq=2 ttl=55 time=7.91 ms
64 bytes from 151.101.65.69: icmp_seq=3 ttl=55 time=6.40 ms
64 bytes from 151.101.65.69: icmp_seq=4 ttl=55 time=6.78 ms
64 bytes from 151.101.65.69: icmp_seq=5 ttl=55 time=7.87 ms
^C
--- unix.stackexchange.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 6.404/11.240/27.219/8.012 ms
root@raspberrypi:/home/pi#

Addendum

After reading through Part 2 of the Pi OTG Networking instructions, I will add the component that they provide to permanently set the Pi's MAC address. With a permanent MAC address, your DHCP server and/or router will stop giving sequential IP addresses with every reboot of the RPi.

webonomic's says:

You do this by appendign(sic) this to cmdline.txt on the boot partition on your pi:

g_ether.host_addr=8a:3e:d4:ce:89:53

Just take the address form the ifconfig command of your laptop, after you have established a connection.

They go on to mention changing the Pi's configuration from DHCP to Static IP. However, I do not recommend doing it that way. I always recommend setting up static leases on your network's DHCP server. This way, only the DHCP server needs to be modified in order to redesign your network. There are also useful methods for dividing up subnets in order to limit access to certain hosts from others.

Most modern home routers allow setting up static leases. It's a good practice to utilize the full capabilities of your DHCP server.

Additional notes

I discovered that setting g_ether.host_addr is not enough to provide a constant MAC address for the Pi. There is a second requirement to set g_ether.dev_addr

The Gadget documentation recommends also setting a manufacturer as well a product number.

Linux-USB Gadget API Framework says:

To better support DHCP, ZCIP, and related network autoconfiguration, you'll want to manage Ethernet addresses so that each peripheral reuses the same unique address every time it boots. You should assign those addresses using a registered IEEE 802 company id; this will also make the device appear to Linux hosts as an "ethN" interface, not as "usbN". It's easy to do this without a separate ID PROM (or an initrd) if you're using boot firmware like U-Boot:

*#* manufacturing assigns Ethernet addresses; company id is xx:xx:xx
setenv eth_a_host    xx:xx:xx:01:23:45
setenv eth_a_gadget  xx:xx:xx:67:89:ac
setenv eth_i_vendor  "Great Stuff, LLC"
setenv eth_i_product "Our Cool Thing"
setenv eth_args             g_ether.host_addr=\$(eth_a_host)
setenv eth_args $(eth_args) g_ether.dev_addr=\$(eth_a_gadget)
setenv eth_args $(eth_args) g_ether.iManufacturer=\$(eth_i_vendor)
setenv eth_args $(eth_args) g_ether.iProduct=\$(eth_i_product)
*#* you can assign USB vendor/product/version codes too...
setenv add_eth_args setenv bootargs $(eth_args) \$(bootargs)
...
setenv bootcmd run add_eth_args\;bootm

These parameters can also be appended to the cmdline.txt for better usability with DHCP servers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.