Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mgqnfoqv7k2w
AutoBuildImmortalWrt
Commits
4e2dbcd8
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "ce31113abddca08aaa71222de7a875483326e92d"
Unverified
Commit
4e2dbcd8
authored
Aug 22, 2025
by
wukongdaily
Committed by
GitHub
Aug 22, 2025
Browse files
adjust r5c eth
parent
be28eddf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
46 deletions
+53
-46
files/etc/uci-defaults/99-custom.sh
files/etc/uci-defaults/99-custom.sh
+53
-46
No files found.
files/etc/uci-defaults/99-custom.sh
View file @
4e2dbcd8
...
...
@@ -23,91 +23,98 @@ else
.
"
$SETTINGS_FILE
"
fi
# 计算网卡数量
count
=
0
# 1. 先获取所有物理接口列表
ifnames
=
""
for
iface
in
/sys/class/net/
*
;
do
iface_name
=
$(
basename
"
$iface
"
)
# 检查是否为物理网卡(排除回环设备和无线设备)
if
[
-e
"
$iface
/device"
]
&&
echo
"
$iface_name
"
|
grep
-Eq
'^eth|^en'
;
then
count
=
$((
count
+
1
))
ifnames
=
"
$ifnames
$iface_name
"
fi
done
# 删除多余空格
ifnames
=
$(
echo
"
$ifnames
"
|
awk
'{$1=$1};1'
)
# 网络设置
count
=
$(
echo
"
$ifnames
"
|
wc
-w
)
echo
"Detected physical interfaces:
$ifnames
"
>>
$LOGFILE
echo
"Interface count:
$count
"
>>
$LOGFILE
# 2. 根据板子型号映射WAN和LAN接口
board_name
=
$(
cat
/tmp/sysinfo/board_name 2>/dev/null
||
echo
"unknown"
)
echo
"Board detected:
$board_name
"
>>
$LOGFILE
wan_ifname
=
""
lan_ifnames
=
""
# 此处特殊处理个别开发板网口顺序问题
case
"
$board_name
"
in
"radxa,e20c"
|
"friendlyarm,nanopi-r5c"
)
wan_ifname
=
"eth1"
lan_ifnames
=
"eth0"
echo
"Using
$board_name
mapping: WAN=
$wan_ifname
LAN=
$lan_ifnames
"
>>
"
$LOGFILE
"
;;
*
)
# 默认第一个接口为WAN,其余为LAN
wan_ifname
=
$(
echo
"
$ifnames
"
|
awk
'{print $1}'
)
lan_ifnames
=
$(
echo
"
$ifnames
"
|
cut
-d
' '
-f2-
)
echo
"Using default mapping: WAN=
$wan_ifname
LAN=
$lan_ifnames
"
>>
"
$LOGFILE
"
;;
esac
# 3. 配置网络
if
[
"
$count
"
-eq
1
]
;
then
# 单网口设备 类似于NAS模式 动态获取ip模式 具体ip地址取决于上一级路由器给它分配的ip 也方便后续你使用web页面设置旁路由
# 单网口设备 不支持修改ip 不要在此处修改ip 单网口采用dhcp模式 删除默认的192.168.1.1
# 单网口设备,DHCP模式
uci
set
network.lan.proto
=
'dhcp'
uci delete network.lan.ipaddr
uci delete network.lan.netmask
uci delete network.lan.gateway
uci delete network.lan.dns
uci delete network.lan.gateway
uci delete network.lan.dns
uci commit network
elif
[
"
$count
"
-gt
1
]
;
then
# 提取第一个接口作为WAN
wan_ifname
=
$(
echo
"
$ifnames
"
|
awk
'{print $1}'
)
# 剩余接口保留给LAN
lan_ifnames
=
$(
echo
"
$ifnames
"
|
cut
-d
' '
-f2-
)
# 设置WAN接口基础配置
# 多网口设备配置
# 配置WAN
uci
set
network.wan
=
interface
# 提取第一个接口作为WAN
uci
set
network.wan.device
=
"
$wan_ifname
"
# WAN接口默认DHCP
uci
set
network.wan.proto
=
'dhcp'
# 设置WAN6绑定网口eth0
# 配置WAN6
uci
set
network.wan6
=
interface
uci
set
network.wan6.device
=
"
$wan_ifname
"
# 更新LAN接口成员
# 查找对应设备的section名称
uci
set
network.wan6.proto
=
'dhcpv6'
# 查找 br-lan 设备 section
section
=
$(
uci show network |
awk
-F
'[.=]'
'/\.@?device\[\d+\]\.name=.br-lan.$/ {print $2; exit}'
)
if
[
-z
"
$section
"
]
;
then
echo
"error:cannot find device 'br-lan'."
>>
$LOGFILE
else
# 删除原
来的
ports
列表
# 删除原
有
ports
uci
-q
delete
"network.
$section
.ports"
# 添加
新的ports列表
# 添加
LAN接口端口
for
port
in
$lan_ifnames
;
do
uci add_list
"network.
$section
.ports"
=
"
$port
"
done
echo
"
ports of device 'br-lan' are update.
"
>>
$LOGFILE
echo
"
Updated br-lan ports:
$lan_ifnames
"
>>
$LOGFILE
fi
# LAN口设置静态IP
# LAN静态IP设置
uci
set
network.lan.proto
=
'static'
# 多网口设备 支持修改为别的管理后台地址 在Github Action 的UI上自行输入即可
uci
set
network.lan.ipaddr
=
'192.168.100.1'
uci
set
network.lan.netmask
=
'255.255.255.0'
# 设置路由器管理后台地址
IP_VALUE_FILE
=
"/etc/config/custom_router_ip.txt"
if
[
-f
"
$IP_VALUE_FILE
"
]
;
then
CUSTOM_IP
=
$(
cat
"
$IP_VALUE_FILE
"
)
# 用户在UI上设置的路由器后台管理地址
uci
set
network.lan.ipaddr
=
$CUSTOM_IP
echo
"custom router ip is
$CUSTOM_IP
"
>>
$LOGFILE
else
uci
set
network.lan.ipaddr
=
'192.168.100.1'
echo
"default router ip is 192.168.100.1"
>>
$LOGFILE
fi
echo
"Set LAN IP to 192.168.100.1"
>>
$LOGFILE
#
判断是否启用
PPPoE
echo
"
print
enable_pppoe value
===
$enable_pppoe
"
>>
$LOGFILE
# PPPoE
设置
echo
"enable_pppoe value
:
$enable_pppoe
"
>>
$LOGFILE
if
[
"
$enable_pppoe
"
=
"yes"
]
;
then
echo
"PPPoE is enabled at
$(
date
)
"
>>
$LOGFILE
# 设置ipv4宽带拨号信息
echo
"PPPoE enabled, configuring..."
>>
$LOGFILE
uci
set
network.wan.proto
=
'pppoe'
uci
set
network.wan.username
=
$pppoe_account
uci
set
network.wan.password
=
$pppoe_password
uci
set
network.wan.username
=
"
$pppoe_account
"
uci
set
network.wan.password
=
"
$pppoe_password
"
uci
set
network.wan.peerdns
=
'1'
uci
set
network.wan.auto
=
'1'
# 设置ipv6 默认不配置协议
uci
set
network.wan6.proto
=
'none'
echo
"PPPoE config
uration completed successfully
."
>>
$LOGFILE
echo
"PPPoE config
done
."
>>
$LOGFILE
else
echo
"PPPoE
is
not enabled.
Skipping configuration.
"
>>
$LOGFILE
echo
"PPPoE not enabled."
>>
$LOGFILE
fi
uci commit network
fi
# 若安装了dockerd 则设置docker的防火墙规则
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment