Skip to content

Instantly share code, notes, and snippets.

@muink
Last active January 31, 2025 06:40
Show Gist options
  • Save muink/d241ab0aec7d9c34b69439c1e942d1f5 to your computer and use it in GitHub Desktop.
Save muink/d241ab0aec7d9c34b69439c1e942d1f5 to your computer and use it in GitHub Desktop.
Openwrt install snippet
opkg update
# Base Apps:
opkg install luci-app-filemanager luci-i18n-filemanager-zh-cn luci-i18n-filemanager-zh-tw
opkg install ttyd luci-app-ttyd luci-i18n-ttyd-zh-cn luci-i18n-ttyd-zh-tw
opkg install miniupnpd luci-app-upnp luci-i18n-upnp-zh-cn luci-i18n-upnp-zh-tw
uci set upnpd.config.enabled='1'
uci set upnpd.config.igdv1='1'
uci set upnpd.config.external_ip='1.2.3.4'
uci commit upnpd
reservice 'miniupnpd' restart
opkg install luci-app-advanced-reboot luci-i18n-advanced-reboot-zh-cn luci-i18n-advanced-reboot-zh-tw
opkg install luci-app-commands luci-i18n-commands-zh-cn luci-i18n-commands-zh-tw
opkg install nlbwmon luci-app-nlbwmon luci-i18n-nlbwmon-zh-cn luci-i18n-nlbwmon-zh-tw
opkg install rgmac luci-app-change-mac luci-i18n-change-mac-zh-cn luci-i18n-change-mac-zh-tw
# DNS Server
## smartdns
opkg install smartdns luci-app-smartdns luci-i18n-smartdns-zh-cn luci-i18n-smartdns-zh-tw
## pcap-dnsproxy
opkg install pcap-dnsproxy luci-app-pcap-dnsproxy luci-i18n-pcap-dnsproxy-zh-cn luci-i18n-pcap-dnsproxy-zh-tw
uci set network.wan.peerdns='0'
uci set dhcp.@dnsmasq[0].noresolv=1
uci commit network
uci commit dhcp
reservice 'network' reload
reservice 'dnsmasq' restart
# Pcap-DNSProxy
uci set pcap-dnsproxy.@pcap-dnsproxy[0].enabled='1'
uci commit pcap-dnsproxy
# reservice 'pcap-dnsproxy' stop && sleep 2 && reservice 'pcap-dnsproxy' start
#
# /etc/pcap-dnsproxy/Config.conf
# pcapconf='/etc/pcap-dnsproxy/Config.conf'
# sed -i 's,Operation Mode = Server,Operation Mode = Private,g' $pcapconf
# sed -i 's,Outgoing Protocol = IPv4 + UDP,Outgoing Protocol = IPv4 + TCP,g' $pcapconf
# sed -i 's,Local Hosts = 0,Local Hosts = 1,g' $pcapconf
# sed -i 's,Local Routing = 1,Local Routing = 0,g' $pcapconf
# sed -i 's,Local Force Request = 0,Local Force Request = 1,g' $pcapconf
# sed -i 's,TCP Fast Open = 0,TCP Fast Open = 1,g' $pcapconf
# sed -i 's,ICMP Test = 900,ICMP Test = 0,g' $pcapconf
# sed -i 's,Domain Test = 900,Domain Test = 0,g' $pcapconf
# sed -i 's,Alternate Reset Time = 300,Alternate Reset Time = 900,g' $pcapconf
# sed -i 's,EDNS Label = 0,EDNS Label = All - Local - SOCKS Proxy - HTTP CONNECT Proxy - DNSCurve,g' $pcapconf
# sed -i 's,EDNS Client Subnet Relay = 0,EDNS Client Subnet Relay = 1,g' $pcapconf
# sed -i 's,DNSSEC Request = 0,DNSSEC Request = 1,g' $pcapconf
# Optional App:
## statistics
opkg install luci-app-statistics luci-i18n-statistics-zh-cn luci-i18n-statistics-zh-tw
opkg install collectd-mod-cpufreq
opkg install collectd-mod-disk
opkg install collectd-mod-thermal
##
opkg install collectd-mod-conntrack
opkg install collectd-mod-dhcpleases
opkg install collectd-mod-dns
opkg install collectd-mod-iptables
opkg install collectd-mod-wireless
## web server:
opkg install luci-app-uhttpd luci-i18n-uhttpd-zh-cn luci-i18n-uhttpd-zh-tw
opkg install acme acme-acmesh-dnsapi luci-app-acme luci-i18n-acme-zh-cn luci-i18n-acme-zh-tw
opkg install ddns-scripts ddns-scripts-noip luci-app-ddns luci-i18n-ddns-zh-cn luci-i18n-ddns-zh-tw
## tools:
opkg install p910nd luci-app-p910nd luci-i18n-p910nd-zh-cn luci-i18n-p910nd-zh-tw
opkg install hd-idle luci-app-hd-idle luci-i18n-hd-idle-zh-cn luci-i18n-hd-idle-zh-tw
opkg install etherwake luci-app-wol luci-i18n-wol-zh-cn luci-i18n-wol-zh-tw
opkg install mwan3 luci-app-mwan3 luci-i18n-mwan3-zh-cn luci-i18n-mwan3-zh-tw
opkg install wifischedule luci-app-wifischedule luci-i18n-wifischedule-zh-cn luci-i18n-wifischedule-zh-tw
opkg install dawn luci-app-dawn luci-i18n-dawn-zh-cn luci-i18n-dawn-zh-tw
opkg install travelmate luci-app-travelmate luci-i18n-travelmate-zh-cn luci-i18n-travelmate-zh-tw
opkg install watchcat luci-app-watchcat luci-i18n-watchcat-zh-cn luci-i18n-watchcat-zh-tw
##
opkg install cshark luci-app-cshark luci-i18n-cshark-zh-cn luci-i18n-cshark-zh-tw
opkg install aria2 luci-app-aria2 luci-i18n-aria2-zh-cn luci-i18n-aria2-zh-tw
opkg install transmission-daemon luci-app-transmission luci-i18n-transmission-zh-cn luci-i18n-transmission-zh-tw
opkg install adblock luci-app-adblock luci-i18n-adblock-zh-cn luci-i18n-adblock-zh-tw
opkg install simple-adblock luci-app-simple-adblock luci-i18n-simple-adblock-zh-cn luci-i18n-simple-adblock-zh-tw
## media server
opkg install minidlna luci-app-minidlna luci-i18n-minidlna-zh-cn luci-i18n-minidlna-zh-tw
opkg install samba4-server cifsmount luci-app-samba4 luci-i18n-samba4-zh-cn luci-i18n-samba4-zh-tw
opkg install ksmbd-server luci-app-ksmbd luci-i18n-ksmbd-zh-cn luci-i18n-ksmbd-zh-tw
#opkg install cifsmount samba36-server samba36-hotplug luci-app-samba luci-i18n-samba-zh-cn
# [ "$(sed -n "/^[ \t]*domain master =/p" /etc/samba/smb.conf.template)" == "" ] && sed -i "$ a \\\tdomain master = yes" /etc/samba/smb.conf.template || sed -Ei "s|^([ \t]*domain master =).*$|\1 yes|" /etc/samba/smb.conf.template
# [ "$(sed -n "/^[ \t]*local master =/p" /etc/samba/smb.conf.template)" == "" ] && sed -i "$ a \\\tlocal master = yes" /etc/samba/smb.conf.template || sed -Ei "s|^([ \t]*local master =).*$|\1 yes|" /etc/samba/smb.conf.template
# [ "$(sed -n "/^[ \t]*name resolve order =/p" /etc/samba/smb.conf.template)" == "" ] && sed -i "$ a \\\tname resolve order = wins lmhosts hosts bcast" /etc/samba/smb.conf.template || || sed -Ei "s|^([ \t]*name resolve order =).*$|\1 wins lmhosts hosts bcast|" /etc/samba/smb.conf.template
# [ "$(sed -n "/^[ \t]*os level =/p" /etc/samba/smb.conf.template)" == "" ] && sed -i "$ a \\\tos level = 99" /etc/samba/smb.conf.template || sed -Ei "s|^([ \t]*os level =).*$|\1 99|" /etc/samba/smb.conf.template
# [ "$(sed -n "/^[ \t]*preferred master =/p" /etc/samba/smb.conf.template)" == "" ] && sed -i "$ a \\\tpreferred master = yes" /etc/samba/smb.conf.template || sed -Ei "s|^([ \t]*preferred master =).*$|\1 yes|" /etc/samba/smb.conf.template
# [ "$(sed -n "/^[ \t]*wins support =/p" /etc/samba/smb.conf.template)" == "" ] && sed -i "$ a \\\twins support = yes" /etc/samba/smb.conf.template || sed -Ei "s|^([ \t]*wins support =).*$|\1 yes|" /etc/samba/smb.conf.template
# reservice 'samba' restart
## qos:
opkg install sqm-scripts sqm-scripts-extra luci-app-sqm luci-i18n-sqm-zh-cn luci-i18n-sqm-zh-tw
opkg install qos-scripts luci-app-qos luci-i18n-qos-zh-cn luci-i18n-qos-zh-tw
opkg install nft-qos luci-app-nft-qos luci-i18n-nft-qos-zh-cn luci-i18n-nft-qos-zh-tw
[fe80::]
passwd
# dev?
#uci set luci.ccache.enable=0; uci commit luci
# init function
function reservice() {
local service="$1"
local action="$2"
echo "${action^}ing ${service} service..."
if hash service 2>/dev/null; then service ${service} ${action};
elif hash busybox 2>/dev/null && [[ -d "/etc/init.d" ]]; then /etc/init.d/${service} ${action};
else echo "Now please ${action} ${service} since I don't know how to do it.";
fi
}
# Local OPKG packages:
opkg update
opkg install blockd mount-utils lsblk blkid kmod-fs-vfat kmod-fs-exfat kmod-fs-ext4 kmod-fs-ntfs
blkid
mount <uuid> /mnt/packages
ln -s /mnt/packages /www/packages
# Upgrade packages
# seed='https://downloads.openwrt.org'
# seed='http://192.168.1.131'
# seed='https://mirrors.zju.edu.cn/openwrt'
# seed='http://mirror.0x.sg/openwrt'
# seed='https://mirrors.ustc.edu.cn/lede'
# seed='https://openwrt.proxy.ustclug.org'
seed='http://127.0.0.1/packages'
sed -i "s|http[s]*://[^/]*|$seed|g" /etc/opkg/distfeeds.conf
# sed -i 's/http:/https:/g' /etc/opkg/distfeeds.conf
opkg update
opkg list-upgradable | cut -f1 -d' ' | xargs opkg upgrade 2>/dev/null
netstat -lpntu
# Base shell
opkg install bash
sed -i 's|/bin/ash|/bin/bash|g' /etc/passwd
sed -i 's|/bin/ash|/bin/bash|g' /usr/libexec/login.sh
# Base network:
uci set network.@device[0].stp=1
uci set network.@device[0].igmp_snooping=1
uci set network.lan.ipaddr=192.168.20.20
uci set network.lan.ip6ifaceid='::20'
uci commit network
ifup lan
# lan port dhcp option
uci add_list dhcp.lan.dhcp_option='6,192.168.20.20,192.168.20.245'
uci add_list dhcp.lan.dhcp_option='44,192.168.20.20'
uci commit dhcp
reservice 'dnsmasq' restart
# set dnsmasq-full
opkg install ip-full iw-full iwinfo
opkg remove dnsmasq && opkg install dnsmasq-full
# dnsmasq custtom conf
#mkdir /etc/dnsmasq.d 2>/dev/null
rm /etc/config/dhcp-opkg
uci set dhcp.@dnsmasq[0].domainneeded=1
uci set dhcp.@dnsmasq[0].filterwin2k=0
uci -q batch <<-EOF >/dev/null
set dhcp.@dnsmasq[0].strictorder=1
set dhcp.@dnsmasq[0].allservers=0
EOF
#uci add_list dhcp.@dnsmasq[0].confdir=/etc/dnsmasq.d
uci commit dhcp
reservice 'dnsmasq' restart
# Firewall
opkg install kmod-tcp-bbr kmod-ipt-offload kmod-nft-offload
uci set firewall.@defaults[0].flow_offloading='1' && uci commit firewall
# Base Hardware:
opkg install amd64-microcode intel-microcode open-vm-tools
# Base tools:
opkg install nano wget-ssl curl ca-certificates ethtool iperf3
# Base LuCI:
uci set luci.languages.en='English'
uci set luci.languages.zh_cn='简体中文 (Chinese Simplified)'
uci set luci.languages.zh_tw='繁體中文 (Chinese Traditional)'
uci set luci.themes.Material='/luci-static/material'
uci set luci.main.lang='en'
# uci set luci.main.lang='zh_cn'
# uci set luci.main.lang='zh_tw'
# uci set luci.main.mediaurlbase='/luci-static/bootstrap'
uci commit luci
opkg install luci luci-compat luci-lib-ipkg luci-theme-material
opkg install luci-mod-dashboard
opkg install luci-i18n-base-zh-cn luci-i18n-package-manager-zh-cn luci-i18n-firewall-zh-cn
opkg install luci-i18n-base-zh-tw luci-i18n-package-manager-zh-tw luci-i18n-firewall-zh-tw
# System Zone:
opkg install zoneinfo-core zoneinfo-simple zoneinfo-asia
# opkg install ntpclient luci-app-ntpc luci-i18n-ntpc-zh-cn
uci set system.@system[0].zonename='Asia/Singapore'
# uci set system.@system[0].zonename='Asia/Shanghai'
# uci set system.@system[0].zonename='Asia/Taipei'
uci set system.@system[0].timezone='<+08>-8'
uci commit system
reservice 'system' restart
opkg update
# RJ45
opkg install kmod-igbvf kmod-ixgbevf kmod-vmxnet3
opkg install kmod-e1000 kmod-e1000e
opkg install kmod-igb kmod-ixgbe
opkg install kmod-igc # I225
# opkg install kmod-i40e
# VLAN
opkg install kmod-macvlan
# SATA
opkg install kmod-ata-core # sata协议的支持
opkg install kmod-ata-ahci # sata协议的支持
opkg install kmod-ata-marvell-sata
# SCSI
opkg install kmod-scsi-core kmod-scsi-generic
opkg install kmod-mvsas
# USB
opkg install usbutils # USB 实用程序
opkg install kmod-usb-core
opkg install kmod-usb-uhci
opkg install kmod-usb-ohci kmod-usb-ohci-pci
opkg install kmod-usb-ehci kmod-usb2 kmod-usb2-pci
opkg install kmod-usb3
# USB Storage
opkg install kmod-usb-storage # 对不需要TRIM的普通U盘和移动硬盘的支持
opkg install kmod-usb-storage-uas # 对USB固态的支持(UASP协议跟trim有关系)
opkg install kmod-usb-storage-extras
# SD CARD
opkg install kmod-sdhci kmod-mmc
opkg update
# nftables compatibility
opkg install arptables-nft ebtables-nft iptables-nft xtables-nft ip6tables-nft
# Protocol
opkg install luci-proto-ppp ppp-mod-pppoe ppp-mod-pppol2tp ppp-mod-pptp ppp-mod-radius pppoe-discovery
opkg install luci-proto-ipv6 6in4 6to4 6rd ds-lite map # Dual-Stack Lite and Lightweight 4over6
opkg install ipsec-tools iptables-mod-ipsec kmod-ipsec4 ppp-mod-passwordfd xl2tpd
opkg install 464xlat #
opkg install luci-proto-bonding
opkg install luci-proto-relay
opkg install luci-proto-vxlan
opkg update
# FileSystem
opkg install blockd mount-utils swap-utils # mount相关命令,开启luci界面“挂载点”功能
opkg install lsblk blkid cfdisk cgdisk fixparts parted # 分区与扫描修复工具
opkg install kmod-fs-vfat dosfstools # 支持 FAT12/16/32
opkg install kmod-fs-exfat exfat-mkfs exfat-fsck # 支持 exFAT;目前,驱动不是微软的,仍可以凑合用,微软的那份驱动在 Linux 5.4 内核里才有,Linux 5.7 后改为了更可靠的三星驱动;机械硬盘用户注意,exFAT文件系统只有一份文件分配表,FAT32则有两份
opkg install kmod-fs-ext4 badblocks # 支持 ext4;注意,ext3是最垃圾的文件系统之一,永远不要格式化为ext3
opkg install kmod-fs-f2fs f2fs-tools
opkg install kmod-fs-squashfs
# opkg install kmod-fs-btrfs kmod-fs-xfs kmod-fs-jfs kmod-fs-reiserfs
# opkg install kmod-fs-ntfs
opkg install ntfs-3g # 用户态的 NTFS 驱动,虽然速度不如kmod-fs-ntfs快,但是经过了大量的使用和验证,非常可靠;最好别挂Windows系统盘
# opkg install ntfs-3g-utils # NTFS 实用程序
# opkg install e2fsprogs # 不知道是啥的就不要装。可选,对 ext2/3/4 文件系统进行格式化、扩展、修复等等的命令
# Native Language Support
opkg install kmod-fs-msdos
opkg install kmod-nls-base
opkg install kmod-nls-utf8
opkg install kmod-nls-cp932 # Shift_JIS
opkg install kmod-nls-cp936 # GB2312
opkg install kmod-nls-cp950 # Big5
# Archive Support
opkg install unzip gzip tar bzip2 xz lzmainfo zstd
# Image associated
opkg install coreutils-dd coreutils-truncate losetup parted resize2fs lsblk coreutils-df qemu-img
opkg update
# Tools:
opkg install lscpu htop atop iftop pciutils kmod-ikconfig
opkg install coreutils-base64 coreutils-sha1sum coreutils-stat getopt jq
opkg install speedtest-go
# Net Tools:
opkg install ethtool arp-scan arp-scan-database bind-tools knot-dig
opkg install wget-ssl curl iperf3 pppoe-discovery
opkg install netdata-ssl
# Usb NIC
opkg install wpad #hostapd #wpa-supplicant
opkg install kmod-usb-net usb-modeswitch # usb network base
opkg install kmod-usb-net-rndis # RNDIS USB Dongle
opkg install kmod-usb-net-ipheth usbmuxd # usb network smartphone
opkg install kmod-usb-net-asix kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8150 kmod-usb-net-rtl8152 kmod-usb-net-dm9601-ether # usb network RJ45 adapter
opkg install iw-full iwinfo kmod-ath9k kmod-ath9k-htc kmod-mt76x2u kmod-mt76x0u kmod-rtl8812au-ct kmod-mt7921e kmod-mt7922-firmware mt7922bt-firmware # usb network wireless adapter
# Intel,Atheros > MediaTek,RealTek
#
# ath9k/ath9k_htc:
# AR9002U/AR9271L
# TL-WN722N-v1
# mt76:
# --MT7610U
# USB-AC50 - Asus
# USB-AC51 - Asus
# CF-923AC - COMFAST
# TL-WDN5200 - TP-Link
# --MT7612U
# AC6210 - Netgear
# CF-926AC - COMFAST
# rtl8812au:
# --RTL8811AU
# AC6100 - Netgear
# --RTL8812AU
# USB-AC56 - Asus
# TL-WDN6200 - TP-Link
# RTL8814AU
# AC7000 - Netgear 600+1300Mbps 3x4MIMO
# USB-AC68 - Asus 600+1300Mbps 3x4MIMO 18~22dBm
# --CF-917AC - COMFAST
# CF-939AC - COMFAST 600+1300Mbps 3x4MIMO 18dBm
# TL-WDN7200H - TP-Link
# ASUS USB-AC57 A1 rtl8822bu RTL8812BU
# QCA9880 BR4A OR ar9380
#
# CF-811AC RTL8811CU
# CF-812AC RTL8812BU
# CF-926AC-V2 RTL7612U
# CF-913AC-V2 RTL8812BU
opkg install kmod-usb-serial kmod-usb-serial-option kmod-usb-serial-wwan usb-modeswitch # Add support for PC Interface (ttyUSB0)
opkg install comgt-ncm kmod-usb-net-cdc-ncm kmod-usb-net-huawei-cdc-ncm luci-proto-ncm # usb network NCM USB Dongle
opkg install comgt kmod-usb-acm luci-proto-3g # usb network 3g/UMTS USB Dongle
opkg install kmod-usb-net-qmi-wwan uqmi luci-proto-qmi # usb network LTE modem in QMI mode
opkg install kmod-usb-net-cdc-mbim umbim # usb network LTE modem in MBIM mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment