OPNsense Forum

English Forums => General Discussion => Topic started by: patrick3000 on February 02, 2024, 07:53:50 AM

Title: Custom startup script to set interface link speed?
Post by: patrick3000 on February 02, 2024, 07:53:50 AM
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.
Title: Re: Custom startup script to set interface link speed?
Post by: 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...
Title: Re: Custom startup script to set interface link speed?
Post by: patrick3000 on February 02, 2024, 08:21:18 AM
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.
Title: Re: Custom startup script to set interface link speed?
Post by: franco on February 02, 2024, 09:15:40 AM
Isn't this possible in the media settings of the interface?


Cheers,
Franco
Title: Re: Custom startup script to set interface link speed?
Post by: patrick3000 on February 02, 2024, 05:24:04 PM
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.
Title: Re: Custom startup script to set interface link speed?
Post by: 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
Title: Re: Custom startup script to set interface link speed?
Post by: patrick3000 on February 02, 2024, 06:15:57 PM
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.
Title: Re: Custom startup script to set interface link speed?
Post by: 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.
Title: Re: Custom startup script to set interface link speed?
Post by: patrick3000 on February 03, 2024, 05:24:04 PM
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.
Title: Re: Custom startup script to set interface link speed?
Post by: patrick3000 on February 03, 2024, 05:28:51 PM
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.
Title: Re: Custom startup script to set interface link speed?
Post by: Mr.Moo52 on March 23, 2024, 10:41:46 PM
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!
Title: Re: Custom startup script to set interface link speed?
Post by: patrick3000 on November 02, 2024, 03:19:13 AM
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.
Title: Re: Custom startup script to set interface link speed?
Post by: maccipher256 on December 08, 2024, 11:04:58 PM
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.
Title: Re: Custom startup script to set interface link speed?
Post by: meyergru on December 09, 2024, 01:16:20 AM
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.
Title: Re: Custom startup script to set interface link speed?
Post by: maccipher256 on December 09, 2024, 03:14:24 PM
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?
Title: Re: Custom startup script to set interface link speed?
Post by: meyergru on December 09, 2024, 03:49:31 PM
You have to assign the underlying physical interface a name under "Interfaces: Assignments" in order to be able to manipulate it. Now it is just ix0, but inaccessible under "Interfaces".

Title: Re: Custom startup script to set interface link speed?
Post by: maccipher256 on December 09, 2024, 04:33:58 PM
Ah ok, I can see ix0 still available in the drop-down. 
What's the impact of assigning ix0 as an interface, whilst also having wan interface with ppoe
Title: Re: Custom startup script to set interface link speed?
Post by: Patrick M. Hausen on December 09, 2024, 04:51:42 PM
The impact is that you will be able to set the interface speed  ;)
Title: Re: Custom startup script to set interface link speed?
Post by: maccipher256 on December 09, 2024, 08:12:21 PM
Hi, please see screenshot of my existing interface setup.  As you can see, my WAN is configured to use PPOE which itself is bound to ixo.

So what you are saying it, I should create another interface, for ix0 and set the speed and duplex there?
Then I should assign this new interface as the interface for the ppoe device configuration?

If so, should the new IX0 interface be set with none for the IPV4/6 config.

Many thanks

Title: Re: Custom startup script to set interface link speed?
Post by: Patrick M. Hausen on December 09, 2024, 08:14:30 PM
You should leave the PPPoE and WAN just as it is.

- create a new interface, e.g. WANPHYS assigned to ix0
- enable WANPHYS
- set IPv4 and IPv6 addresses to "None"
- set link speed as desired

Done.
Title: Re: Custom startup script to set interface link speed?
Post by: maccipher256 on December 09, 2024, 08:17:55 PM
Ok thanks.  Seems counterintuitive to me as I'm not fully understanding why its necessary to create an interface from this device to support this and any security implications but will give it a try.

thank you sir.
Title: Re: Custom startup script to set interface link speed?
Post by: AhnHEL on December 09, 2024, 11:54:15 PM
I was using the X550-t2 last year but have since changed hardware.  Wasnt this issue resolved with this sysctl added to Tunables?

sysctl dev.ix.0.advertise_speed=55



Quote
sysctl dev.ix.X.advertise_speed=N

Where X is the interface number (e.g. for ix0, X=0 in the command above) and N is the sum of the advertised speeds, works.

In hex and decimal:

Control advertised link speed using these flags:
    0x1 - 1 - advertise 100M
    0x2 - 2 - advertise 1G
    0x4 - 4 - advertise 10G
    0x8 - 8 - advertise 10M

    0x10 - 16 - advertise 2.5G
    0x20 - 32 - advertise 5G

    100M and 10M are only supported on certain adapters.

To add advertisement of 2.5G and 5G on ix0:

sysctl dev.ix.0.advertise_speed=55

Since 7 + 16 + 32 = 55.




Or has the driver been updated since?
Title: Re: Custom startup script to set interface link speed?
Post by: maccipher256 on December 10, 2024, 12:31:32 AM
Hi let me try this. The driver hasn't been updated as far as I know.
Title: Re: Custom startup script to set interface link speed?
Post by: maccipher256 on December 10, 2024, 01:17:05 AM
I can confirm this also works.
Thanks for the suggestion!

Quote from: AhnHEL on December 09, 2024, 11:54:15 PM
I was using the X550-t2 last year but have since changed hardware.  Wasnt this issue resolved with this sysctl added to Tunables?

sysctl dev.ix.0.advertise_speed=55



Quote
sysctl dev.ix.X.advertise_speed=N

Where X is the interface number (e.g. for ix0, X=0 in the command above) and N is the sum of the advertised speeds, works.

In hex and decimal:

Control advertised link speed using these flags:
    0x1 - 1 - advertise 100M
    0x2 - 2 - advertise 1G
    0x4 - 4 - advertise 10G
    0x8 - 8 - advertise 10M

    0x10 - 16 - advertise 2.5G
    0x20 - 32 - advertise 5G

    100M and 10M are only supported on certain adapters.

To add advertisement of 2.5G and 5G on ix0:

sysctl dev.ix.0.advertise_speed=55

Since 7 + 16 + 32 = 55.




Or has the driver been updated since?