I'd like to configure my router's network interfaces as shown in the diagram below.
Currently, I need to produce dozens of these routers, and they should all have the same physical interface assignments:
lan: eth0
wan1: eth1
wan2: eth2
wan3: eth3
wan4: eth4
wan5: eth5
wan6: eth6
wan7: eth7
I've set up failover functionality using mwan3. However, I'm concerned that the order of eth0, eth1, and eth2 might change. How does OpenWrt determine the order of eth0, eth1, and eth2?
I've read suggestions to fix this issue using MAC addresses, but since each machine will have a different MAC address, I'd have to configure it individually. Is there a more efficient way to create installation images for each machine with consistent interface assignments? Any good ideas or advice would be greatly appreciated. please..TT Thank you!
Thank you very much for answering my question. I asked the manufacturer if the process of processing the PIC NIC of the product is the same, and I want to process it as you to
Thank you for your response. I have limited knowledge in this area, and I'm finding it challenging to understand how to change the 'path'. Could you possibly provide a script related to this and explain how to use it? I would really appreciate your assistance. Thank you!
Set up the hotplug script linked above, then reconfigure devices like this:
while uci -q delete network.@device[0]; do :; done
find /sys/class/net/*/device/uevent \
| awk -F '/' '{print $5}' \
| sort -u \
| while read -r DEV_NAME
do DEV_MAC="$(cat /sys/class/net/${DEV_NAME}/address)"
case ${DEV_NAME} in
(eth0|lan) DEV_NAME="lan"
uci set network.${DEV_NAME}_br="device"
uci set network.${DEV_NAME}_br.name="br-${DEV_NAME}"
uci set network.${DEV_NAME}_br.type="bridge"
uci add_list network.${DEV_NAME}_br.ports="${DEV_NAME}"
uci set network.${DEV_NAME}.device="br-${DEV_NAME}" ;;
(eth*|wan*) DEV_NAME="wan${DEV_NAME##*[^0-9]}"
uci set network.${DEV_NAME}.device="${DEV_NAME}"
uci set network.${DEV_NAME}6.device="${DEV_NAME}" ;;
esac
uci set network.${DEV_NAME}_dev="device"
uci set network.${DEV_NAME}_dev.name="${DEV_NAME}"
uci set network.${DEV_NAME}_dev.mac="${DEV_MAC}"
done
uci commit network
service network restart
Thank you so much for your help. I've implemented the following script in rc.local to set network names based on the PCI Path. I really appreciate it! I'm not entirely sure if this is the correct implementation, but I confirmed that it works well. Thank you so much!
for dev in $(ls -1 /sys/class/net); do
ip link set dev "$dev" down
if [ "$dev" != "lo" ] && [ "$dev" != "br-lan" ]; then
ip link set dev "$dev" name "${dev}_tmp"
fi
done
for dev in $(ls -1 /sys/class/net); do
path=$(basename $(readlink -f "/sys/class/net/$dev/device" 2>/dev/null))
if [ "$dev" = "lo" ] || [ "$dev" = "br-lan" ]; then
continue
fi
case "$path" in
"0000:03:00.0")
ip link set dev "$dev" name eth0
;;
"0000:05:00.0")
ip link set dev "$dev" name eth1
;;
..............................
esac
done
for dev in $(ls -1 /sys/class/net); do
ip link set dev "$dev" up
done
Thank you for your advice. I initially implemented the change based on MAC addresses, but then realized that these can vary from device to device. So, I explored a different method. Thanks to your suggestion, I learned about various approaches and gained a bit more understanding in this field. I really appreciate your help. Thank you!
Thank you for your advice. However, I understand that using metric values to set up interfaces is a method applied in mwan3. I was looking for a way to assign fixed names to network interfaces so that the same interface is consistently recognized by the same name every time the system boots. If I'm misunderstanding your suggestion due to my limited knowledge in this area, please kindly clarify it for me. This field seems to require a lot of learning and understanding