We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

How to fix random MAC addresses at USB?

asked 2019-09-27 21:21:06 +0200

iourine gravatar image

updated 2019-09-28 12:29:38 +0200

Nearly (!) every time when I connect my Jolla to the PC over USB (in tethering mode), it generates new MAC addresses for both sides. SFOS 3.1.0.11. More specifically, journalctl says that

  • Sailfish kernel provides a random MAC address;

  • Sailfish kernel provides the Host MAC address specified in /etc/modprobe.d/g_ether.conf .

The provided MAC address is the one finally assigned to rndis0. The provided Host MAC address has no effect and appears to be replaced by another random address which finally appears on the PC interface. The consequences are:

  • At the host, the existing record for Jolla connection is no longer used, and a new one is created.

  • iptables rules appear not to work, despite being present. In particular, DHCP traffic is dropped, thus I have to set the IP address manually at the PC.

  • Also due to iptables, tethering over USB does not work until the masquerading rule is re-created manually.

Thus,

  1. Why does it happen? (And does NOT in some cases; e.g. it seems not to happen if Jolla is rebooted while staying connected to the PC, and also in some other cases that I haven't figured yet.)
  2. What are the reasons for using such behavior rather than permanent addresses?
  3. How to fix the address and make iptables working again?
edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
2

answered 2020-03-09 00:59:56 +0200

Alfonso gravatar image

Jolla 1 and Xperia X: I just added a fixed MAC address in the /etc/modprobe.d/g_ether.conf - for example:

options g_ether mac_addr=50:56:a8:44:44:44

And it was enough to see an enx5056a8444444 showing up in the list of the network interfaces on my Ubuntu PC when I plugged in the USB cable.

Xperia XA2: that trick doesn't work anymore; apparently it shows up as an USB device 0fce:0a02, thus in my Ubuntu PC I created a file /etc/udev/rules.d/55-xperia-xa2.rules containing an USB rule to use a fixed interface name ethxa2 whenever that USB device offers a network interface and without regard for the random MAC shown by the XA2:

SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="0a02", NAME="ethxa2"

After reloading the udev rules (udevadm control --reload) on my Ubuntu PC, and then plugging in the USB-C cable of the Xperia XA2, I was able to configure the NetworkManager to use that interface name (ethxa2) instead of a MAC address.

edit flag offensive delete publish link more

Comments

I've been using the udev way on my laptop since the original Jolla 1 and can confirm I never had any problem all the way to my Xperia XA2.

DrYak ( 2020-03-09 11:25:13 +0200 )edit
Login/Signup to Answer

Question tools

Follow
4 followers

Stats

Asked: 2019-09-27 21:21:06 +0200

Seen: 903 times

Last updated: Mar 09 '20