Dhcp address as default in build

Is it possible to build an image which comes with option proto 'dhcp' in the network lan configuration?

Yes, use custom files. Search the forum and openwrt.org to see how this is done.

2 Likes

https://openwrt.org/docs/guide-developer/build-system/use-buildsystem#custom_files

Thanks for the pointer, so am correct in thinking I need to copy my customised network file here?

<buildroot dir>/files/etc/config/network

yes, that is the correct place

If you put it in etc/config/network. Does it overwrite the whole default nework file or it just changes the proto from static to DHCP?

so I will be having
files/etc/config - for other custom files
files /etc/uci-defaults/network_customization - for changing the proto
is it ?

also, the script would look something like this right?

#!/bin/sh
uci set network.proto='dhcp'
uci commit network 
exit 0
mkdir -p files/etc/uci-defaults
cat << "EOF_cat" > files/etc/uci-defaults/xx_custom
WIFI_SSID="$(sed -n -r -e "s/://g;s/.*(.{4})$/\1/;1p" \
    /sys/class/net/wlan*/address)"
uci -q batch << EOF
set network.lan.proto=dhcp
delete network.lan.ipaddr
delete network.lan.netmask
commit network
set wireless.@wifi-iface[0].ssid=${WIFI_SSID}
commit wireless
EOF
EOF_cat
1 Like

Thank you so much .. its a great help

one more confirmation.

can i also add

set wireless.ap.ssid=$(cat /sys/class/net/wlan*/address | head -n 1
 | tr -d ":" | tr -d "\n"| tail -c 4)

into the same file?

1 Like

I've updated the code above.

Thank you so much

1 Like

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