|
|
|
@ -265,64 +265,62 @@ set_easymesh() {
|
|
|
|
|
add_kvr
|
|
|
|
|
add_dawn
|
|
|
|
|
|
|
|
|
|
if [ "$ap_mode" = 1 ]; then
|
|
|
|
|
|
|
|
|
|
if [ "$ap_mode" = 1 ]; then
|
|
|
|
|
# Backup Configurations
|
|
|
|
|
cp /etc/config/wireless /etc/config/wireless.backup
|
|
|
|
|
cp /etc/config/network /etc/config/network.backup
|
|
|
|
|
cp /etc/config/dhcp /etc/config/dhcp.backup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Generate a random IP in the same subnet
|
|
|
|
|
ip_base=$(echo "$dns" | cut -d'.' -f1-3) # Get the first three octets of the DNS IP
|
|
|
|
|
last_octet=$((RANDOM % 254 + 1)) # Generate a random value for the last octet between 1 and 254
|
|
|
|
|
nodeip="${ip_base}.${last_octet}" # Concatenate the base IP with the new last octet
|
|
|
|
|
|
|
|
|
|
# Configure Bridge and Interfaces
|
|
|
|
|
uci set network.lan.type='bridge'
|
|
|
|
|
uci set network.lan.ifname="$(uci get network.lan.ifname) $(uci get network.wan.ifname)"
|
|
|
|
|
uci del network.wan.ifname
|
|
|
|
|
uci set wireless.mesh_$apall.mesh_fwding='1'
|
|
|
|
|
|
|
|
|
|
# Disable dnsmasq
|
|
|
|
|
uci set network.lan.ifname='eth0' # assuming eth0 is the LAN interface
|
|
|
|
|
uci set network.lan.proto='static'
|
|
|
|
|
uci set network.lan.ipaddr=$nodeip # Set the randomly chosen IP
|
|
|
|
|
uci set network.lan.netmask='255.255.255.0' # Set your desired netmask
|
|
|
|
|
uci set network.lan.gateway=$dns # Set the gateway IP (usually your main router IP)
|
|
|
|
|
uci set network.lan.dns=$dns # Set the DNS IP
|
|
|
|
|
uci set system.@system[0].hostname=$gateway
|
|
|
|
|
|
|
|
|
|
# Add the Wi-Fi interface to the LAN bridge
|
|
|
|
|
uci set wireless.default_$apall.network='lan' # Adjust if your wireless interface name differs
|
|
|
|
|
|
|
|
|
|
# Disable and stop dnsmasq
|
|
|
|
|
uci commit dhcp; echo '' > /etc/config/dhcp
|
|
|
|
|
/etc/init.d/dnsmasq disable
|
|
|
|
|
/etc/init.d/dnsmasq stop
|
|
|
|
|
|
|
|
|
|
# Switch LAN to DHCP Client
|
|
|
|
|
echo "Switching the LAN interface to DHCP client"
|
|
|
|
|
uci del network.lan.broadcast
|
|
|
|
|
uci del network.lan.dns
|
|
|
|
|
uci del network.lan.gateway
|
|
|
|
|
uci del network.lan.ipaddr
|
|
|
|
|
uci del network.lan.netmask
|
|
|
|
|
uci set network.lan.proto='dhcp'
|
|
|
|
|
uci set system.@system[0].hostname=$gateway
|
|
|
|
|
uci set network.lan.hostname="`uci get system.@system[0].hostname`"
|
|
|
|
|
|
|
|
|
|
# Add WAN to br-lan bridge
|
|
|
|
|
echo "Adding WAN to br-lan bridge"
|
|
|
|
|
uci set network.lan.ifname="$(uci get network.lan.ifname) eth1" # assuming eth1 is your WAN interface
|
|
|
|
|
uci commit network
|
|
|
|
|
# Delete existing WAN interface
|
|
|
|
|
uci delete network.wan
|
|
|
|
|
|
|
|
|
|
# Delete WAN zone from firewall
|
|
|
|
|
echo "Deleting the WAN zone from the firewall"
|
|
|
|
|
# Delete WAN zone from firewall
|
|
|
|
|
wan_zone=$(uci show firewall | grep '=zone' | grep '.name=' | grep 'wan' | cut -d'.' -f2)
|
|
|
|
|
if [ ! -z "$wan_zone" ]; then
|
|
|
|
|
uci delete firewall.$wan_zone
|
|
|
|
|
echo "WAN zone deleted"
|
|
|
|
|
else
|
|
|
|
|
echo "No WAN zone found"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Adjust the firewall settings as necessary
|
|
|
|
|
|
|
|
|
|
# Commit the changes
|
|
|
|
|
uci commit firewall
|
|
|
|
|
uci commit network
|
|
|
|
|
|
|
|
|
|
# Commit Changes and Restart Network
|
|
|
|
|
uci commit
|
|
|
|
|
uci commit wireless
|
|
|
|
|
uci commit system
|
|
|
|
|
# Restart services to apply changes
|
|
|
|
|
sync
|
|
|
|
|
/etc/init.d/network restart
|
|
|
|
|
|
|
|
|
|
# Reboot the device
|
|
|
|
|
#echo "Please reboot the device..."
|
|
|
|
|
#reboot
|
|
|
|
|
/etc/init.d/wireless restart
|
|
|
|
|
/etc/init.d/system reload
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
ap_mode_stop
|
|
|
|
|
|
|
|
|
|