swbbs 发表于 2025-4-19 07:49

小白发immortalwrt 首次启动时运行的脚本请大神完善

本帖最后由 swbbs 于 2025-4-19 09:28 编辑

不要嘲笑

#!/bin/sh
# Set root password (SHA512 hash of '123456')
ROOT_PASSWORD='$6$0ahu9n82kfad$0ahu9n82kfadX3eZ5pLOKbB4h8eR$J7j5Y8jLrYd5Ue6vz7wQ1cQ3eZ5pLOKbB4h8eR/examplehash'
uci set system.@system[-1].password="$ROOT_PASSWORD"

# Network configuration
# Configure WAN interface (PPPoE on eth0)
uci delete network.wan
uci set network.wan='interface'
uci set network.wan.proto='pppoe'
uci set network.wan.device='eth0'
uci set network.wan.username='053704027571'
uci set network.wan.password='123456'

# Configure LAN bridge (eth1-eth3)
uci delete network.lan
uci set network.lan='interface'
uci set network.lan.type='bridge'
uci set network.lan.proto='static'
uci set network.lan.netmask='255.255.255.0'
uci set network.lan.ipaddr='10.0.0.1'
uci set network.lan.ifname='eth1 eth2 eth3'
uci set network.lan.ip6assign='0'# Disable IPv6 assignment

# Disable IPv6 globally
uci set network.globals.ula_prefix=''

# Firewall configuration
uci delete firewall.@zone
uci delete firewall.@zone
uci add firewall zone
uci set firewall.@zone[-1].name='lan'
uci set firewall.@zone[-1].input='ACCEPT'
uci set firewall.@zone[-1].output='ACCEPT'
uci set firewall.@zone[-1].forward='ACCEPT'
uci set firewall.@zone[-1].network='lan'

uci add firewall zone
uci set firewall.@zone[-1].name='wan'
uci set firewall.@zone[-1].input='REJECT'
uci set firewall.@zone[-1].output='ACCEPT'
uci set firewall.@zone[-1].forward='REJECT'
uci set firewall.@zone[-1].masq='1'
uci set firewall.@zone[-1].mtu_fix='1'
uci set firewall.@zone[-1].network='wan'

# Allow LAN -> WAN forwarding
uci add firewall forwarding
uci set firewall.@forwarding[-1].src='lan'
uci set firewall.@forwarding[-1].dest='wan'

# DHCP configuration
uci set dhcp.lan.leasetime='12h'
uci set dhcp.lan.start='100'
uci set dhcp.lan.limit='155'# 100-254 (155 IPs)
uci set dhcp.lan.ra='disabled'
uci set dhcp.lan.dhcpv6='disabled'

# Commit changes
uci commit

# Cleanup script
rm -f "$0"

iamyangyi 发表于 2025-4-19 08:43

发了个寂寞啊 哈哈

swbbs 发表于 2025-4-19 08:57

iamyangyi 发表于 2025-4-19 08:43
发了个寂寞啊 哈哈

好像到处是问题,所以没敢发

swbbs 发表于 2025-4-19 08:59

本帖最后由 swbbs 于 2025-4-19 09:16 编辑

这样设置对吗,如果除了问题初始化,是不是还会走一次脚本

Axiaobai 发表于 2025-4-23 10:06

发现个问题,虽然写的uci set dhcp.lan.start='100'
uci set dhcp.lan.limit='155'这样设置,但是往往分配会超出此范围,没搞清楚,如何使它严格遵守此规定设置。
页: [1]
查看完整版本: 小白发immortalwrt 首次启动时运行的脚本请大神完善