zw963 / asuswrt-merlin-transparent-proxy

transparent proxy base on ss, v2ray, xray, ipset, iptables, chinadns on asuswrt merlin or side router.
MIT License
380 stars 80 forks source link

`dnsmasq.log` eats all the disk space of `/tmp` #96

Closed kfstorm closed 4 years ago

kfstorm commented 4 years ago

Sometimes the DNS lookup just doesn't work. I found that dnsmasq.log is too big that there's no disk space left in /tmp.

admin@RT-AC68U-64C0:/tmp/home/root# dig github.com

; <<>> DiG 9.14.4 <<>> github.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 20363
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;github.com.                    IN      A

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun Dec 15 04:22:58 UTC 2019
;; MSG SIZE  rcvd: 39
admin@RT-AC68U-64C0:/tmp/mnt/sda1/entware/etc# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                32.5M     32.5M         0 100% /
devtmpfs                124.7M         0    124.7M   0% /dev
df: /tmp: Value too large for defined data type
/dev/mtdblock4           62.8M      1.9M     60.9M   3% /jffs
/dev/sda1                 7.3G      1.5G      5.5G  21% /tmp/mnt/sda1
admin@RT-AC68U-64C0:/tmp/var/log# ll
-rw-rw-rw-    1 admin    root            11 May  5  2018 commit_ret
-rw-r-----    1 nobody   root     129507328 Dec 11 22:32 dnsmasq.log

Try to run patch_router:

admin@RT-AC68U-64C0:/tmp/mnt/sda1/entware/etc# ./patch_router
 Shutting down v2ray...              done.
 Starting v2ray...              done.
echo: write error: No space left on device
echo: write error: No space left on device
echo: write error: No space left on device
dnsmasq: syntax check OK.
Apply ipset rule ...
...

After I deleted the dnsmasq.log file:

admin@RT-AC68U-64C0:/tmp/var/log# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                32.5M     32.5M         0 100% /
devtmpfs                124.7M         0    124.7M   0% /dev
tmpfs                   124.8M      1.2M    123.6M   1% /tmp
/dev/mtdblock4           62.8M      1.9M     60.8M   3% /jffs
/dev/sda1                 7.3G      1.5G      5.5G  21% /tmp/mnt/sda1

And patch_router succeeds.

zw963 commented 4 years ago

Sorry for that, i never missing this issue, because i reboot every day.

image

maybe we can change to truncate log every day or not output log.

kfstorm commented 4 years ago

I commented below code and the disk space issue is fixed.

    # # 开启日志.
    # if ! grep -qs "^log-queries$" /etc/dnsmasq.conf; then
    #     echo 'log-queries' >> /etc/dnsmasq.conf
    # fi

    # # 输出日志到 /var/log/dnsmasq.log
    # if ! grep -qs "^log-facility=/var/log/dnsmasq\.log$" /etc/dnsmasq.conf; then
    #     echo 'log-facility=/var/log/dnsmasq.log' >> /etc/dnsmasq.conf
    # fi

But now the logs go to 系统记录 - 一般记录文件 of the router admin portal.

zw963 commented 4 years ago

Fixed by 65253f0.