Custom startup script to set interface link speed?

Started by patrick3000, February 02, 2024, 07:53:50 AM

Previous topic - Next topic
My WAN interface is connected to a cable modem but, for some reason, does not automatically negotiate to 2.5 gbps, the max speed of the modem, even though it's on an X550-T2 adapter that supports this speed.

I have figured out how to get it to connect at 2.5 gbps by changing a setting at the command shell using the command "ifconfig [interface name] media 2500Base-T."

Unfortunately, however, this does not persist after reboot.

So, does anyone know a way to create a script in the OPNsense UI to run this command automatically at startup? I'd rather not manually edit configuration files, such as cron, in FreeBSD because I'm afraid I could mess something up and also because it might break with updates.

I'm not sure if there is a way to do this, but I thought I'd check.

If you have a managed 2.5Gbps switch with two free ports, I would set an (untagged) VLAN for your WAN connection. It sounds like the modem is not very good at speed negotiation.

That is after you've ruled out your cable, of course.

Bart...

February 02, 2024, 08:21:18 AM #2 Last Edit: February 02, 2024, 08:46:57 AM by patrick3000
Quote from: bartjsmit on February 02, 2024, 08:09:55 AM
If you have a managed 2.5Gbps switch with two free ports, I would set an (untagged) VLAN for your WAN connection. It sounds like the modem is not very good at speed negotiation.

That is after you've ruled out your cable, of course.

Bart...

It's not the modem that's the problem. It's the on-board X550-T2 adapter that does not automatically negotiate to 2.5gbps. I know this because it didn't do so even when I had Linux, rather than OPNsense/FreeBSD, installed. With Linux, I had to manually set the speed to 2.5gbps using the ethtool command. Now that I've got OPNsense/Freebsd installed, I have to manually set it using the ifconfig command.

The ultimate problem is that the X550-T2 chipset, while stable, does not always advertise at multigig speeds, meaning 2.5gbps and 5gbps. It tends to advertise only at 10gbps, 1gbps, and 100mbps. There have been other posts about this.

In any event, I do not have a switch with 2.5gbps ports. My switch has only 10gbps SFP+ ports and 1 gbps base-T ports. I already run WAN2, which connects at 1gbps, through the switch on a VLAN, but since WAN connects at 2.5gbps, I cannot run it through the switch.

Unless someone knows of a way to easily set up a startup script, it seems like I'll need to manually run the command to force 2.5gbps after each reboot, which isn't necessarily the end of the world since I don't reboot often, but it's still a bit of a hassle.

Isn't this possible in the media settings of the interface?


Cheers,
Franco

Quote from: franco on February 02, 2024, 09:15:40 AM
Isn't this possible in the media settings of the interface?


Cheers,
Franco

How can the media settings for the interface be changed in the web UI? I have not found a way to do so. It would be great if there were a way. Perhaps I missed it?

I can force it to negotiate to 2.5gbps by changing the media settings at the command shell, but this does not persist after reboot.

You need to assign the parent of the VLAN in order to adjust its media settings.


Cheers,
Franco

Quote from: franco on February 02, 2024, 05:27:12 PM
You need to assign the parent of the VLAN in order to adjust its media settings.


Cheers,
Franco

No VLANs are involved. The interface, which is in this case is called "ix0," is a standard physical interface, specifically an on-board 10GB Base-T ethernet adapter with the X550-T2 chipset. It doesn't have any VLANs on it and connects directly to a cable modem that gets internet from an ISP.

It's looking to me as though there may not be a way to do this--i.e. to force negotiation to 2.5 gbps--either in the web UI or in a startup script. As noted, I can force it from the command shell with "ifconfig [interface name] media 2500Base-T." That works until reboot, and it looks like I'll just have to run it manually after each reboot. Since I generally only reboot once a month or so when I install updates, it's only a minor inconvenience to do it manually.

