Logrotate не сжимается

Проблема решена! Я выполнял только следующую команду одиночного сброса:

sudo iptables -F

Следовательно, я не сбрасывал все правила iptables, например. НАТ.

Итак, у меня была эта путаница с дубликатами PREROUTING и POSTROUTING:

$ sudo iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:192.168.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:192.168.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:192.168.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:192.168.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:192.168.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:192.168.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:192.168.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:172.22.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:172.22.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:172.22.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:172.22.0.99:8080
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:172.22.0.99:8080

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere
MASQUERADE  all  --  anywhere             anywhere

Как только я начал использовать следующее перед созданием своих правил, это сработало (никаких других изменений):

sudo iptables -F
sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -t mangle -F
sudo iptables -t mangle -X

sudo ipset flush
sudo ipset destroy
sudo ipset list

Видимо, мне тоже следует:

sudo iptables -t raw -F 
sudo iptables -t raw -X

Теперь у меня есть:

$ sudo iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http-alt to:172.22.0.99:8080

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
MASQUERADE  all  --  anywhere             anywhere

Итак, теперь, если я подключусь к беспроводной точке доступа Pi по адресу 172.24.1.1 (wlan0 )и получу IP-адрес 172.24.1.x, я смогу получить доступ к веб-серверу Domoticz на Pi через http://172.24.1.1:8080, который это то, что я хочу.

Раньше мне приходилось проходить через отдельный маршрутизатор (172.22.0.1 ), получать IP-адрес 172.22.0.x и получать доступ к Pi через eth0:http://172.22.0.99:8080.

0
25.03.2019, 12:34
1 ответ

Судя по тому, что я вижу, logrotate запутался. Во-первых, вы должны быть более строгими с вашим шаблоном имени. Вместо вращения /var/log/remots/*/*следует вращать:

/var/log/remots/*/*.log {
    rotate 178
    daily
    maxage 178
    compress
}

При изменении конфигурации не забудьте проверить /var/lib/logrotate/status. Удалите все записи для файлов .*gz.


Менее распространено смешивание logrotate с программами, меняющими собственные журналы. Вы настроили rsyslog для записи в устаревшие файлы журналов. Чаще используется статическое имя файла и позволяет logrotate добавлять даты за вас. Я заметил, что у других были проблемы с тем же типом настройки :https://stackoverflow.com/questions/8962477/logrotate-files-with-date-in-the-file-name

.

Более простой способ настроить это — записать журнал «remots» (rsyslog )в статическое место, например:

$template GuardaRemots, "/var/log/remots/%HOSTNAME%.log"
:source, !isequal, "localhost" -? GuardaRemots

Затем поверните:

/var/log/remots/*.log {
    rotate 178
    daily
    maxage 178
    compress
}

Logrotate будет автоматически добавлять дату при ротации.

2
28.01.2020, 02:30

Теги

Похожие вопросы