#
修改wan口为pppoe拨号
package/base-files/files/lib/functions/uci-defaults.sh
1
2
3
4
|
ucidef_set_interface_wan() {
#dhcp改成pppoe
ucidef_set_interface "wan" ifname "$1" protocol "${2:-dhcp}"
}
|
#
修改lan口ip和pppoe拨号用户名、密码
package/base-files/files/bin/config_generate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
case "$protocol" in
static)
local ipad
case "$1" in
#修改lan口ip
lan) ipad=${ipaddr:-"192.168.1.1"} ;;
*) ipad=${ipaddr:-"192.168.$((addr_offset++)).1"} ;;
esac
netm=${netmask:-"255.255.255.0"}
uci -q batch <<-EOF
set network.$1.proto='static'
set network.$1.ipaddr='$ipad'
set network.$1.netmask='$netm'
EOF
[ -e /proc/sys/net/ipv6 ] && uci set network.$1.ip6assign='60'
;;
dhcp)
# fixup IPv6 slave interface if parent is a bridge
[ "$type" = "bridge" ] && ifname="br-$1"
uci set network.$1.proto='dhcp'
[ -e /proc/sys/net/ipv6 ] && {
uci -q batch <<-EOF
delete network.${1}6
set network.${1}6='interface'
set network.${1}6.ifname='$ifname'
set network.${1}6.proto='dhcpv6'
EOF
}
;;
pppoe)
uci -q batch <<-EOF
set network.$1.proto='pppoe'
#拨号用户名
set network.$1.username='username'
#拨号密码
set network.$1.password='password'
EOF
[ -e /proc/sys/net/ipv6 ] && {
uci -q batch <<-EOF
set network.$1.ipv6='1'
delete network.${1}6
set network.${1}6='interface'
set network.${1}6.ifname='@${1}'
set network.${1}6.proto='dhcpv6'
EOF
}
;;
esac
|
#
修改默认lan
package/base-files/files/etc/board.d/99-default_network
1
|
ucidef_set_interface_lan 'eth0 eth2 eth3' # eth0 eth2 eth3
|
#
win子系统ubuntu20.04.6 LTS 编译openwrt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
sudo apt install build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses-dev libssl-dev python3-distutils rsync unzip zlib1g-dev file wget mkisofs
git clone -b v22.03.5 https://github.com/openwrt/openwrt.git
v23.05.0
cd openwrt/
./scripts/feeds update -a
./scripts/feeds install -a
cd package/
git clone https://github.com/jerrykuku/luci-theme-argon.git #安装皮肤
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
make menuconfig #配置
# 默认架构 皮肤 语言 ...选择
# LuCI>Modules>Translations>Chinese Simplified #语言选择
# LuCI>Modules>Themes #皮肤选择
# 修改默认皮肤
# feeds/luci/collections/luci/Makefile
# 23.05 版本在 feeds/luci/collections/luci-light/Makefile
# 将LUCI_DESCRIPTION中,bootstrap 替换为 argon
# 将LUCI_DEPENDS中,+luci-theme-bootstrap 替换为 +luci-theme-argon
make V=s -j8 #编译
|
#
串口工具进入 openwrt 终端需要用户名和密码
1
2
3
4
5
6
7
8
9
10
11
|
# 修改下面文件
# /package/base-files/files/usr/libexec/login.sh
#!/bin/sh
[ "$(uci -q get system.@system[0].ttylogin)" = 1 ] || exec /bin/login # /bin/ash --login
exec /bin/login
# 前提设置了密码
# 修改下面文件 密码 admin
# /package/base-files/files/etc/shadow
root:$1$8IHo1.U2$qw3WHbJ1duKWYiLkcSInY1:19651:0:99999:7:::
|
#
dnsmasq 默认配置信息
1
2
3
4
|
# package/network/services/dnsmasq/files/dhcp.conf
option rebind_protection 0 # disable if upstream must serve RFC1918 addresses 改成0
list server '10.0.0.1#5353' # 去掉# /mycompany.local/1.2.3.4改成 10.0.0.1#5353 AdGuardHome用
|
#
更好的处理方式 uci-defaults
在 package/base-files/files/etc/uci-defaults
目录下创建脚本和默认配置覆盖原有配置,例子
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#!/bin/sh
uci -q batch <<-EOF >/dev/null
set network.wan.device='eth1'
set network.wan.proto='pppoe'
set network.wan.username='账号'
set network.wan.password='密码'
set network.wan.peerdns='0'
set network.wan.ipv6='0'
commit network
EOF
# 禁止空密码登录
sed -i 's/root:::0:99999:7:::/root:$1$8IHo1.U2$qw3WHbJ1duKWYiLkcSInY1:0:0:99999:7:::/g' /etc/shadow
sed -i 's/ash\ --//g' /usr/libexec/login.sh
exit 0
|