OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • Custom startup script to set interface link speed?
« previous next »
  • Print
Pages: [1]

Author Topic: Custom startup script to set interface link speed?  (Read 2871 times)

patrick3000

  • Jr. Member
  • **
  • Posts: 87
  • Karma: 6
    • View Profile
Custom startup script to set interface link speed?
« 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.
Logged

bartjsmit

  • Hero Member
  • *****
  • Posts: 2023
  • Karma: 194
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #1 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...
Logged

patrick3000

  • Jr. Member
  • **
  • Posts: 87
  • Karma: 6
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #2 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.
« Last Edit: February 02, 2024, 08:46:57 am by patrick3000 »
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17745
  • Karma: 1620
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #3 on: February 02, 2024, 09:15:40 am »
Isn't this possible in the media settings of the interface?


Cheers,
Franco
Logged

patrick3000

  • Jr. Member
  • **
  • Posts: 87
  • Karma: 6
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #4 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.
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17745
  • Karma: 1620
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #5 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
Logged

patrick3000

  • Jr. Member
  • **
  • Posts: 87
  • Karma: 6
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #6 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.
Logged

bartjsmit

  • Hero Member
  • *****
  • Posts: 2023
  • Karma: 194
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #7 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.
Logged

patrick3000

  • Jr. Member
  • **
  • Posts: 87
  • Karma: 6
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #8 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.
« Last Edit: February 03, 2024, 05:31:37 pm by patrick3000 »
Logged

patrick3000

  • Jr. Member
  • **
  • Posts: 87
  • Karma: 6
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #9 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.
« Last Edit: February 03, 2024, 05:30:45 pm by patrick3000 »
Logged

Mr.Moo52

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #10 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!
Logged

patrick3000

  • Jr. Member
  • **
  • Posts: 87
  • Karma: 6
    • View Profile
Re: Custom startup script to set interface link speed?
« Reply #11 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.
« Last Edit: November 02, 2024, 06:52:42 am by patrick3000 »
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • Custom startup script to set interface link speed?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2