From b76160a12ee70155881a0f254a5bb4c308912c57 Mon Sep 17 00:00:00 2001 From: Pdboy Sir <63764630+sirpdboy@users.noreply.github.com> Date: Fri, 15 Mar 2024 16:55:11 +0800 Subject: [PATCH] =?UTF-8?q?up=20=20luci-app-adguardhome=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=B1=89=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luasrc/controller/AdGuardHome.lua | 20 +- .../luasrc/model/cbi/AdGuardHome/base.lua | 2 +- .../luasrc/model/cbi/AdGuardHome/log.lua | 2 +- .../luasrc/model/cbi/AdGuardHome/manual.lua | 21 +- luci-app-adguardhome/po/zh-cn/AdGuardHome.po | 303 ++++++++++++++++++ .../po/zh_Hans/AdGuardHome.po | 303 ++++++++++++++++++ .../root/etc/init.d/AdGuardHome | 18 +- 7 files changed, 636 insertions(+), 33 deletions(-) create mode 100644 luci-app-adguardhome/po/zh-cn/AdGuardHome.po create mode 100644 luci-app-adguardhome/po/zh_Hans/AdGuardHome.po diff --git a/luci-app-adguardhome/luasrc/controller/AdGuardHome.lua b/luci-app-adguardhome/luasrc/controller/AdGuardHome.lua index bd751d1..468e6a7 100644 --- a/luci-app-adguardhome/luasrc/controller/AdGuardHome.lua +++ b/luci-app-adguardhome/luasrc/controller/AdGuardHome.lua @@ -21,11 +21,13 @@ end function get_template_config() local b local d="" - for cnt in io.lines("/tmp/resolv.conf.d/resolv.conf.auto") do - b=string.match (cnt,"^[^#]*nameserver%s+([^%s]+)$") - if (b~=nil) then - d=d.." - "..b.."\n" - end + local file = "/tmp/resolv.conf.d/resolv.conf.auto" + if not fs.access(file) then + file = "/tmp/resolv.conf.auto" + end + for cnt in io.lines(file) do + b = string.match(cnt, "^[^#]*nameserver%s+([^%s]+)$") + if (b ~= nil) then d = d .. " - " .. b .. "\n" end end local f=io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+") local tbl = {} @@ -92,13 +94,7 @@ function get_log() return end http.prepare_content("text/plain; charset=utf-8") - local fdp - if fs.access("/var/run/lucilogreload") then - fdp=0 - fs.remove("/var/run/lucilogreload") - else - fdp=tonumber(fs.readfile("/var/run/lucilogpos")) or 0 - end + local fdp = tonumber(fs.readfile("/var/run/lucilogpos")) or 0 local f=io.open(logfile, "r+") f:seek("set",fdp) local a=f:read(2048000) or "" diff --git a/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua b/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua index e659c94..0bd2444 100644 --- a/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua +++ b/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua @@ -54,7 +54,7 @@ o = s:option(Button, "restart", translate("Upgrade Core")) o.inputtitle=translate("Update core version") o.template = "AdGuardHome/AdGuardHome_check" o.showfastconfig=(not fs.access(configpath)) -o.description=string.format(translate("core version:").."%s ",e) +o.description = string.format(translate("Current core version:") .. "%s ", e) ---- port warning not safe local port=luci.sys.exec("awk '/ port:/{printf($2);exit;}' "..configpath.." 2>nul") if (port=="") then port="?" end diff --git a/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/log.lua b/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/log.lua index 754311a..2581ade 100644 --- a/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/log.lua +++ b/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/log.lua @@ -12,5 +12,5 @@ t.readonly="readonly" local logfile=uci:get("AdGuardHome","AdGuardHome","logfile") or "" t.timereplace=(logfile~="syslog" and logfile~="" ) t.pollcheck=logfile~="" -fs.writefile("/var/run/lucilogreload","") +fs.writefile("/var/run/lucilogpos", "0") return f diff --git a/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/manual.lua b/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/manual.lua index 180a10c..11d8a0c 100644 --- a/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/manual.lua +++ b/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/manual.lua @@ -8,11 +8,13 @@ require("table") function gen_template_config() local b local d="" - for cnt in io.lines("/tmp/resolv.conf.d/resolv.conf.auto") do - b=string.match (cnt,"^[^#]*nameserver%s+([^%s]+)$") - if (b~=nil) then - d=d.." - "..b.."\n" - end + local file = "/tmp/resolv.conf.d/resolv.conf.auto" + if not fs.access(file) then + file = "/tmp/resolv.conf.auto" + end + for cnt in io.lines(file) do + b = string.match(cnt, "^[^#]*nameserver%s+([^%s]+)$") + if (b ~= nil) then d = d .. " - " .. b .. "\n" end end local f=io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+") local tbl = {} @@ -48,9 +50,7 @@ end o.validate=function(self, value) fs.writefile("/tmp/AdGuardHometmpconfig.yaml", value:gsub("\r\n", "\n")) if fs.access(binpath) then - if (sys.call(binpath.." -c /tmp/AdGuardHometmpconfig.yaml --check-config 2> /tmp/AdGuardHometest.log")==0) then - return value - end + if (sys.call(binpath .. " -c /tmp/AdGuardHometmpconfig.yaml --check-config 2> /tmp/AdGuardHometest.log") == 0) then return value end else return value end @@ -60,9 +60,8 @@ end o.write = function(self, section, value) fs.move("/tmp/AdGuardHometmpconfig.yaml",configpath) end -o.remove = function(self, section, value) - fs.writefile(configpath, "") -end +o.remove = function(self, section, value) fs.writefile(configpath, "") end + --- js and reload button o = s:option(DummyValue, "") o.anonymous=true diff --git a/luci-app-adguardhome/po/zh-cn/AdGuardHome.po b/luci-app-adguardhome/po/zh-cn/AdGuardHome.po new file mode 100644 index 0000000..f4e9da6 --- /dev/null +++ b/luci-app-adguardhome/po/zh-cn/AdGuardHome.po @@ -0,0 +1,303 @@ +#/cgi-bin/luci/admin/services/AdGuardHome +msgid "Base Setting" +msgstr "基础设置" + +msgid "Log" +msgstr "日志" + +msgid "AdGuardHome's version" +msgstr "AdGuardHome 版本" + +msgid "Needed to click 'save&apply' to generate the configuration file" +msgstr "需要点击“保存并应用”才能生成配置文件" + +msgid "In case of the latest realease is a source code that can not download the binary file" +msgstr "防止最新release只有源码,导致下载不成功" + +msgid "Manual Config" +msgstr "手动设置" + +msgid "Free and open source, powerful network-wide ads & trackers blocking DNS server." +msgstr "全网络广告和跟踪程序拦截DNS服务器,默认账号和密码均为:admin" + +msgid "RUNNING" +msgstr "运行中" + +msgid "NOT RUNNING" +msgstr "未运行" + +msgid "Redirected" +msgstr "已重定向" + +msgid "Not redirect" +msgstr "未重定向" + +msgid "Collecting data..." +msgstr "获取数据中..." + +msgid "Enable" +msgstr "启用" + +msgid "Browser management port" +msgstr "网页管理账号和密码:admin ,端口:" + +msgid "Upgrade Core" +msgstr "更新核心" + +#button change +msgid "Update core version" +msgstr "更新核心版本" + +msgid "Check..." +msgstr "检查中..." + +msgid "Updated" +msgstr "已更新" + +#button hide +msgid "Force update" +msgstr "强制更新核心" + +msgid "Fast config" +msgstr "快速配置" + +msgid "Core Version" +msgstr "核心版本" + +msgid "Latest Version" +msgstr "最新版" + +msgid "Beta Version" +msgstr "测试版" + +msgid "Current core version:" +msgstr "当前核心版本:" + +msgid "core version:" +msgstr "核心版本:" + +msgid "no config" +msgstr "没有配置文件" + +msgid "no core" +msgstr "没有核心" + +# +msgid "Redirect" +msgstr "重定向" + +#inlist +msgid "none" +msgstr "无" + +msgid "Run as dnsmasq upstream server" +msgstr "作为dnsmasq的上游服务器" + +msgid "Redirect 53 port to AdGuardHome" +msgstr "重定向53端口到AdGuardHome" + +msgid "Use port 53 replace dnsmasq" +msgstr "使用53端口替换dnsmasq" + +# +msgid "AdGuardHome redirect mode" +msgstr "AdGuardHome重定向模式" + +msgid "Bin Path" +msgstr "执行文件路径" + +msgid "AdGuardHome Bin path if no bin will auto download" +msgstr "AdGuardHome 执行文件路径 如果没有执行文件将自动下载" + +msgid "use upx to compress bin after download" +msgstr "下载后使用upx压缩执行文件" + +#inlist +msgid "compress faster" +msgstr "快速压缩" + +msgid "compress better" +msgstr "更好的压缩" + +msgid "compress best(can be slow for big files)" +msgstr "最好的压缩(大文件可能慢)" + +msgid "try all available compression methods & filters [slow]" +msgstr "尝试所有可能的压缩方法和过滤器[慢]" + +msgid "try even more compression variants [very slow]" +msgstr "尝试更多变体压缩手段[很慢]" + +msgid "bin use less space,but may have compatibility issues" +msgstr "减小执行文件空间占用,但是可能压缩后有兼容性问题" +# +msgid "Config Path" +msgstr "配置文件路径" + +msgid "AdGuardHome config path" +msgstr "AdGuardHome 配置文件路径" + +msgid "Work dir" +msgstr "工作目录" + +msgid "AdGuardHome work dir include rules,audit log and database" +msgstr "AdGuardHome 工作目录包含规则,审计日志和数据库" + +msgid "Runtime log file" +msgstr "运行日志路径" + +msgid "AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log" +msgstr "AdGuardHome 运行日志, 如果填 syslog 将写入系统日志; 如果该项为空则不记录运行日志" + +msgid "Verbose log" +msgstr "输出详细日志" + +#hide div +msgid "Add gfwlist" +msgstr "添加 GFW 列表" + +msgid "Add" +msgstr "添加" + +msgid "Added" +msgstr "已添加" + +msgid "Not added" +msgstr "未添加" + +#hide div +msgid "Del gfwlist" +msgstr "删除gfw列表" + +msgid "Del" +msgstr "删除" + +#hide div +msgid "Gfwlist upstream dns server" +msgstr "gfw列表上游服务器" + +msgid "Gfwlist domain upstream dns service" +msgstr "gfw列表域名上游服务器" + +#hide div +msgid "Change browser management password" +msgstr "更改网页登录密码" + +msgid "Culculate" +msgstr "计算" + +##button change +msgid "Load culculate model" +msgstr "载入计算模块" + +msgid "loading..." +msgstr "载入中" + +msgid "Please save/apply" +msgstr "请点击[保存/应用]" + +msgid "is empty" +msgstr "为空" + +msgid "Press load culculate model and culculate finally save/apply" +msgstr "先输入你想要的密码, 点击[载入计算模块], 然后点击[计算], 最后点击下方[保存&应用]" + +# +msgid "Keep files when system upgrade" +msgstr "系统升级时保留文件" + +#checkbox +msgid "core bin" +msgstr "核心执行文件" + +msgid "config file" +msgstr "配置文件" + +msgid "log file" +msgstr "日志文件" + +msgid "querylog.json" +msgstr "审计日志.json" + +# +msgid "On boot when network ok restart" +msgstr "开机后网络准备好时重启" + +msgid "Backup workdir files when shutdown" +msgstr "在关机时备份工作目录文件" + +msgid "Will be restore when workdir/data is empty" +msgstr "在工作目录/data为空的时候恢复" + +msgid "Backup workdir path" +msgstr "工作目录备份路径" + +msgid "Crontab task" +msgstr "计划任务" + +msgid "Auto update core" +msgstr "自动升级核心" + +msgid "Auto tail querylog" +msgstr "自动截短查询日志" + +msgid "Auto tail runtime log" +msgstr "自动截短运行日志" + +msgid "Auto update ipv6 hosts and restart adh" +msgstr "自动更新ipv6主机并重启adh" + +msgid "Auto update gfwlist and restart adh" +msgstr "自动更新gfw列表并重启adh" + +msgid "Please change time and args in crontab" +msgstr "请在计划任务中修改时间和参数" + +msgid "Core Update URL" +msgstr "核心更新地址" + +#/cgi-bin/luci/admin/services/AdGuardHome/log/ +msgid "reverse" +msgstr "逆序" + +msgid "localtime" +msgstr "本地时间" + +msgid "Please add log path in config to enable log" +msgstr "请在设置里填写日志路径以启用日志" + +msgid "dellog" +msgstr "删除日志" + +msgid "download log" +msgstr "下载日志" + +#/cgi-bin/luci//admin/services/AdGuardHome/manual/ +msgid "Use template" +msgstr "使用模板" + +#hide button +msgid "Reload Config" +msgstr "重新载入配置" + +msgid "WARNING!!! no bin found apply config will not be test" +msgstr "警告!!!未找到执行文件,提交配置将不会进行校验" + +#unused +msgid "Change browser management username" +msgstr "改变网页登录用户名" + +msgid "Username" +msgstr "用户名" + +msgid "Check Config" +msgstr "检查配置" + +msgid "unknown" +msgstr "未知" + +msgid "Keep database when system upgrade" +msgstr "系统升级时保留数据" + +msgid "Boot delay until network ok" +msgstr "开机时直到网络准备好再启动" \ No newline at end of file diff --git a/luci-app-adguardhome/po/zh_Hans/AdGuardHome.po b/luci-app-adguardhome/po/zh_Hans/AdGuardHome.po new file mode 100644 index 0000000..f4e9da6 --- /dev/null +++ b/luci-app-adguardhome/po/zh_Hans/AdGuardHome.po @@ -0,0 +1,303 @@ +#/cgi-bin/luci/admin/services/AdGuardHome +msgid "Base Setting" +msgstr "基础设置" + +msgid "Log" +msgstr "日志" + +msgid "AdGuardHome's version" +msgstr "AdGuardHome 版本" + +msgid "Needed to click 'save&apply' to generate the configuration file" +msgstr "需要点击“保存并应用”才能生成配置文件" + +msgid "In case of the latest realease is a source code that can not download the binary file" +msgstr "防止最新release只有源码,导致下载不成功" + +msgid "Manual Config" +msgstr "手动设置" + +msgid "Free and open source, powerful network-wide ads & trackers blocking DNS server." +msgstr "全网络广告和跟踪程序拦截DNS服务器,默认账号和密码均为:admin" + +msgid "RUNNING" +msgstr "运行中" + +msgid "NOT RUNNING" +msgstr "未运行" + +msgid "Redirected" +msgstr "已重定向" + +msgid "Not redirect" +msgstr "未重定向" + +msgid "Collecting data..." +msgstr "获取数据中..." + +msgid "Enable" +msgstr "启用" + +msgid "Browser management port" +msgstr "网页管理账号和密码:admin ,端口:" + +msgid "Upgrade Core" +msgstr "更新核心" + +#button change +msgid "Update core version" +msgstr "更新核心版本" + +msgid "Check..." +msgstr "检查中..." + +msgid "Updated" +msgstr "已更新" + +#button hide +msgid "Force update" +msgstr "强制更新核心" + +msgid "Fast config" +msgstr "快速配置" + +msgid "Core Version" +msgstr "核心版本" + +msgid "Latest Version" +msgstr "最新版" + +msgid "Beta Version" +msgstr "测试版" + +msgid "Current core version:" +msgstr "当前核心版本:" + +msgid "core version:" +msgstr "核心版本:" + +msgid "no config" +msgstr "没有配置文件" + +msgid "no core" +msgstr "没有核心" + +# +msgid "Redirect" +msgstr "重定向" + +#inlist +msgid "none" +msgstr "无" + +msgid "Run as dnsmasq upstream server" +msgstr "作为dnsmasq的上游服务器" + +msgid "Redirect 53 port to AdGuardHome" +msgstr "重定向53端口到AdGuardHome" + +msgid "Use port 53 replace dnsmasq" +msgstr "使用53端口替换dnsmasq" + +# +msgid "AdGuardHome redirect mode" +msgstr "AdGuardHome重定向模式" + +msgid "Bin Path" +msgstr "执行文件路径" + +msgid "AdGuardHome Bin path if no bin will auto download" +msgstr "AdGuardHome 执行文件路径 如果没有执行文件将自动下载" + +msgid "use upx to compress bin after download" +msgstr "下载后使用upx压缩执行文件" + +#inlist +msgid "compress faster" +msgstr "快速压缩" + +msgid "compress better" +msgstr "更好的压缩" + +msgid "compress best(can be slow for big files)" +msgstr "最好的压缩(大文件可能慢)" + +msgid "try all available compression methods & filters [slow]" +msgstr "尝试所有可能的压缩方法和过滤器[慢]" + +msgid "try even more compression variants [very slow]" +msgstr "尝试更多变体压缩手段[很慢]" + +msgid "bin use less space,but may have compatibility issues" +msgstr "减小执行文件空间占用,但是可能压缩后有兼容性问题" +# +msgid "Config Path" +msgstr "配置文件路径" + +msgid "AdGuardHome config path" +msgstr "AdGuardHome 配置文件路径" + +msgid "Work dir" +msgstr "工作目录" + +msgid "AdGuardHome work dir include rules,audit log and database" +msgstr "AdGuardHome 工作目录包含规则,审计日志和数据库" + +msgid "Runtime log file" +msgstr "运行日志路径" + +msgid "AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log" +msgstr "AdGuardHome 运行日志, 如果填 syslog 将写入系统日志; 如果该项为空则不记录运行日志" + +msgid "Verbose log" +msgstr "输出详细日志" + +#hide div +msgid "Add gfwlist" +msgstr "添加 GFW 列表" + +msgid "Add" +msgstr "添加" + +msgid "Added" +msgstr "已添加" + +msgid "Not added" +msgstr "未添加" + +#hide div +msgid "Del gfwlist" +msgstr "删除gfw列表" + +msgid "Del" +msgstr "删除" + +#hide div +msgid "Gfwlist upstream dns server" +msgstr "gfw列表上游服务器" + +msgid "Gfwlist domain upstream dns service" +msgstr "gfw列表域名上游服务器" + +#hide div +msgid "Change browser management password" +msgstr "更改网页登录密码" + +msgid "Culculate" +msgstr "计算" + +##button change +msgid "Load culculate model" +msgstr "载入计算模块" + +msgid "loading..." +msgstr "载入中" + +msgid "Please save/apply" +msgstr "请点击[保存/应用]" + +msgid "is empty" +msgstr "为空" + +msgid "Press load culculate model and culculate finally save/apply" +msgstr "先输入你想要的密码, 点击[载入计算模块], 然后点击[计算], 最后点击下方[保存&应用]" + +# +msgid "Keep files when system upgrade" +msgstr "系统升级时保留文件" + +#checkbox +msgid "core bin" +msgstr "核心执行文件" + +msgid "config file" +msgstr "配置文件" + +msgid "log file" +msgstr "日志文件" + +msgid "querylog.json" +msgstr "审计日志.json" + +# +msgid "On boot when network ok restart" +msgstr "开机后网络准备好时重启" + +msgid "Backup workdir files when shutdown" +msgstr "在关机时备份工作目录文件" + +msgid "Will be restore when workdir/data is empty" +msgstr "在工作目录/data为空的时候恢复" + +msgid "Backup workdir path" +msgstr "工作目录备份路径" + +msgid "Crontab task" +msgstr "计划任务" + +msgid "Auto update core" +msgstr "自动升级核心" + +msgid "Auto tail querylog" +msgstr "自动截短查询日志" + +msgid "Auto tail runtime log" +msgstr "自动截短运行日志" + +msgid "Auto update ipv6 hosts and restart adh" +msgstr "自动更新ipv6主机并重启adh" + +msgid "Auto update gfwlist and restart adh" +msgstr "自动更新gfw列表并重启adh" + +msgid "Please change time and args in crontab" +msgstr "请在计划任务中修改时间和参数" + +msgid "Core Update URL" +msgstr "核心更新地址" + +#/cgi-bin/luci/admin/services/AdGuardHome/log/ +msgid "reverse" +msgstr "逆序" + +msgid "localtime" +msgstr "本地时间" + +msgid "Please add log path in config to enable log" +msgstr "请在设置里填写日志路径以启用日志" + +msgid "dellog" +msgstr "删除日志" + +msgid "download log" +msgstr "下载日志" + +#/cgi-bin/luci//admin/services/AdGuardHome/manual/ +msgid "Use template" +msgstr "使用模板" + +#hide button +msgid "Reload Config" +msgstr "重新载入配置" + +msgid "WARNING!!! no bin found apply config will not be test" +msgstr "警告!!!未找到执行文件,提交配置将不会进行校验" + +#unused +msgid "Change browser management username" +msgstr "改变网页登录用户名" + +msgid "Username" +msgstr "用户名" + +msgid "Check Config" +msgstr "检查配置" + +msgid "unknown" +msgstr "未知" + +msgid "Keep database when system upgrade" +msgstr "系统升级时保留数据" + +msgid "Boot delay until network ok" +msgstr "开机时直到网络准备好再启动" \ No newline at end of file diff --git a/luci-app-adguardhome/root/etc/init.d/AdGuardHome b/luci-app-adguardhome/root/etc/init.d/AdGuardHome index a350655..32ab310 100644 --- a/luci-app-adguardhome/root/etc/init.d/AdGuardHome +++ b/luci-app-adguardhome/root/etc/init.d/AdGuardHome @@ -5,6 +5,8 @@ USE_PROCD=1 START=95 STOP=01 +ipt=$(command -v iptables-legacy || command -v iptables) +ip6t=$(command -v ip6tables-legacy || command -v ip6tables) CONFIGURATION=AdGuardHome CRON_FILE=/etc/crontabs/root EXTRA_COMMANDS="do_redirect testbackup test_crontab force_reload isrunning" @@ -76,9 +78,9 @@ EOF for IP in $IPS do if [ "$tcp_server" == "1" ]; then - iptables -t nat -A PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1 + $ipt -t nat -A PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1 fi - iptables -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1 + $ipt -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1 done if [ "$ipv6_server" == 0 ]; then @@ -89,9 +91,9 @@ EOF for IP in $IPS do if [ "$tcp_server" == "1" ]; then - ip6tables -t nat -A PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1 + $ipt -t nat -A PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1 fi - ip6tables -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1 + $ipt -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1 done } @@ -106,8 +108,8 @@ EOF IPS="`ifconfig | grep "inet addr" | grep -v ":127" | grep "Bcast" | awk '{print $2}' | awk -F : '{print $2}'`" for IP in $IPS do - iptables -t nat -D PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1 - iptables -t nat -D PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1 + $ipt -t nat -D PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1 + $ipt -t nat -D PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1 done if [ "$ipv6_server" == 0 ]; then @@ -117,8 +119,8 @@ EOF IPS="`ifconfig | grep "inet6 addr" | grep -v " fe80::" | grep -v " ::1" | grep "Global" | awk '{print $3}'`" for IP in $IPS do - ip6tables -t nat -D PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1 - ip6tables -t nat -D PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1 + $ipt -t nat -D PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1 + $ipt -t nat -D PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1 done }