USB tethering with a MacBook Pro

When I connect my L5 with my MacBook with an USB-C cable, an interface in the MacBook appears:

en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=400<CHANNEL_IO>
        ether ea:ea:96:be:0f:49
        inet6 fe80::8:ff4c:5e4c:6494%en7 prefixlen 64 secured scopeid 0x15
        inet 169.254.151.4 netmask 0xffff0000 broadcast 169.254.255.255
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect (2500Base-T <full-duplex>)
        status: active

and is also visible a “Librem 5”. But, in the L5 nothing happens with the usb0 interface. What do I miss here?

update I can set manually in the L5 ifconfig usb0 169.254.151.5 and can ssh into the L5.

1 Like

What operating system is running on the Mac?

It looks like nothing is configured to assign IP addresses on that link. 169.254.x.y is the IPv4 autoconfiguration IP address range, which may be good enough.

Just FYI, IP addresses in the range 169.254.0.0 - 169.254.255.255 are APIPA (automatic private ip adressing) addresses. An interface configured to use DHCP to get an IP-address gets automatically an IP-address in this range if no DHCP server is currently present.
If you manually change an IP-address, you should use one of another range (e.g. 192.168.x.x.). However, that is not really harmful, just take it as an convention. :slight_smile:

… which is usually quite slow because it requires timing out all the attempts to contact a DHCP server.

And, yeah, could cause problems if you have more than one interface where DHCP failed.

On the other hand, a static IP address is not great if you intend to connect the Librem 5 to other hosts at other times. You want DHCP - and you want it to work.

The Mac is running macOS 12.6 and the network configuration screen for this link is attached below. I do not understand why the Mac has an IP addr 169.254.151.4, but nothing happens on the L5. As I said, when I do set an addr 169.254.151.5 in the L5 with ifconfig, all is fine and I can ssh into the L5. This is what I wanted, because at work my L5 and my laptop are not on the same Wifi AP (guess why :slight_smile:), but from time to time I need files from the L5 or put files to it. So, I could live with that even.

There may be a deficit of macOS expertise in this forum. Certainly I’m out.

… because a static IP address was not set and because use of DHCP did not work.

Who can say? Maybe autoconfiguration is disabled (it was always a bit sucky). Maybe it is still timing out. Would require more investigation.

I am unfamiliar with how the Librem 5 / PureOS on Librem 5 is configured in the default factory settings. But I guess the USB ethernet is another interface which has nothing to do with the usual WIFI interface. It’s possible to give a static IP to the Ethernet over USB interface while keeping DHCP on the WIFI interface.

In order to get a private IP address on the Macbook the Librem 5 would have to be configured to act as a DHCP server for connections over USB.

… or the Mac is configured to act as a DHCP server. That is better because you really want the Librem 5 to be a DHCP client (on all interfaces) and just take a suitable IP address from whatever it is connected to.

I’m not sure about that. I understand your idea but you would have to configure each and every client you connect the Librem 5 to… Not to think about installing DHCP servers on all of them.

What do you expect to happen?

It’s just an Ethernet interface. If you want one side to configure its IP automatically based on the other side, you need to run a DHCP server on the other side. On the Librem 5 side you can do it by choosing a profile with “Shared Ethernet” IPv4 option set in NetworkManager. On the macOS side - you’re on your own.

For MacOS, “Shared Ethernet” equivalent functionality is a standard feature of the OS and is available by enabling “Internet Sharing” from the “Sharing” settings, then check select the Librem 5 interface from the list to enable connection sharing on that interface.

1 Like

I will try to setup a DHCP server on the Mac (already with the motivation to learn something).

Is it safe to assume that when the DHCP server is running on the interface of the USB-C port (which seems to be en7:) that on plug-in of the USB-C something in the L5 is running

dhclient usb0?

I setup the DHCP server on the Mac as described here: https://www.swissns.ch/site/2014/05/running-mac-os-xs-built-in-dhcp-server/
rebooted the L5 and it got assigned 192.168.33.2 in the usb0 interface. The wlan0 and wwan0 interface stay as they have been, i.e. the L5 accesses Internet through wlan0.

1 Like

Btw: The Mac is able to charge the L5 through USB-C

1 Like

In the Linux world, dnsmasq has a DHCP server built-in - so as long as you are using dnsmasq for DNS, you may be set already. (However that is complicated. In Ubuntu, which I mostly run, it used to use dnsmasq for DNS out-of-the-box but no longer does so, using systemd-resolved instead. So your mileage may vary. :wink:)

Yes, DHCP on the Librem 5 may work - but with the device at each end both having multiple interfaces the potential exists for clashing private addressing (regardless of which end runs DHCP). Maybe the smarts are there to avoid that problem??