Bonding interface renamed after reboot

gozfly

Dabbler
Joined
Dec 24, 2023
Messages
10
Hello everyone,
We have been trying to understand for several days why our interface is renamed every time we restart the TrueNAS server, that causes us to lose connectivity to the server.

We have tried to execute this command but apparently it keeps renaming every time we restart.
midclt call system.advanced.update '{"kernel_extra_options": "bonding.max_bonds=0"}'

In the boot log we have this quite curious section.

[2023/12/24 13:16:58] (INFO) middlewared.setup():203 - Interface 'bond0' is now 'enp5s0f0' (matched by link address '00:0a:f7:xx:xx:xx')
[2023/12/24 13:16:58] (INFO) middlewared.rename():112 - Renaming interface 'bond0' to 'enp5s0f0'
[2023/12/24 13:16:58] (INFO) middlewared.commit():118 - Renaming hardware interface 'bond0' to 'enp5s0f0'
[2023/12/24 13:16:58] (INFO) middlewared.commit():125 - Renaming interface configuration 'bond0' to 'enp5s0f0'

Any help will be appreciated
 

jonboy345

Cadet
Joined
Nov 6, 2023
Messages
3
I'm having a similar issue I think.

I had had a LAGG named bond0, but now it's missing entirely, only NICs I have are the physical nics, and when I attempt to create a new bond0, I get a error:

(sqlite3.IntegrityError) UNIQUE constraint failed: network_lagginterfacemembers.lagg_physnic [SQL: INSERT INTO network_lagginterfacemembers (lagg_ordernum, lagg_physnic, lagg_interfacegroup_id) VALUES (?, ?, ?)] [parameters: (0, 'enp61s0f0', 15)]
 

gozfly

Dabbler
Joined
Dec 24, 2023
Messages
10
I'm having a similar issue I think.

I had had a LAGG named bond0, but now it's missing entirely, only NICs I have are the physical nics, and when I attempt to create a new bond0, I get a error:

(sqlite3.IntegrityError) UNIQUE constraint failed: network_lagginterfacemembers.lagg_physnic [SQL: INSERT INTO network_lagginterfacemembers (lagg_ordernum, lagg_physnic, lagg_interfacegroup_id) VALUES (?, ?, ?)] [parameters: (0, 'enp61s0f0', 15)]
I keep testing, and I think I'm about to identify what the real problem is. Does your network card by any chance have the same MAC address for both 10Gbps ports?
 

jonboy345

Cadet
Joined
Nov 6, 2023
Messages
3
They do not have the same mac address:
1703473075069.png
 

gozfly

Dabbler
Joined
Dec 24, 2023
Messages
10
@jonboy345
I have taken the time to investigate the source code of TrueNAS there is a python script that changes the MAC addresses of the interfaces and apparently it is a for loop that compares the physical and logical MAC addresses stored in the database, if any of them These MAC match then execute the function of renaming interfaces.

async def setup(middleware):
try:
interface_renamer = InterfaceRenamer(middleware)

if await middleware.call("failover.node") == "B":
link_address_key = "link_address_b"
else:
link_address_key = "link_address"

real_interfaces = RealInterfaceCollection(await middleware.call("interface.query", INTERFACE_FILTERS))

# Migrate BSD network interfaces to Linux
for db_interface in await middleware.call("datastore.query", "network.interfaces", [], {"prefix": "int_"}):
if m := RE_FREEBSD_BRIDGE.match(db_interface["interface"]):
interface_renamer.rename(db_interface["interface"], f"br{m.group(1)}")

if m := RE_FREEBSD_LAGG.match(db_interface["interface"]):
interface_renamer.rename(db_interface["interface"], f"bond{m.group(1)}")

db_interfaces = DatabaseInterfaceCollection(
await middleware.call("datastore.query", "network.interface_link_address"),
)
for db_interface in db_interfaces:
if db_interface[link_address_key] is not None:
real_interface_by_link_address = real_interfaces.by_link_address.get(db_interface[link_address_key])
if real_interface_by_link_address is None:
middleware.logger.warning(
"Interface with link address %r does not exist anymore (its name was %r)",
db_interface[link_address_key], db_interface["interface"],
)
continue

if real_interface_by_link_address["name"] == db_interface["interface"]:
continue

middleware.logger.info(
"Interface %r is now %r (matched by link address %r)",
db_interface["interface"], real_interface_by_link_address["name"], db_interface[link_address_key],
)
interface_renamer.rename(db_interface["interface"], real_interface_by_link_address["name"])

await interface_renamer.commit()
except Exception:
middleware.logger.error("Unhandled exception while migrating network interfaces", exc_info=True)

await middleware.call("interface.persist_link_addresses")

At the moment I have solved it by adding a Pre-Init script to change the MAC address of the bond0 interface to any other to avoid it coinciding with the physical interfaces and avoid renaming, and now with each reboot I do not lose the connection.

preinit.png


Additionally:
There is something in the UI that when you make a change to your network interfaces it reapplies the same MAC address to all three interfaces, this is a bug that will surely be fixed by the developers.
 

gozfly

Dabbler
Joined
Dec 24, 2023
Messages
10
I forgot to mention that you need to restore the default configuration settings, then apply the LACP configuration and then create the Pre-init for it to work.

If you try to just run the pre-init command it will not work since the interface was already renamed previously, and if you try to create bond0 again it will return an error UNIQUE constraint failed: network_lagginterfacemembers.lagg_physnic
To avoid this you have to restore the default settings.

Greetings
 

jonboy345

Cadet
Joined
Nov 6, 2023
Messages
3
I forgot to mention that you need to restore the default configuration settings, then apply the LACP configuration and then create the Pre-init for it to work.

If you try to just run the pre-init command it will not work since the interface was already renamed previously, and if you try to create bond0 again it will return an error UNIQUE constraint failed: network_lagginterfacemembers.lagg_physnic
To avoid this you have to restore the default settings.

Greetings
By default configuration, do you mean the network interface configuration or the entire TrueNAS install config?
 

gozfly

Dabbler
Joined
Dec 24, 2023
Messages
10
By default configuration, do you mean the network interface configuration or the entire TrueNAS install config?
Hello,
We were implementing a Fresh installation, so we had no problem resetting the entire TrueNAS configuration.

Due to this problem I have decided to wait for the team to provide some response to the problem by following up on the bug report in these two links


 
Top