Intel iMac Ethernet intermittently not working
I've had this iMac since new for 5 years and over the last 6 months or so it has developed an intemittent problem with Ethernet. When the problem occurs, the ethernet shows to be not connected in settings even though nothing has changed one day to the next. The cable and switch work when tested with another device, so it's not hardware outside the iMac. A month ago, Ethernet stopped working again and through a series of unrelated events, I had to downgrade from Sonoma to Ventura and then the Ethernet has worked flawlessly (indicates a software issue) until yesterday when it stopped in the middle of a YouTube video. WiFi works fine whenever Ethernet goes down, but it's slower and sometimes I need to transfer large files between computers which is why I went to the trouble of running an Ethernet cable to this machine. Now, today, Ethernet shows connected in settings and all appears to be well.
I have run the terminal command to turn off the Ethernet port and back on again, and I know there is a procedure to delete certain system config files that will then be regenerated but I can't find good information on that at the moment. Anybody have an ideas?
iMac 27″, macOS 13.6