Switch eth0 and eth1 in image

I am migrating about 2 dozen Intel servers that are currently running Ubuntu to a custom OpenWRT image. I did a number of other server already without any problems.
But when I tried to upgrade the first server I noticed that they are all using eth0 (renamed to various different names, enp1s0, em1, eno1) for their WAN-interface.
This causes a major issue as OpenWRT by default uses eth1 as the WAN-interface.
Now before you all start shouting to just switch the cables around, I cannot.
First these are all running systems that are live-migrated, and secondly the WAN-interfaces are all using DHCP with a static ip leased on their MAC address and I do not control or am able to access the various DHCP servers.
And lastly they are located all over Belgium.

So now to the question does anyone see a way to switch the designation for the WAN interface to eth0 and LAN to eth1 while building the image? Or should I try to do this in uci-defaults

TIA,
Herman

Sound pretty much the same as the default ER4 setup for me…

I would highly recommend uci-defaults.

But I even more highly recommend having a setup script and run it after the actual install.
If you are not 100000% sure what you are doing when writing the super heavy duty complex uci-defaults script you are screwed beyond any hope once you reboot.

Hi thanks for the reply.

I am familiar with uci-defaults I already use it for some years to set the lan interfaces ip-address and update the banner, ... I currently have a setup script that runs from etc/init.d with a START=99, which checks for the existance of a setup-script and execute/removes it. But somehow I am not comfortable that the network initialization script will have completed by the time I get there.

Completed?
Have you tried it in lab environment and did it work or not?

I tried a live migration of another server and when it rebooted, it did not come online in our management system, necessitating a 150km drive to the location to see that my attempt to set the WAN interface to a fixed ip had failed and it was still set to DHCP. In the mean time I tried this with various devices in my lab and it succeeded every time, but still you know. Why did it fail that time?

First of all, this isn’t professional commercial code with functional guarantees that some industry application maybe require.
So if you use it with functional guarantees you can be in for some headache.

Do you use a stable release or a snapshot?

What have you written in the scripts that failed?
Compared to what was actually written in the config files after the script was run?

I know about the guarantees, I have been running OpenWRT since 2008, and not too many headaches for sure.

Latest stable release.

The script had some uci commands to set proto to static, ipaddr, etc.
None had been executed. Even though I use the same script on other occasions to set the country code and ssid, without issues. Although I have to mention that those were not on x86\64 target but ath79/generic.

Would you by any chance know how I can see the execution of the script and it's results in the bootlog? Because then I could try it some more in my lab. I have a tech picking up one of the servers on Monday, so I can test on a real system.

I don’t know if it is viewable in log or on remote.
But when you run these kind of scripts in terminal it say if a line is non working.

You could try writing some log echo “something” lines at different places in the script to see if they are processed.

Ok, back to experimenting it is. Fun, though time-consuming. :grin:

The second alternative is to make the configs manually and compile them with the firmware.

The cons with this solution is if the config setup is changed in the future which happens from time to time then new configs are needed.

Not a bad idea, I create a custom firmware just for these migrations, they are all the same brand/motherboard anyway.

1 Like

You can check out /etc/board.d/01_network and just over-write it in your ./files/etc/board.d/, which is used for things that are included outside of packages, but need to be put in every build. (Hint: check ./scripts/env for a way to easily handle said files across multiple targets)

I've never used ImageBuilder, so I don't know if this would work or if IB has similar functionality, but if source building, it's a peach.

I added a case with the correct board_name and this also allows me to specify all interfaces that make up the br-lan bridge.

Thanks!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.