I'm guessing that the modem does not do autonegotiation very well https://en.wikipedia.org/wiki/Autonegotiation

You may need to hang a scope on a breakout of the wires to be sure, but as you said - diminishing returns if you only bounce the firewall once a month.

February 03, 2024, 05:24:04 PM #8 Last Edit: February 03, 2024, 05:31:37 PM by patrick3000
Quote from: bartjsmit on February 03, 2024, 08:57:43 AM
I'm guessing that the modem does not do autonegotiation very well https://en.wikipedia.org/wiki/Autonegotiation

You may need to hang a scope on a breakout of the wires to be sure, but as you said - diminishing returns if you only bounce the firewall once a month.

Thanks. However, it's not the modem. It's the on-board X550-T2 adapter. Back when I had Linux installed on this server and was able to run ethtool, it showed that the adapter does not by default advertise at all supported speeds. It only advertises at 10 gbps, 1 gbps, and 100 mbps. Although it supports 5 gbps and 2.5 gbps, it does not advertise at those speeds, so it cannot negotiate to them by default. Under Linux, I had to use an ethtool command to force the adapter to advertise at 5 and 2.5 gbps, which allowed it to negotiate to those speeds.

Under OPNsense/Freebsd, there is no ethtool command, but ifconfig does something similar and has allowed me to force the adapter to advertise and negotiate to 2.5 gbps from the command shell.

I don't know if it's only the implementation of the X550-T2 chipset on my motherboard (an ASRock Rack X570d4u-2L2T) or whether it's the X550-T2 chipset more generally that does not, by default, advertise at 2.5 and 5 gbps, but others have posted about this problem with X550-T2 adapters.

February 03, 2024, 05:28:51 PM #9 Last Edit: February 03, 2024, 05:30:45 PM by patrick3000
For the record, here is a post from someone last year about this same problem with X550-T2 adapters not by default negotiating to 2.5 gbps: https://forum.opnsense.org/index.php?topic=33154.0.

Reading through the post from last year, it's my understanding that this was not solved there. As noted, I have solved it from the command shell with the command "ifconfig [interface name] media 2500Base-T," although this does not persist after reboot.

Hey, I'm not sure if you solved this, but it seems as of the latest version of OPNSense (24.1.4) you're able to manually set the speed to any of the available options on the interface itself.  If you got to the interface (Interfaces>WAN in my case) near the bottom of the second section is the option 'Speed and Duplex'.  All 5 options for the X550 are available for me (100, 1000, 2500, 5000, and 10G).  Once I set it to 2500 and saved everything, the interface was reporting at 2500.  Hope this helps!

November 02, 2024, 03:19:13 AM #11 Last Edit: November 02, 2024, 06:52:42 AM by patrick3000
Mr.Moo52 I just found your response to my old thread. That's brilliant. It finally solves the problem of me having to manually set the link speed every time I reboot OPNsense. As you note, the link speed can be set under Interfaces, WAN, Generic Configuration, Speed and Duplex.

Hi there, I'm having the same issue.  My OpenReach ONT has a 2.5G port, as my WAN speed in 1.6gbps, but the X550-T2 is negotatiating on 1000base-T like you mentioned.  However I don't have the speed and duplex options in my WAN configuration page.  It's a PPOE type so not sure that majes a difference.  In fact, none of the VLAN, LAN etc have these options.

Running Opnsense 24.7.10_2

Any help appreciated so I can get the full speed on this line.

Only the physical interface will have the media options. So, if you have PPPoE on a pyhsical interface, you will have to assign that pyhsical interface and select speed there. Likewise is you have PPPoE->VLAN->physical interface.
Intel N100, 4 x I226-V, 16 GByte, 256 GByte NVME, ZTE F6005

1100 down / 800 up, Bufferbloat A+

Hey thanks for the response. So I have the PPOE interface assigned to the wan which doesn't have Speed or Duplex either. What do you mean assign the physical interface? Isn't the ix0 assigned to PPOE?