FortiGate環境で”This Connection is Invalid. SSL certificate expired.”を食らった


会社からアクセスしてみたようとしたら「This Connection is Invalid. SSL certificate expired.」というエラーがでてアクセスできなかった。

最初、サーバ側の問題なのかと思って調査を開始したところletsencrypt.orgにアクセスした場合にも同じエラーが・・・

さすがにこれはおかしいな、とスマホからLTE回線で確認してみたらどちらもアクセス可能。

これは???と思ってよくよくエラー内容を見直してみる…

FortiNetのアイコンじゃん

というわけで対処方法がFortiNetのページにありました「Fortinet and Expiring Let’s Encrypt Certificates

上記記載の内容を下記に引用する。

Workaround 1 – Prevent fallback to the expired Root CA

With the removal of the expired IdenTrust DST Root CA X3 in Certificate Bundle version 1.28, it is possible to prevent fallback to the expired root CA by blocking FortiGate access to apps.identrust.com, resulting in the correct root CA being used. This can be achieved by using either DNS blackholing or via an FQDN policy to block access to apps.identrust.com.

This will force the FortiGate device to rebuild the certificate chain and find the ISRC Root X1 Root CA Cert in the local certificate in the store.

config system dns-database
    edit "1"
        set domain "identrust.com"
        config dns-entry
            edit 1
                set hostname "apps"
                set ip 127.0.0.1
            next
        end
    next
end

Workaround 2 – Accept the expired certificates

For third-party sites outside of your control, customers can turn off this certificate expiration validation using the following CLI as a temporary workaround:

config firewall ssl-ssh-profile
  edit "certificate-inspection"
    config https
      set expired-server-cert allow 
      set untrusted-server-cert allow
end

FortiGateのコマンドで、期限切れとなっている証明書の取り扱い手法を変える、というものになっている。

今後のFortiGateの新firmwareで、もうちょっとスマートな回避方法の提供を計画しているとのこと。

今回の問題について、該当環境の管理者に確認したところworkaround2の手法で対処した、とのこと。

NanoPi R2S+OpenWRT 21.02.0でBIGLOBEのMAP-E接続


5月に「NanoPi R2S+openWRT 21.02.0RCでBIGLOBEのMAP-E接続」にてOpenWRT 21.02.0-RC版での手順を作成した。

しかし、OpenWRT 21.02.0リリース版になってみると、いろいろ設定画面が変更となり、この手順のままでは動作させることができなかった。

ぐぐってみたところ「OpenWrt(21.02)でIPv6インターネットを使う」に手順があったので、参考にしつつ手順を更新した。

前書き

OpenWRTルータを作成するにあたり、いろいろある選択肢からRockchip RK3328のNanoPi R2S と Rockchip RK3399のNanoPi R4S を候補にあげた。

Amazon日本の倉庫に在庫があるというのと、openWRTのページに「FriendlyARM NanoPi R2S」とデバイスに関する個別ページが作成されており、リリース版の提供がされていたので、NanoPi R2Sを買って設定を行った。

ちなみに置き換え対象となったGL-MV1000とのサイズ比較はこんな感じ

OpenWRT 21.02.0-RC版の時代はアップグレードしたら以前の設定を残しておくと起動しなくなるとか問題もありましたが、OpenWRT 21.02.0リリース版を書き込んだあと設定復旧で動作させることができました。

設定手順0: MicroSD作成

friendlyarm_nanopi-r2s-squashfs-sysupgrade.img.gz を展開したものをmicroSDに書き込んでNanoPi R2Sを起動。

設定手順1:パッケージの追加

mapパッケージと日本語UIパッケージ(luci-i18n-base-ja)をインストール

また、後述のニチバン対策を行う場合は iptables-mod-ipopt もインストールする。

GUIの場合、[システム]-[Software]にて、「Update lists」を実行してパッケージ一覧を取得した後に、「Filter」にパッケージ名を入れて、出てきたモジュールを「Install」する。

CLIでインストールする場合は以下を実行

# opkg update
# opkg install luci-i18n-base-ja
# opkg install map
# okpg install iptables-mod-ipopt

インストール後は再起動を行うこと。

再起動しないとluciのネットワーク設定で「プロトコル:MAP / LW4over6」が選択肢に現れません。

設定手順2:WAN6インタフェースの作成

WAN6インタフェースがなければ「プロトコル: DHCPv6クライアント」で作成する

最初はそのまま設定して、有効化し、WAN6インタフェースに割り当てられるIPv6アドレスを確認すること。

↑の画像は使い回しなので、この段階では無いはずの「MAP」インタフェースなどが入ってます

上記のようにWAN6インタフェースに「IPv6」アドレスが確認できたら、そのアドレスをコピーして、notepadにでも貼り付けておきます。

設定手順3:WAN6インタフェースにDHCPv6関連設定

openWRT 21.02.0のリリース版になったらWAN6インタフェースではDHCPv6関連設定がGUIできるようになりました。

[DHCPサーバー]を選択して、下記のようになっている場合は「DHCPサーバーをセットアップ」をクリックします。

クリックしたあと[一般設定]タブは下記のような感じで変更せず

[IPv6設定]タブで下記の設定を行います。

Designated master: チェックを入れる
RA-Service:リレーモード
DHCPv6-サービス: リレーモード
NDP-Proxy: リレーモード
(Learn routesは設定を変更していない)

設定手順4:LANインタフェースにDHCPv6関連設定

LANインタフェースの[DHCPサーバー]-[IPv6設定]で以下の設定を行います。

RA-Service:リレーモード
DHCPv6-サービス: サーバーモード
NDP-Proxy: リレーモード

(マスターにチェックは入れません)

設定手順5: IPv6 PD設定

OpenWRT 21.02.0-RC版だとIPv6 PD設定がWAN6にあったのですが、リリース版だと消えています。

これは別のインタフェースとして作成することで対応するようです。

[インタフェースを新規作成]から下記でインタフェースを作成します。

名前:WAN6PD
プロトコル:静的アドレス
デバイス: WAN6インタフェース(@wan6表記)

詳細設定では手順2で確認したIPv6アドレスを使います。

IPv6アドレスが「IPv6: wwww:xxxx:yyyy:zzzz:aaaa:bbbb:cccc:dddd/64」というようになっているとき、先頭の4カラム「wwww:xxxx:yyyy:zzzz」を使います。

まず、WAN6PDに割り当てる 「wwww:xxxx:yyyy:zzzz::1001」を「IPv6アドレス」に設定します。

「IPv6 ゲートウェイ」には「wwww:xxxx:yyyy:zzzz::1 」を指定します。このアドレスは設定完了後、WAN6PDインタフェースではなく、LANインタフェースに対して割り当てられます。

「IPv6ルートプレフィックス」には「wwww:xxxx:yyyy:zzzz::/56」と指定します。

設定すると上記のような感じです。

設定手順6: MAP-E接続設定

インタフェースの新規作成で「プロトコル:MAP / LW4over6」を作成して、必要な値を入れていきます。今回は「WAN_MAP」で作成しました。

[一般設定]では下記の様にしました。

プロトコル:MAP/LW4over6
タイプ:MAP-E
以後は環境に合わせた値

[詳細設定]では「従来のMAPを使用」にチェックを入れる

設定手順7: 各インタフェースのファイアウォールゾーン設定

wan系のゾーンに「wan_map」と「WAN6PD」を追加します。

設定完了

ひとまずこれで設定完了です。

うまく接続が始まらない場合は、再起動してみてください。

設定:ニチバン対策

通称「ニチバンベンチ」と呼ばれているものがある。

一部のIPv4通信のみが可能なサイトにアクセスした際に、一定数以上の通信が行えなくなりコンテンツが欠けるなどの現象が発生することがある。

これはNATテーブルの利用手法と、一回確保したNATテーブルエントリの有効期限設定の兼ね合いで、MAP-Eで確保できるIPv4通信用のNAT用ポートを使い果たしてしまった場合に発生している。

大量の小さなファイルがWebサーバ側の同時セッション数が非常に多い設定で流れてこなければならないので、この現象が発生しているかどうかを意図的に確認するのがなかなか難しいものがある。

しかし、長らくニチバンサイトではその条件に合致するサイト構造であったため、ニチバンサイトを10窓ぐらいでリロードすれば発生していたため、確認手法としてニチバンにアクセスすることを「ニチバンベンチ」と呼称していた。(なお、2021年9月時点のニチバンサイトはサイト内容が一新され発生しなくなっている)

このNATテーブルとIPv4 ポート割り当ての問題を解消するためにiptablesを利用して割り当て手法の調整を行う https://paste.teknik.io/VeN9r を使用した。

IP4,PSID, TUNDEVは自分の環境に合わせて変更すること
IP4, PSIDがわからない場合は http://ipv4.web.fc2.com/map-e.html で確認すること

TUNDEVは、GUIから設定した名前ではなく、アイコンの下に小さく書かれている方の名前を使う。↑の場合は「map-wan_map」になる。

また、units1とunits2は、BIGLOBEはV6plus相当であるため、数値を変更する。

units1=15 #V6plus:15 OCN:63
units2=4096 #V6plus 4096 OCN:1024
IP4='xxx.xxx.xxx.xxx'
PSID='x'
TUNDEV='map-wan_map'


iptables -t nat -F PREROUTING
iptables -t nat -F OUTPUT
iptables -t nat -F POSTROUTING

rule=1
while [ $rule -le $units1  ] ; do
  mark=`expr $rule + 16`
  pn=`expr $rule - 1`
  portl=`expr $rule \* $units2 + $PSID \* 16`
  portr=`expr $portl + 15`

  iptables -t nat -A PREROUTING -m statistic --mode nth --every $units1 --packet $pn -j MARK --set-mark $mark
  iptables -t nat -A OUTPUT -m statistic --mode nth --every $units1 --packet $pn -j MARK --set-mark $mark

  iptables -t nat -A POSTROUTING -p icmp -o $TUNDEV -m mark --mark $mark -j SNAT --to $IP4:$portl-$portr
  iptables -t nat -A POSTROUTING -p tcp -o $TUNDEV -m mark --mark $mark -j SNAT --to $IP4:$portl-$portr
  iptables -t nat -A POSTROUTING -p udp -o $TUNDEV -m mark --mark $mark -j SNAT --to $IP4:$portl-$portr
  rule=`expr $rule + 1`
done

上記をopenwrtの[ネットワーク]-[ファイヤーウォール]-[Custom Rules] (/etc/firewall.user) に記載する。

また、[システム]-[スタートアップ]-[ローカルスタートアップ] (/etc/rc.local)の exit 0よりも前に下記2行を追加する

sleep 30
sh /etc/firewall.user

なお、iptablesのstatisticモジュールはiptables-mod-ipoptに入っているが、標準では導入されていないため、冒頭でインストールしているが、まだの場合は下記のような感じでインストールする。

root@nanopi:~# opkg install iptables-mod-ipopt
Installing iptables-mod-ipopt (1.8.7-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.0-rc1/targets/rockchip/armv8/packages/iptables-mod-ipopt_1.8.7-1_aarch64_generic.ipk
Installing kmod-ipt-ipopt (5.4.111-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.0-rc1/targets/rockchip/armv8/packages/kmod-ipt-ipopt_5.4.111-1_aarch64_generic.ipk
Configuring kmod-ipt-ipopt.
Configuring iptables-mod-ipopt.
root@nanopi:~#

これで、とりあえずニチバンもスムースに開けるようになった。


参考資料

/etc/config/network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fdaf:6014:6f21::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1'

config device
        option name 'eth1'
        option macaddr '1a:e4:a4:73:0d:0c'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option ipaddr '192.168.1.1'

config device
        option name 'eth0'
        option macaddr '1a:e4:a4:73:0d:0b'

config interface 'wan'
        option device 'eth0'
        option proto 'dhcp'
        option auto '0'

config interface 'wan6'
        option device 'eth0'
        option proto 'dhcpv6'
        option reqaddress 'try'
        option reqprefix 'auto'

config interface 'wan_map'
        option proto 'map'
        option maptype 'map-e'
        option peeraddr '2404:9200:225:100::64'
        option ipaddr 'xxx.xxx.xxx.xxx'
        option ip4prefixlen '15'
        option ip6prefix 'wwww:xxxx::'
        option ip6prefixlen '31'
        option ealen '25'
        option psidlen '8'
        option offset '4'
        option legacymap '1'

config interface 'WAN6PD'
        option proto 'static'
        list ip6addr 'wwww:xxxx:yyyy:zzzz::1001'
        option ip6gw 'wwww:xxxx:yyyy:zzzz::1'
        option ip6prefix 'wwww:xxxx:yyyy:zzzz::/56'
        option device '@wan6'

/etc/config/dhcp

config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option nonwildcard '1'
        option localservice '1'
        option ednspacket_max '1232'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv4 'server'
        option ra 'relay'
        option ndp 'relay'
        list ra_flags 'none'
        option dhcpv6 'server'

config dhcp 'wan6'
        option dhcpv6 'relay'
        option ra 'relay'
        option ndp 'relay'
        option master '1'
        option interface 'wan6'
        option ignore '1'
        list ra_flags 'none'

iptablesの結果

意図した分散が行われているかを「iptables -t nat -L -v」のPOSTROUTING tcp/udpのpkts/bytesカウントが分散して増加していっているかを確認する。

ちなみに、 /etc/rc.local にsleep 30とsh /etc/firewall.user を入れないと、システムが生成した分散ルールも残って表示される。

root@nanopi:~# iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 2756 packets, 474K bytes)
 pkts bytes target     prot opt in     out     source               destination
  185 32012 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 MARK set 0x11
  184 28575 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 1 MARK set 0x12
  184 31952 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 2 MARK set 0x13
  184 31323 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 3 MARK set 0x14
  184 33123 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 4 MARK set 0x15
  184 36047 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 5 MARK set 0x16
  184 32939 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 6 MARK set 0x17
  184 33412 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 7 MARK set 0x18
  184 29916 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 8 MARK set 0x19
  184 28526 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 9 MARK set 0x1a
  184 29308 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 10 MARK set 0x1b
  183 32364 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 11 MARK set 0x1c
  183 30150 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 12 MARK set 0x1d
  183 29944 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 13 MARK set 0x1e
  183 34100 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 14 MARK set 0x1f

Chain INPUT (policy ACCEPT 598 packets, 40818 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 67 packets, 5056 bytes)
 pkts bytes target     prot opt in     out     source               destination
    5   372 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 MARK set 0x11
    5   372 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 1 MARK set 0x12
    5   372 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 2 MARK set 0x13
    5   372 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 3 MARK set 0x14
    5   380 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 4 MARK set 0x15
    5   380 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 5 MARK set 0x16
    5   380 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 6 MARK set 0x17
    4   300 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 7 MARK set 0x18
    4   304 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 8 MARK set 0x19
    4   304 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 9 MARK set 0x1a
    4   304 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 10 MARK set 0x1b
    4   304 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 11 MARK set 0x1c
    4   304 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 12 MARK set 0x1d
    4   304 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 13 MARK set 0x1e
    4   304 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 14 MARK set 0x1f

Chain POSTROUTING (policy ACCEPT 23 packets, 1064 bytes)
 pkts bytes target     prot opt in     out     source               destination
    2   168 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x11 to:xxx.xxx.xxx.xxx:5856-5871
   41  2607 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x11 to:xxx.xxx.xxx.xxx:5856-5871
    8   557 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x11 to:xxx.xxx.xxx.xxx:5856-5871
    4   336 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x12 to:xxx.xxx.xxx.xxx:9952-9967
   50  3503 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x12 to:xxx.xxx.xxx.xxx:9952-9967
   13   868 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x12 to:xxx.xxx.xxx.xxx:9952-9967
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x13 to:xxx.xxx.xxx.xxx:14048-14063
   46  2981 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x13 to:xxx.xxx.xxx.xxx:14048-14063
   11   771 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x13 to:xxx.xxx.xxx.xxx:14048-14063
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x14 to:xxx.xxx.xxx.xxx:18144-18159
   33  1991 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x14 to:xxx.xxx.xxx.xxx:18144-18159
   10   709 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x14 to:xxx.xxx.xxx.xxx:18144-18159
    2   168 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x15 to:xxx.xxx.xxx.xxx:22240-22255
   38  2280 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x15 to:xxx.xxx.xxx.xxx:22240-22255
   13   950 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x15 to:xxx.xxx.xxx.xxx:22240-22255
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x16 to:xxx.xxx.xxx.xxx:26336-26351
   42  3095 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x16 to:xxx.xxx.xxx.xxx:26336-26351
   11   831 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x16 to:xxx.xxx.xxx.xxx:26336-26351
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x17 to:xxx.xxx.xxx.xxx:30432-30447
   51  3838 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x17 to:xxx.xxx.xxx.xxx:30432-30447
   11   823 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x17 to:xxx.xxx.xxx.xxx:30432-30447
    1    84 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x18 to:xxx.xxx.xxx.xxx:34528-34543
   41  2564 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x18 to:xxx.xxx.xxx.xxx:34528-34543
    9   656 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x18 to:xxx.xxx.xxx.xxx:34528-34543
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x19 to:xxx.xxx.xxx.xxx:38624-38639
   44  2665 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x19 to:xxx.xxx.xxx.xxx:38624-38639
    9   629 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x19 to:xxx.xxx.xxx.xxx:38624-38639
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1a to:xxx.xxx.xxx.xxx:42720-42735
   55  3841 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1a to:xxx.xxx.xxx.xxx:42720-42735
   11   762 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1a to:xxx.xxx.xxx.xxx:42720-42735
    1    84 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1b to:xxx.xxx.xxx.xxx:46816-46831
   53  3161 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1b to:xxx.xxx.xxx.xxx:46816-46831
   10   699 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1b to:xxx.xxx.xxx.xxx:46816-46831
    2   168 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1c to:xxx.xxx.xxx.xxx:50912-50927
   46  2965 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1c to:xxx.xxx.xxx.xxx:50912-50927
    9   632 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1c to:xxx.xxx.xxx.xxx:50912-50927
    1    84 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1d to:xxx.xxx.xxx.xxx:55008-55023
   45  2700 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1d to:xxx.xxx.xxx.xxx:55008-55023
   10   671 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1d to:xxx.xxx.xxx.xxx:55008-55023
    1    84 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1e to:xxx.xxx.xxx.xxx:59104-59119
   48  2992 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1e to:xxx.xxx.xxx.xxx:59104-59119
   15  1003 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1e to:xxx.xxx.xxx.xxx:59104-59119
    1    84 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1f to:xxx.xxx.xxx.xxx:63200-63215
   38  2280 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1f to:xxx.xxx.xxx.xxx:63200-63215
    9   615 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1f to:xxx.xxx.xxx.xxx:63200-63215

Chain postrouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain postrouting_rule (0 references)
 pkts bytes target     prot opt in     out     source               destination

Chain postrouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain prerouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain prerouting_rule (0 references)
 pkts bytes target     prot opt in     out     source               destination

Chain prerouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain zone_lan_postrouting (0 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 postrouting_lan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom lan postrouting rule chain */

Chain zone_lan_prerouting (0 references)
 pkts bytes target     prot opt in     out     source               destination
  389 44358 prerouting_lan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom lan prerouting rule chain */

Chain zone_wan_postrouting (0 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 postrouting_wan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom wan postrouting rule chain */
    0     0 MASQUERADE  all  --  any    any     anywhere             anywhere             /* !fw3 */

Chain zone_wan_prerouting (0 references)
 pkts bytes target     prot opt in     out     source               destination
    6   786 prerouting_wan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom wan prerouting rule chain */
root@nanopi:~#

2021/09/22追記: 8日間稼働した後の状態

root@nanopi:~# iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 1434K packets, 285M bytes)
 pkts bytes target     prot opt in     out     source               destination
95575   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 MARK set 0x11
95574   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 1 MARK set 0x12
95574   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 2 MARK set 0x13
95574   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 3 MARK set 0x14
95574   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 4 MARK set 0x15
95574   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 5 MARK set 0x16
95574   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 6 MARK set 0x17
95573   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 7 MARK set 0x18
95573   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 8 MARK set 0x19
95573   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 9 MARK set 0x1a
95573   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 10 MARK set 0x1b
95573   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 11 MARK set 0x1c
95573   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 12 MARK set 0x1d
95573   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 13 MARK set 0x1e
95573   19M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 14 MARK set 0x1f

Chain INPUT (policy ACCEPT 231K packets, 17M bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 1399 packets, 222K bytes)
 pkts bytes target     prot opt in     out     source               destination
   94 15373 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 MARK set 0x11
   94 16668 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 1 MARK set 0x12
   94 13812 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 2 MARK set 0x13
   94 14151 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 3 MARK set 0x14
   93 14819 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 4 MARK set 0x15
   93 13431 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 5 MARK set 0x16
   93 15387 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 6 MARK set 0x17
   93 14528 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 7 MARK set 0x18
   93 15124 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 8 MARK set 0x19
   93 16367 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 9 MARK set 0x1a
   93 14850 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 10 MARK set 0x1b
   93 14763 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 11 MARK set 0x1c
   93 14121 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 12 MARK set 0x1d
   93 13029 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 13 MARK set 0x1e
   93 15394 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 14 MARK set 0x1f

Chain POSTROUTING (policy ACCEPT 1289 packets, 186K bytes)
 pkts bytes target     prot opt in     out     source               destination
  772 64680 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x11 to:xxx.xxx.xxx.xxx:5856-5871
14703  948K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x11 to:xxx.xxx.xxx.xxx:5856-5871
 3753  257K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x11 to:xxx.xxx.xxx.xxx:5856-5871
  837 70140 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x12 to:xxx.xxx.xxx.xxx:9952-9967
14623  945K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x12 to:xxx.xxx.xxx.xxx:9952-9967
 3628  254K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x12 to:xxx.xxx.xxx.xxx:9952-9967
  806 67536 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x13 to:xxx.xxx.xxx.xxx:14048-14063
14690  930K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x13 to:xxx.xxx.xxx.xxx:14048-14063
 3705  257K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x13 to:xxx.xxx.xxx.xxx:14048-14063
  853 71540 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x14 to:xxx.xxx.xxx.xxx:18144-18159
14620  936K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x14 to:xxx.xxx.xxx.xxx:18144-18159
 3696  255K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x14 to:xxx.xxx.xxx.xxx:18144-18159
  802 67088 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x15 to:xxx.xxx.xxx.xxx:22240-22255
14833  942K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x15 to:xxx.xxx.xxx.xxx:22240-22255
 3723  256K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x15 to:xxx.xxx.xxx.xxx:22240-22255
  834 69944 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x16 to:xxx.xxx.xxx.xxx:26336-26351
14759  930K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x16 to:xxx.xxx.xxx.xxx:26336-26351
 3689  258K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x16 to:xxx.xxx.xxx.xxx:26336-26351
  804 67480 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x17 to:xxx.xxx.xxx.xxx:30432-30447
14874  946K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x17 to:xxx.xxx.xxx.xxx:30432-30447
 3746  261K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x17 to:xxx.xxx.xxx.xxx:30432-30447
  868 72800 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x18 to:xxx.xxx.xxx.xxx:34528-34543
14703  937K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x18 to:xxx.xxx.xxx.xxx:34528-34543
 3698  254K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x18 to:xxx.xxx.xxx.xxx:34528-34543
  843 70644 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x19 to:xxx.xxx.xxx.xxx:38624-38639
14651  931K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x19 to:xxx.xxx.xxx.xxx:38624-38639
 3720  256K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x19 to:xxx.xxx.xxx.xxx:38624-38639
  768 64288 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1a to:xxx.xxx.xxx.xxx:42720-42735
14731  942K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1a to:xxx.xxx.xxx.xxx:42720-42735
 3689  251K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1a to:xxx.xxx.xxx.xxx:42720-42735
  839 70084 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1b to:xxx.xxx.xxx.xxx:46816-46831
14826  944K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1b to:xxx.xxx.xxx.xxx:46816-46831
 3729  257K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1b to:xxx.xxx.xxx.xxx:46816-46831
  841 70420 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1c to:xxx.xxx.xxx.xxx:50912-50927
14751  939K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1c to:xxx.xxx.xxx.xxx:50912-50927
 3697  252K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1c to:xxx.xxx.xxx.xxx:50912-50927
  783 65492 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1d to:xxx.xxx.xxx.xxx:55008-55023
14802  937K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1d to:xxx.xxx.xxx.xxx:55008-55023
 3679  255K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1d to:xxx.xxx.xxx.xxx:55008-55023
  850 71288 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1e to:xxx.xxx.xxx.xxx:59104-59119
14824  942K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1e to:xxx.xxx.xxx.xxx:59104-59119
 3622  246K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1e to:xxx.xxx.xxx.xxx:59104-59119
  870 72968 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1f to:xxx.xxx.xxx.xxx:63200-63215
14802  941K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1f to:xxx.xxx.xxx.xxx:63200-63215
 3684  258K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1f to:xxx.xxx.xxx.xxx:63200-63215

Chain postrouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain postrouting_rule (0 references)
 pkts bytes target     prot opt in     out     source               destination

Chain postrouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain prerouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain prerouting_rule (0 references)
 pkts bytes target     prot opt in     out     source               destination

Chain prerouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain zone_lan_postrouting (0 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 postrouting_lan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom lan postrouting rule chain */

Chain zone_lan_prerouting (0 references)
 pkts bytes target     prot opt in     out     source               destination
  389 44358 prerouting_lan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom lan prerouting rule chain */

Chain zone_wan_postrouting (0 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 postrouting_wan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom wan postrouting rule chain */
    0     0 MASQUERADE  all  --  any    any     anywhere             anywhere             /* !fw3 */

Chain zone_wan_prerouting (0 references)
 pkts bytes target     prot opt in     out     source               destination
    6   786 prerouting_wan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom wan prerouting rule chain */
root@nanopi:~#

2022/04/14追記

32日起動していた場合の出力なんだけど、以前と違って「conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat」の数が増えてないのはなんなのだ???

root@nanopi:~# uptime
 09:48:41 up 32 days, 12:38,  load average: 0.00, 0.01, 0.00
root@nanopi:~# iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 6326K packets, 1296M bytes)
 pkts bytes target     prot opt in     out     source               destination
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 MARK set 0x11
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 1 MARK set 0x12
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 2 MARK set 0x13
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 3 MARK set 0x14
 422K   87M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 4 MARK set 0x15
 422K   87M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 5 MARK set 0x16
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 6 MARK set 0x17
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 7 MARK set 0x18
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 8 MARK set 0x19
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 9 MARK set 0x1a
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 10 MARK set 0x1b
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 11 MARK set 0x1c
 422K   87M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 12 MARK set 0x1d
 422K   87M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 13 MARK set 0x1e
 422K   86M MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 14 MARK set 0x1f
6326K 1296M prerouting_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom prerouting rule chain */
6321K 1295M zone_lan_prerouting  all  --  br-lan any     anywhere             anywhere             /* !fw3 */
    0     0 zone_wan_prerouting  all  --  eth0   any     anywhere             anywhere             /* !fw3 */
 4905  558K zone_wan_prerouting  all  --  map-wan_map any     anywhere             anywhere             /* !fw3 */

Chain INPUT (policy ACCEPT 1037K packets, 79M bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 9463 packets, 1532K bytes)
 pkts bytes target     prot opt in     out     source               destination
  632  101K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 MARK set 0x11
  631  103K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 1 MARK set 0x12
  631  100K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 2 MARK set 0x13
  631 99184 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 3 MARK set 0x14
  631  101K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 4 MARK set 0x15
  631  103K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 5 MARK set 0x16
  631  105K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 6 MARK set 0x17
  631  102K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 7 MARK set 0x18
  631  102K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 8 MARK set 0x19
  631 97260 MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 9 MARK set 0x1a
  631  104K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 10 MARK set 0x1b
  631  102K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 11 MARK set 0x1c
  631  105K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 12 MARK set 0x1d
  630  100K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 13 MARK set 0x1e
  630  104K MARK       all  --  any    any     anywhere             anywhere             statistic mode nth every 15 packet 14 MARK set 0x1f

Chain POSTROUTING (policy ACCEPT 7238 packets, 1363K bytes)
 pkts bytes target     prot opt in     out     source               destination
 2962  257K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x11 to:xxx.xx.xxx.xx:5856-5871
62597 4208K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x11 to:xxx.xx.xxx.xx:5856-5871
14955 4828K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x11 to:xxx.xx.xxx.xx:5856-5871
 2998  256K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x12 to:xxx.xx.xxx.xx:9952-9967
62399 4173K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x12 to:xxx.xx.xxx.xx:9952-9967
14973 4852K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x12 to:xxx.xx.xxx.xx:9952-9967
 2972  263K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x13 to:xxx.xx.xxx.xx:14048-14063
62056 4109K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x13 to:xxx.xx.xxx.xx:14048-14063
14958 4830K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x13 to:xxx.xx.xxx.xx:14048-14063
 3020  270K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x14 to:xxx.xx.xxx.xx:18144-18159
62491 4170K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x14 to:xxx.xx.xxx.xx:18144-18159
15125 4922K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x14 to:xxx.xx.xxx.xx:18144-18159
 2948  255K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x15 to:xxx.xx.xxx.xx:22240-22255
62215 4170K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x15 to:xxx.xx.xxx.xx:22240-22255
15160 4931K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x15 to:xxx.xx.xxx.xx:22240-22255
 2985  259K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x16 to:xxx.xx.xxx.xx:26336-26351
62214 4147K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x16 to:xxx.xx.xxx.xx:26336-26351
15056 4989K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x16 to:xxx.xx.xxx.xx:26336-26351
 3116  271K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x17 to:xxx.xx.xxx.xx:30432-30447
62050 4150K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x17 to:xxx.xx.xxx.xx:30432-30447
15061 4789K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x17 to:xxx.xx.xxx.xx:30432-30447
 2973  256K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x18 to:xxx.xx.xxx.xx:34528-34543
62684 4173K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x18 to:xxx.xx.xxx.xx:34528-34543
15055 4832K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x18 to:xxx.xx.xxx.xx:34528-34543
 3046  272K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x19 to:xxx.xx.xxx.xx:38624-38639
62090 4162K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x19 to:xxx.xx.xxx.xx:38624-38639
14894 4747K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x19 to:xxx.xx.xxx.xx:38624-38639
 3045  263K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1a to:xxx.xx.xxx.xx:42720-42735
62550 4157K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1a to:xxx.xx.xxx.xx:42720-42735
15085 4847K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1a to:xxx.xx.xxx.xx:42720-42735
 2970  255K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1b to:xxx.xx.xxx.xx:46816-46831
62369 4167K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1b to:xxx.xx.xxx.xx:46816-46831
14965 4803K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1b to:xxx.xx.xxx.xx:46816-46831
 2912  257K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1c to:xxx.xx.xxx.xx:50912-50927
62665 4189K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1c to:xxx.xx.xxx.xx:50912-50927
15057 4704K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1c to:xxx.xx.xxx.xx:50912-50927
 3024  263K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1d to:xxx.xx.xxx.xx:55008-55023
62282 4191K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1d to:xxx.xx.xxx.xx:55008-55023
15039 4877K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1d to:xxx.xx.xxx.xx:55008-55023
 3022  262K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1e to:xxx.xx.xxx.xx:59104-59119
62369 4163K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1e to:xxx.xx.xxx.xx:59104-59119
15014 4877K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1e to:xxx.xx.xxx.xx:59104-59119
 3001  261K SNAT       icmp --  any    map-wan_map  anywhere             anywhere             mark match 0x1f to:xxx.xx.xxx.xx:63200-63215
62511 4145K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1f to:xxx.xx.xxx.xx:63200-63215
15094 4836K SNAT       udp  --  any    map-wan_map  anywhere             anywhere             mark match 0x1f to:xxx.xx.xxx.xx:63200-63215
10025 1475K postrouting_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom postrouting rule chain */
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 0 */ to:xxx.xx.xxx.xx:5856-5871
 2787  111K SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 1 */ to:xxx.xx.xxx.xx:5856-5871
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 2 */ to:xxx.xx.xxx.xx:5856-5871
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 3 */ to:xxx.xx.xxx.xx:9952-9967
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 4 */ to:xxx.xx.xxx.xx:9952-9967
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 5 */ to:xxx.xx.xxx.xx:9952-9967
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 6 */ to:xxx.xx.xxx.xx:14048-14063
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 7 */ to:xxx.xx.xxx.xx:14048-14063
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 8 */ to:xxx.xx.xxx.xx:14048-14063
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 9 */ to:xxx.xx.xxx.xx:18144-18159
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 10 */ to:xxx.xx.xxx.xx:18144-18159
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 11 */ to:xxx.xx.xxx.xx:18144-18159
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 12 */ to:xxx.xx.xxx.xx:22240-22255
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 13 */ to:xxx.xx.xxx.xx:22240-22255
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 14 */ to:xxx.xx.xxx.xx:22240-22255
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 15 */ to:xxx.xx.xxx.xx:26336-26351
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 16 */ to:xxx.xx.xxx.xx:26336-26351
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 17 */ to:xxx.xx.xxx.xx:26336-26351
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 18 */ to:xxx.xx.xxx.xx:30432-30447
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 19 */ to:xxx.xx.xxx.xx:30432-30447
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 20 */ to:xxx.xx.xxx.xx:30432-30447
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 21 */ to:xxx.xx.xxx.xx:34528-34543
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 22 */ to:xxx.xx.xxx.xx:34528-34543
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 23 */ to:xxx.xx.xxx.xx:34528-34543
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 24 */ to:xxx.xx.xxx.xx:38624-38639
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 25 */ to:xxx.xx.xxx.xx:38624-38639
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 26 */ to:xxx.xx.xxx.xx:38624-38639
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 27 */ to:xxx.xx.xxx.xx:42720-42735
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 28 */ to:xxx.xx.xxx.xx:42720-42735
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 29 */ to:xxx.xx.xxx.xx:42720-42735
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 30 */ to:xxx.xx.xxx.xx:46816-46831
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 31 */ to:xxx.xx.xxx.xx:46816-46831
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 32 */ to:xxx.xx.xxx.xx:46816-46831
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 33 */ to:xxx.xx.xxx.xx:50912-50927
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 34 */ to:xxx.xx.xxx.xx:50912-50927
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 35 */ to:xxx.xx.xxx.xx:50912-50927
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 36 */ to:xxx.xx.xxx.xx:55008-55023
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 37 */ to:xxx.xx.xxx.xx:55008-55023
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 38 */ to:xxx.xx.xxx.xx:55008-55023
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 39 */ to:xxx.xx.xxx.xx:59104-59119
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 40 */ to:xxx.xx.xxx.xx:59104-59119
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 41 */ to:xxx.xx.xxx.xx:59104-59119
    0     0 SNAT       icmp --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 42 */ to:xxx.xx.xxx.xx:63200-63215
    0     0 SNAT       tcp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 43 */ to:xxx.xx.xxx.xx:63200-63215
    0     0 SNAT       udp  --  any    map-wan_map  anywhere             anywhere             #conn dst/32 <= 16 /* !fw3: ubus:wan_map[map] nat 44 */ to:xxx.xx.xxx.xx:63200-63215
 7137 1356K zone_lan_postrouting  all  --  any    br-lan  anywhere             anywhere             /* !fw3 */
    0     0 zone_wan_postrouting  all  --  any    eth0    anywhere             anywhere             /* !fw3 */
    0     0 zone_wan_postrouting  all  --  any    map-wan_map  anywhere             anywhere             /* !fw3 */

Chain postrouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain postrouting_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain postrouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain prerouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain prerouting_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain prerouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain zone_lan_postrouting (1 references)
 pkts bytes target     prot opt in     out     source               destination
 7137 1356K postrouting_lan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom lan postrouting rule chain */

Chain zone_lan_prerouting (1 references)
 pkts bytes target     prot opt in     out     source               destination
6321K 1295M prerouting_lan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom lan prerouting rule chain */

Chain zone_wan_postrouting (2 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 postrouting_wan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom wan postrouting rule chain */
    0     0 MASQUERADE  all  --  any    any     anywhere             anywhere             /* !fw3 */

Chain zone_wan_prerouting (2 references)
 pkts bytes target     prot opt in     out     source               destination
 4905  558K prerouting_wan_rule  all  --  any    any     anywhere             anywhere             /* !fw3: Custom wan prerouting rule chain */
root@nanopi:~#

これはどうやら、openwrt起動後にSoftwareパッケージの個別更新を実施していたのだが、ネットワークのrestartが行われた際に、iptablesが再設定されたためだったようで、openwrt全体を再起動した正常になった。

現在行っている設定はネットワーク開始後に /etc/rc.local からiptablesの設定を追加しているので、rc.localで行うことが消えた、という感じである

Linksys E8450 AX3200はEasyMeshでバッファローの子機にもできるけど5GHzが4チャンネルしか使えない


LinksysのWi-Fiルータ E7350とE8450がEasyMeshに対応した、というニュースとツイートに遭遇した。

.

Amazonで見てみたら、Amazonアウトレット扱いでE7350が4791円、E8450が6204円だった。

というわけでLinksys E8450 AX3200を買って、firmwareを1.0.01.101415から1.1.00.180912へアップデートしてからいろいろやってみた。

W52周波数帯しか使えない問題

ウィザード形式の設定を飛ばして、設定画面を見てみると、なんと5GHzで使用できるチャネル設定が36,40,44,48chの4つしかない。

この4chはW52と呼ばれる周波数帯で、2021年現在の日本では他にW53の52,56,60,64ch、と、W56の100,104,108,112,116,120,124,128,132,136,140chが使えるのが普通である。

サポートに問い合わせて見たが、2021/09/10時点ではW52しか選択できない件について明確な回答は得られていない。

2021/09/27追記:なんと技適はW52範囲でしか取得していないということが判明。まさかの仕様!

他社のEasyMesh親機につなげるか問題

さて、今回このLinksys E8450はEasyMeshの子機として使うために購入した。

既存環境はバッファローのWSR-1800AX4で、2021年6月に「バッファローWSR-1800AX4をEasyMesh対応にしてみた」で書いたように構成したものとなる。

この環境にE8450を子機として設定する手順は「LinksysデュアルバンドEasyMeshWiFiルーターへの子ノードの追加方法」にある「WPSボタンを使用してEasyMesh子ノードを追加する方法」を使用した。

親機となるバッファローWSR-1800AX4の管理画面からWPSボタンを押した後、E7450背面のWPSボタン(物理)を3秒押して、電源ランプが点滅するのを確認して手を放します。

しばらくすると、子機の電源ランプとインターネットランプが青で点灯します。

そして、親機のWSR-1800AX4の管理画面上では「機器名:Other」として登録されているのが確認出来ます。

・・・接続帯域が「2.4G」となっていますね。

これは既存環境のWSR-1800AX4で使っている5GHz帯が140chチャンネルで、E8450がサポートしていないチャンネルであるから接続出来なかったようです。

試しにWSR-1800AX4のチャンネルを40chに変更してから再試行すると、ちゃんと「接続帯域:5G」となります。

念のためW53の60chでも試してみたところ2.4GHz接続となり、E8450ではW52以外のチャンネルは使用できないようです。

EasyMesh子機の管理画面にアクセスできない

結構な問題だと思うのですが、E8450をEasyMesh子機とした場合、そのE8450の管理画面にアクセスできなくなります。

英語のLivechatサポートに確認したところ、子機の管理画面は親機となるE8450から一括管理できる、という話で、メーカー違いの場合は管理できないようです。

このため、実は上記で親機のチャンネル変更を行った場合、E8450が設定をアップデートとかしてくれなかったので、毎回E8450を初期化して、1から設定をやり直していました。

Linksysメッシュルーターを工場出荷時のデフォルト設定にリセットする」にあるように、E8450が起動状態にあるときにリセットボタンを10秒ぐらい押しつづけ、赤点滅をしはじめて処理がはじまったところで、ボタンを放すと初期化が開始されます。

異機種混在はメーカ保証対象外なんでしょうけど、単体で設定出来る手法は用意してほしかったものです・・・


2022/05/06追記

openwrtに「Linksys E8450 (aka. Belkin RT3200)」というページがあり、snapshot版22.03で対応している。

snapshot版を入れた人の話では、5GHzはW52,W53,W56がちゃんと使えるそうだ。

MariaDB 5.5から10.6にアップデートして死にかけた件(utf8が無くなった)


CentOS7上で動いているMariaDB 5.5サーバをMariaDB 10.6にアップデートして死にかけた。

2022/10/28追記:この件に関するMariaDB公式のお知らせ的な物。どうやらold_mode を設定するらしい

データベースのアップデート自体は問題なかったのだが、アプリケーション側で問題発生。

/var/log/messages に下記の様なメッセージが多発

Jul 13 10:50:11 ホスト名 kernel: dict[23339]: segfault at a8 ip 00007f99c6fa9fa1 sp 00007ffc4641fe50 error 4 in libmysqlclient.so.18.0.0[7f99c6f4b000+320000]
Jul 13 10:50:11 ホスト名 mariadbd: 2021-07-13 10:50:11 7 [Warning] Aborted connection 7 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 10:50:11 ホスト名 kernel: dict[23340]: segfault at a8 ip 00007f3950ee4fa1 sp 00007ffe8bec4f70 error 4 in libmysqlclient.so.18.0.0[7f3950e86000+320000]
Jul 13 10:50:11 ホスト名 kernel: dict[23341]: segfault at a8 ip 00007f89b3d8efa1 sp 00007ffed464d830 error 4 in libmysqlclient.so.18.0.0[7f89b3d30000+320000]
Jul 13 10:50:11 ホスト名 mariadbd: 2021-07-13 10:50:11 8 [Warning] Aborted connection 8 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 10:50:33 ホスト名 kernel: auth[23362]: segfault at a8 ip 00007f197609dfa1 sp 00007ffe82dc98a0 error 4 in libmysqlclient.so.18.0.0[7f197603f000+320000]

authとdictでlibmysqlclient.so.18.0.0 のsegmentation faultが発生しているという・・・

で・・このauthとdictというのはdovecot/authとdovecot/dictで、そこで何か起こっているようだ

/var/log/dovecot/dovecot.log を見てみる

Jul 13 10:50:05 ホスト名1 dovecot: dict(23024): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't connect to MySQL s
erver on '127.0.0.1' (111 "Connection refused") - waiting for 5 seconds before retry
Jul 13 10:50:05 ホスト名1 dovecot: dict(23024): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't connect to MySQL s
erver on '127.0.0.1' (111 "Connection refused") - waiting for 5 seconds before retry
Jul 13 10:50:10 ホスト名1 dovecot: dict: Error: #007Character set 'utf8' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Jul 13 10:50:10 ホスト名1 dovecot: dict(23024): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't initialize character set utf8 (path: /usr/share/mysql/charsets/) - waiting for 25 seconds before retry
Jul 13 10:50:10 ホスト名1 dovecot: dict: Error: #007Character set 'utf8' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Jul 13 10:50:10 ホスト名1 dovecot: dict(23024): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't initialize character set utf8 (path: /usr/share/mysql/charsets/) - waiting for 25 seconds before retry
Jul 13 10:50:11 ホスト名1 dovecot: dict: Error: #007Character set 'utf8' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Jul 13 10:50:11 ホスト名1 dovecot: dict(23338): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't initialize character set utf8 (path: /usr/share/mysql/charsets/) - waiting for 1 seconds before retry

mariadb 10.6で文字コード utf8の指定ができないというエラーなようだ。

/usr/share/mysql/charsets/ に utf8の定義があるか確認してみる

# ls -l /usr/share/mysql/charsets/
合計 236
-rw-r--r-- 1 root root 23531  7月  5 19:47 Index.xml
-rw-r--r-- 1 root root  1749  7月  5 19:47 README
-rw-r--r-- 1 root root  5526  7月  5 19:47 armscii8.xml
-rw-r--r-- 1 root root  5512  7月  5 19:47 ascii.xml
-rw-r--r-- 1 root root  8241  7月  5 19:47 cp1250.xml
-rw-r--r-- 1 root root  8365  7月  5 19:47 cp1251.xml
-rw-r--r-- 1 root root  5569  7月  5 19:47 cp1256.xml
-rw-r--r-- 1 root root  8902  7月  5 19:47 cp1257.xml
-rw-r--r-- 1 root root  5506  7月  5 19:47 cp850.xml
-rw-r--r-- 1 root root  5528  7月  5 19:47 cp852.xml
-rw-r--r-- 1 root root  5613  7月  5 19:47 cp866.xml
-rw-r--r-- 1 root root  6529  7月  5 19:47 dec8.xml
-rw-r--r-- 1 root root  5516  7月  5 19:47 geostd8.xml
-rw-r--r-- 1 root root  5728  7月  5 19:47 greek.xml
-rw-r--r-- 1 root root  5517  7月  5 19:47 hebrew.xml
-rw-r--r-- 1 root root  5502  7月  5 19:47 hp8.xml
-rw-r--r-- 1 root root  5529  7月  5 19:47 keybcs2.xml
-rw-r--r-- 1 root root  5510  7月  5 19:47 koi8r.xml
-rw-r--r-- 1 root root  6532  7月  5 19:47 koi8u.xml
-rw-r--r-- 1 root root  9816  7月  5 19:47 latin1.xml
-rw-r--r-- 1 root root  7238  7月  5 19:47 latin2.xml
-rw-r--r-- 1 root root  5515  7月  5 19:47 latin5.xml
-rw-r--r-- 1 root root  7438  7月  5 19:47 latin7.xml
-rw-r--r-- 1 root root  8047  7月  5 19:47 macce.xml
-rw-r--r-- 1 root root  8058  7月  5 19:47 macroman.xml
-rw-r--r-- 1 root root  6530  7月  5 19:47 swe7.xml
# grep utf8 /usr/share/mysql/charsets/Index.xml
<charset name="utf8mb3">
  <collation name="utf8mb3_general_ci"  id="33">
  <collation name="utf8mb3_bin"         id="83">
#

なんと無い。

/usr/share/mysql/charsets/Index.xml のutf8関連記述を見てみる

<charset name="utf8mb3">
  <family>Unicode</family>
  <description>UTF-8 Unicode</description>
  <alias>utf-8</alias>
  <collation name="utf8mb3_general_ci"  id="33">
   <flag>primary</flag>
   <flag>compiled</flag>
  </collation>
  <collation name="utf8mb3_bin"         id="83">
    <flag>binary</flag>
    <flag>compiled</flag>
  </collation>
</charset>

おやぁ???

以前mariadb 10.5にアップデートしたサーバの/usr/share/mysql/charsets/Index.xmlの該当箇所と比較すると、いままでは utf8だったエントリが utf8mb3 に置き換わっているようだ。

<charset name="utf8">
  <family>Unicode</family>
  <description>UTF-8 Unicode</description>
  <alias>utf-8</alias>
  <collation name="utf8_general_ci"     id="33">
   <flag>primary</flag>
   <flag>compiled</flag>
  </collation>
  <collation name="utf8_bin"            id="83">
    <flag>binary</flag>
    <flag>compiled</flag>
  </collation>
</charset>

で・・・ /etc/my.cnf の設定で言語に関する設定は下記の様になっていた

[mysqld]
<略>
# character-set-server に関する値は未設定
<略>
[client]
default-character-set=utf8

クライアントからのアクセス時のデフォルトがutf8と設定されていた。

そこで/etc/my.cnf の文字コード指定を utf8mb3 に変更

[mysqld]
<略>
character-set-server=utf8mb3
<略>
[client]
default-character-set=utf8mb3

これで接続できない、という事象はなくなった。

なくなったが、/var/log/messages には下記のメッセージが出続けている。

Jul 13 13:10:01 ホスト名 mariadbd: 2021-07-13 13:10:01 925 [Warning] Aborted connection 925 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:10:02 ホスト名 mariadbd: 2021-07-13 13:10:02 934 [Warning] Aborted connection 934 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:10:06 ホスト名 mariadbd: 2021-07-13 13:10:06 935 [Warning] Aborted connection 935 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:10:06 ホスト名 mariadbd: 2021-07-13 13:10:06 936 [Warning] Aborted connection 936 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:10:22 ホスト名 mariadbd: 2021-07-13 13:10:22 811 [Warning] Aborted connection 811 to db: 'amavisd' user: 'amavisd' host: 'localhost' (Got timeout reading communication packets)
Jul 13 13:11:01 ホスト名 mariadbd: 2021-07-13 13:11:01 786 [Warning] Aborted connection 786 to db: 'amavisd' user: 'amavisd' host: 'localhost' (Got timeout reading communication packets)
Jul 13 13:12:26 ホスト名 mariadbd: 2021-07-13 13:12:26 839 [Warning] Aborted connection 839 to db: 'amavisd' user: 'amavisd' host: 'localhost' (Got timeout reading communication packets)
Jul 13 13:12:26 ホスト名 mariadbd: 2021-07-13 13:12:26 828 [Warning] Aborted connection 828 to db: 'amavisd' user: 'amavisd' host: 'localhost' (Got timeout reading communication packets)

iRedMailフォーラム「mysqld [Warning] Aborted connection」によると、ログレベル下げろ、とのこと

mysqlを起動しようとしたら問題が・・・

# mysql -u root
ERROR 2019 (00000): Can't initialize character set utf8mb3 (path: compiled_in)
#

とりあえず /etc/my.cnf の最後に下記を追加

[mysql]
default-character-set=utf8

警告はでるのもの操作は可能(なお、default-character-set=utf8mb3 だと起動できなかった)

# mysql -u root
mysql: Warning: Charset id '33' csname 'utf8mb3' trying to replace existing csname 'utf8'
mysql: Warning: Charset id '83' csname 'utf8mb3' trying to replace existing csname 'utf8'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1103
Server version: 10.6.3-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

起動したのでフォーラムにあった設定を入れる。

MariaDB [(none)]> show global variables like '%log_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_warnings  | 2     |
+---------------+-------+
1 row in set (0.002 sec)

MariaDB [(none)]> set global log_warnings=1;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> show global variables like '%log_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_warnings  | 1     |
+---------------+-------+
1 row in set (0.002 sec)

MariaDB [(none)]> quit
Bye
#

しばらく放置・・・

Jul 13 13:40:01 ホスト名 mariadbd: 2021-07-13 13:40:01 313 [Warning] Aborted connection 313 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:40:02 ホスト名 mariadbd: 2021-07-13 13:40:02 314 [Warning] Aborted connection 314 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:40:04 ホスト名 mariadbd: 2021-07-13 13:40:04 315 [Warning] Aborted connection 315 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:42:53 ホスト名 mariadbd: 2021-07-13 13:42:53 359 [Warning] Aborted connection 359 to db: 'vmail' user: 'vmail' host: 'localhost' (Got an error reading communication packets)
Jul 13 13:42:53 ホスト名 mariadbd: 2021-07-13 13:42:53 352 [Warning] Aborted connection 352 to db: 'vmail' user: 'vmail' host: 'localhost' (Got an error reading communication packets)
Jul 13 13:42:53 ホスト名 mariadbd: 2021-07-13 13:42:53 357 [Warning] Aborted connection 357 to db: 'vmail' user: 'vmail' host: 'localhost' (Got an error reading communication packets)
Jul 13 13:42:53 ホスト名 mariadbd: 2021-07-13 13:42:53 351 [Warning] Aborted connection 351 to db: 'vmail' user: 'vmail' host: 'localhost' (Got an error reading communication packets)

うーん?

あれ?反映されてない

# mysql -u root
mysql: Warning: Charset id '33' csname 'utf8mb3' trying to replace existing csname 'utf8'
mysql: Warning: Charset id '83' csname 'utf8mb3' trying to replace existing csname 'utf8'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 474
Server version: 10.6.3-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show global variables like '%log_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_warnings  | 2     |
+---------------+-------+
1 row in set (0.002 sec)

MariaDB [(none)]> set global log_warnings=1;
Query OK, 0 rows aff
MariaDB [(none)]>

なんだろ?とりあえず再設定・・・

今度は大丈夫か?

…2時間経過

大丈夫そうだな


2021/07/15追記

注:下記はmariadbのserverとclientのバージョンが違っていたことによる問題でなので参考情報です

iredmailでは/usr/local/bin/fail2ban_banned_dbがcronにより毎分実行されているのだが、これがmysqlコマンドを使ってデータベース操作をしているようで、下記のメールが届くようになってしまった・・・

mysql: Warning: Charset id '33' csname 'utf8mb3' trying to replace existing csname 'utf8'
mysql: Warning: Charset id '83' csname 'utf8mb3' trying to replace existing csname 'utf8'

mysqlコマンドを実行した際のメッセージをなんとしてでも消さなければならないようだ。

utf8がutf8mb3になった変更について「MariaDB Server/MDEV-8334/Rename utf8 to utf8mb3

MariaDBの「OLD_MODE」という設定

# mysql -u root
mysql: Warning: Charset id '33' csname 'utf8mb3' trying to replace existing csname 'utf8'
mysql: Warning: Charset id '83' csname 'utf8mb3' trying to replace existing csname 'utf8'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 38510
Server version: 10.6.3-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT REPLACE(@@OLD_MODE, ',', '\n');
+--------------------------------+
| REPLACE(@@OLD_MODE, ',', '\n') |
+--------------------------------+
| UTF8_IS_UTF8MB3                |
+--------------------------------+
1 row in set (0.023 sec)

MariaDB [(none)]>

現状は「UTF8_IS_UTF8MB3」が設定されているので、UTF8=UTF8MB3扱いになるらしいが、設定されていない場合は「UTF8=UTF8MB4」となるそうな。

だったら、「utf8」でアクセスした場合でも勝手に読み替えて欲しいもんなんだけど、どうなっているのか???

MariaDB [(none)]> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb3                    |
| character_set_connection | utf8mb3                    |
| character_set_database   | utf8mb3                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb3                    |
| character_set_server     | utf8mb3                    |
| character_set_system     | utf8mb3                    |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.002 sec)

MariaDB [(none)]>
MariaDB [(none)]> show global variables like '%character_set%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb3                    |
| character_set_connection | utf8mb3                    |
| character_set_database   | utf8mb3                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb3                    |
| character_set_server     | utf8mb3                    |
| character_set_system     | utf8mb3                    |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.002 sec)

MariaDB [(none)]> show global variables like 'collation%';
+----------------------+--------------------+
| Variable_name        | Value              |
+----------------------+--------------------+
| collation_connection | utf8mb3_general_ci |
| collation_database   | utf8mb3_general_ci |
| collation_server     | utf8mb3_general_ci |
+----------------------+--------------------+
3 rows in set (0.002 sec)

MariaDB [(none)]>

ん?????

トラブル生じた時に、MariaDB10.5にしなかったっけ?と

# rpm -qa | grep MariaDB
MariaDB-client-10.5.11-1.el7.centos.x86_64
MariaDB-compat-10.6.3-1.el7.centos.x86_64
MariaDB-common-10.6.3-1.el7.centos.x86_64
MariaDB-server-10.6.3-1.el7.centos.x86_64
#

あー・・・MariaDB-clientとMariaDB-serverのバージョンがずれていました。

そんなわけで、MariaDB-clientの方も 10.6.3に揃えて再実行

# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 405
Server version: 10.6.3-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit
Bye
#

というわけで、解決しました。

Oracle CloudのOracle Linux 8で標準選択されているesmtpでメールを送信する


Oracle Cloud上のOralce Linux 8インスタンスでは、postfixやsendmailではなく、esmtpがインストールされている。

esmtpはRHEL8やCentOS8でも用意されているが、実際に使用している情報があまりない。

esmtp公式ページを見ると「THIS PROJECT IS NO LONGER BEING MAINTAINED. IF IT DOESN’T WORK FOR YOU SEE THESE LINKS.」と書いてあり、本来は利用推奨ではないようだ。

ざっと見たところ日本語情報としてまとまっているのは2010年に書かれた 本を読む の「軽量MTA「esmtp」を試してみた」だった。

esmtpはデーモンではなく、ポート25での待受もせず、/usr/lib/sendmailや/usr/bin/mail を実行する形でのメール送信が実行できるようにするためのソフトウェアです。

ローカルのUNIXユーザ宛にメールを届けたい場合は別途 procmailパッケージをインストールする必要があります。

他のサーバ宛にメールを送りたい場合は、外部のSMTPサーバのアカウント情報を登録し、SMTP AUTHを利用したメール送信が可能です。

難点は、メール送信に関するログがどこにも保存されない、ということ。

設定に失敗してメールが送信できなかった場合でもどう調べればいいのか分からない、という問題点も・・・

また、SMTP AUTHに使うパスワードを平文で設定ファイルに書く必要があるというのも、なかなかな問題点です。

とはいえ、期待通りに動けば簡単に外部SMTPを使用してメール送信ができるし、各サーバに同じ設定を入れておくとシステム系メールの送信元メールアドレスを全て同じにする、ということも容易な感じです。

設定

esmtpの設定は、システム全体に適用される /etc/esmtprc と、各UNIXユーザごとの~/.esmtprc で行います。

とりあえずシステム系メールを送りたいだけであれば /etc/esmtprc を設定しておけばいい感じです。

/etc/esmtprc は用意されていないので /usr/share/doc/esmtp/sample.esmtprc にあるサンプルをコピーして使うか、必要なものだけを書きます。

sample.esmtprcの内容

# Sample configuration file for ESMTP.
#
#       Jose Fonseca

# Set SMTP host and service (port)
#
hostname = localhost:25

# Set the user name
#
username = "USERNAME"

# Set the password
password = "PASSWORD"

# Use the Starttls
#
#starttls = disabled
#
# It can be one of "enabled", "disabled" or "required". It defaults to
# disabled.

# Set the certificate passphrase
#
#certificate_passphrase = "CERTIFICATE_PASSPHRASE"

# Command to run before contacting the SMTP server
#
#preconnect = "ssh -f -L 2025:mail.isp.com:25 user@shell.isp.com 'sleep 5'"


# Same as above but for a different identity which can be selected with the
# '-f' flag. You can have as many you like.
#
identity = myself@somewhere.com
        hostname = smtp.somewhere.com:25
        username = "myself"
        password = "secret"
        #starttls = disabled
#
# NOTE: the default indentity settings aren't shared by the other identities.
# Everything (username, password, etc.) must be specified for every identity
# even if they don't differ from the default identity.


# Set the Mail Delivery Agent (MDA)
#
mda = "/usr/bin/procmail -d %T"
#
# Some possible MDAs are "/usr/bin/procmail -d %T", "/usr/bin/deliver" or
# "/usr/lib/mail.local %T".

これを使ってもいいのですが、必要なものだけを書いた方が簡単ですね。

外部のSMTPサーバを使って送信する設定例

Net@ddressというかれこれ20年以上使っているメールサービスのアカウントを使用してメール送信する設定です。

hostname=smtp.postoffice.net:25
username="ユーザ名@usa.net"
password="パスワード"

mda "/usr/bin/procmail -d %T"

これを /etc/esmtprc に書いたサーバから mailコマンドを使って送信したメールは全て「ユーザ名@usa.net」が発信元となって送られることになります。

また、「mda “/usr/bin/procmail -d %T”」という設定を入れているので、ローカルユーザ宛のメールであれば /var/spool/mail/ に配送されるようにしています。

SMTP送信時にstarttlsが必要な場合は「starttls=enabled」を追加すればいいようなのですが、下記の手順でやったのですが、送信されませんでした。

$ mkdir ~/.authenticate
$ chmod 0700 ~/.authenticate
$ wget http://curl.haxx.se/ca/cacert.pem
$ mv cacert.pem ~/.authenticate/ca.pem
$ chmod 0600 ~/.authenticate/ca.pem
$ mailx メール送り先@ドメイン名
Subject: test mail 5
test mail 5
.
EOT
$ 0 (null)
メール送り先@ドメイン名: 0 (null)
0 (null)
メール送り先@ドメイン名: 0 (null)
メール送り先@ドメイン名: 0 (null)
procmail: Unknown user "-r"
0 (null)
メール送り先@ドメイン名: 0 (null)
メール送り先@ドメイン名: 0 (null)
procmail: Unknown user "-r"

とりあえずstarttls対応は保留ですね。

なお、 /etc/esmtprcでは、下記の様な書式を使うこともできます。

identity ユーザ名@usa.net
        hostname smtp.postoffice.net:25
        username "ユーザ名@usa.net"
        password "パスワード"
        default

mda "/usr/bin/procmail -d %T"

ユーザによってアカウントを変える場合はこれを使うようです。


2021/07/02追記

さて、Oracle Linux 7環境でesmtpを設定してみたところ、cronで送られてくるメールが送信できていないようだ。

/etc/cron.daily/0logwatch:

You have old files in your logwatch tmpdir (/var/cache/logwatch):
        logwatch.idrC25J0
        logwatch.Hb7DUNNO
The directories listed above were most likely created by a
logwatch run that failed to complete successfully.  If so, you
may delete these directories.

/bin/mktemp: failed to create directory via template '/root/.esmtp_queue/XXXXXXX
X': Permission denied
unable to create tempdir inside /root/.esmtp_queue
/etc/cron.daily/0yum-daily.cron:

root宛に上記のような一時ファイルが作れないというエラーメールが届いていた。

/var/log/audit/audit.log 内を esmtp で検索してみると、下記の様にSELinuxの権限問題で書き込みが阻止されていた。

# grep esmt /var/log/audit/audit.log
type=AVC msg=audit(1623953887.619:18168): avc:  denied  { write } for  pid=23636 comm="mktemp" name=".esmtp_queue" dev="sda3" ino=2567447 scontext=system_u:system_r:logwatch_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:mail_home_rw_t:s0 tclass=dir permissive=0
#

/root/.esmtp_queue のSELinuxコンテキストを確認すると、mail_home_rw_tとなっている。要求はlogwatch

# ls -ldZ /root/.esmtp_queue
drwxr-xr-x. root root unconfined_u:object_r:mail_home_rw_t:s0 /root/.esmtp_queue
#

関係しそうな事例を発見
Bug 1366173 – /root/.esmtp_queue has bad context when created from a cron job
Bug 1592083 – SELinux is preventing touch from ‘create’ accesses on the archivo mail.
Bug 1295923 – SELinux is preventing sendmail from ‘read’ accesses on the directory .esmtp_queue.
Bug 1303305 – errors from esmtp in /var/log/messages every time my cron job runs
Bug 1149164 – SELinux is preventing esmtp from ‘read’ accesses on the file /.esmtp_queue/4PVJsKZY/mail.

ただ、上記は調査方法や解決方法に関して直接の記載がない。

また、Bug 1303305 には、esmtpはローカル配送にのみ使え、なんて書かれている。

Fedora MaillingList「Trying to use mailx for logwatch」に確認してくヒントがあった。

まず、「logwatch_t」で設定されている内容の確認してみる

# sesearch -T -s logwatch_t
Found 12 semantic te rules:
   type_transition logwatch_t postfix_postdrop_t : process logwatch_mail_t;
   type_transition logwatch_t abrt_helper_exec_t : process abrt_helper_t;
   type_transition logwatch_t ntpd_exec_t : process ntpd_t;
   type_transition logwatch_t postfix_postqueue_exec_t : process postfix_postqueue_t;
   type_transition logwatch_t sendmail_exec_t : process logwatch_mail_t;
   type_transition logwatch_t var_lock_t : file logwatch_lock_t;
   type_transition logwatch_t courier_exec_t : process logwatch_mail_t;
   type_transition logwatch_t mdadm_exec_t : process mdadm_t;
   type_transition logwatch_t tmp_t : dir logwatch_tmp_t;
   type_transition logwatch_t tmp_t : file logwatch_tmp_t;
   type_transition logwatch_t exim_exec_t : process logwatch_mail_t;
   type_transition logwatch_t var_run_t : file logwatch_var_run_t;

#

ターゲット側が mail_home_rw_t なものを調べて見ると

# sesearch -T | grep mail_home_rw_t
type_transition cups_pdf_t user_home_dir_t : dir mail_home_rw_t "Maildir";
type_transition cinder_backup_t user_home_dir_t : dir mail_home_rw_t "Maildir";
type_transition conman_unconfined_script_t admin_home_t : file mail_home_rw_t ".esmtp_queue";
<略>
type_transition samba_unconfined_script_t user_home_dir_t : dir mail_home_rw_t ".esmtp_queue";
type_transition vmtools_unconfined_t admin_home_t : dir mail_home_rw_t ".maildir";
# sesearch -T |grep mail_home_rw_t |wc
    886    6202   72157
#

886個設定されているようだ。

「logwatch」が関連しているものに限定してみると

# sesearch -T |grep mail_home_rw_t |grep logwatch
type_transition logwatch_mail_t admin_home_t : dir mail_home_rw_t ".esmtp_queue";
type_transition logwatch_mail_t user_home_dir_t : file mail_home_rw_t ".esmtp_queue";
type_transition logwatch_mail_t user_home_dir_t : dir mail_home_rw_t ".maildir";
type_transition logwatch_mail_t admin_home_t : dir mail_home_rw_t ".maildir";
type_transition logwatch_mail_t user_home_dir_t : dir mail_home_rw_t "Maildir";
type_transition logwatch_mail_t admin_home_t : file mail_home_rw_t ".esmtp_queue";
type_transition logwatch_mail_t user_home_dir_t : dir mail_home_rw_t ".esmtp_queue";
type_transition logwatch_mail_t admin_home_t : dir mail_home_rw_t "Maildir";
#

ソースターゲットが logwatch_mail_t でいろいろ設定されているようなので、「logwatch_mail_t」で調べて見る

# sesearch -T -s logwatch_mail_t
Found 15 semantic te rules:
   type_transition logwatch_mail_t postfix_etc_t : file etc_aliases_t;
   type_transition logwatch_mail_t postfix_postqueue_exec_t : process postfix_postqueue_t;
   type_transition logwatch_mail_t abrt_helper_exec_t : process abrt_helper_t;
   type_transition logwatch_mail_t tmp_t : file logwatch_mail_tmp_t;
   type_transition logwatch_mail_t postfix_etc_t : lnk_file etc_aliases_t;
   type_transition logwatch_mail_t tmp_t : dir logwatch_mail_tmp_t;
   type_transition logwatch_mail_t var_log_t : file sendmail_log_t;
   type_transition logwatch_mail_t postfix_showq_exec_t : process postfix_showq_t;
   type_transition logwatch_mail_t postfix_etc_t : sock_file etc_aliases_t;
   type_transition logwatch_mail_t qmail_inject_exec_t : process qmail_inject_t;
   type_transition logwatch_mail_t exim_exec_t : process exim_t;
   type_transition logwatch_mail_t postfix_postdrop_exec_t : process postfix_postdrop_t;
   type_transition logwatch_mail_t postfix_etc_t : dir etc_aliases_t;
   type_transition logwatch_mail_t qmail_queue_exec_t : process qmail_queue_t;
   type_transition logwatch_mail_t postfix_etc_t : fifo_file etc_aliases_t;

Found 14 named file transition filename_trans:
type_transition logwatch_mail_t admin_home_t : dir mail_home_rw_t ".esmtp_queue";
type_transition logwatch_mail_t user_home_dir_t : file mail_home_rw_t ".esmtp_queue";
type_transition logwatch_mail_t user_home_dir_t : dir mail_home_rw_t ".maildir";
type_transition logwatch_mail_t admin_home_t : dir mail_home_rw_t ".maildir";
type_transition logwatch_mail_t user_home_dir_t : file mail_home_t "dead.letter";
type_transition logwatch_mail_t user_home_dir_t : dir mail_home_rw_t "Maildir";
type_transition logwatch_mail_t user_home_dir_t : file mail_home_t ".mailrc";
type_transition logwatch_mail_t admin_home_t : file mail_home_t "dead.letter";
type_transition logwatch_mail_t admin_home_t : file mail_home_rw_t ".esmtp_queue";
type_transition logwatch_mail_t user_home_dir_t : dir mail_home_rw_t ".esmtp_queue";
type_transition logwatch_mail_t admin_home_t : file mail_home_t ".forward";
type_transition logwatch_mail_t admin_home_t : dir mail_home_rw_t "Maildir";
type_transition logwatch_mail_t admin_home_t : file mail_home_t ".mailrc";
type_transition logwatch_mail_t user_home_dir_t : file mail_home_t ".forward";
#

最初に実行した sesearch -T -s logwatch_t の結果内にいくつか logwatch_mail_t への定義が描かれているがcronからのメール送信には適用されていない?

仕方がないので /var/log/audit/audit.log* の出力結果から書き込みなどの操作エラーの発生対象である mail_home_rw_t について抜き出す

# grep deni /var/log/audit/audit.log*|grep mail_home_rw_t
<略>
/var/log/audit/audit.log.4:type=AVC msg=audit(1623953887.619:18168): avc:  denied  { write } for  pid=23636 comm="mktemp" name=".esmtp_queue" dev="sda3" ino=2567447 scontext=system_u:system_r:logwatch_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:mail_home_rw_t:s0 tclass=dir permissive=0
/var/log/audit/audit.log.4:type=AVC msg=audit(1624041848.311:27261): avc:  denied  { add_name } for  pid=5082 comm="mktemp" name="PcKUa8QZ" scontext=system_u:system_r:logwatch_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:mail_home_rw_t:s0 tclass=dir permissive=0
/var/log/audit/audit.log.4:type=AVC msg=audit(1624126686.899:34916): avc:  denied  { add_name } for  pid=15196 comm="mktemp" name="jiIjNaug" scontext=system_u:system_r:logwatch_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:mail_home_rw_t:s0 tclass=dir permissive=0
#

これをaudit2allowコマンドでSELinuxのモジュール化して、読み込む。

# grep deni /var/log/audit/audit.log*|grep mail_home_rw_t

#============= logwatch_t ==============

#!!!! This avc is allowed in the current policy
allow logwatch_t mail_home_rw_t:dir create;
allow logwatch_t mail_home_rw_t:file create;
# grep deni /var/log/audit/audit.log*|grep mail_home_rw_t | audit2allow -M mktemp

******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i mktemp.pp

# semodule -i mktemp.pp
# semodule -l | mktemp
mktemp  1.0
#

ただ、1回だけではだめで、何回か追加を繰り替えすことになった。

最終的に作成された mktemp.te ファイルは下記となった。

module mktemp 1.0.8;

require {
        type logwatch_t;
        type mail_home_rw_t;
        class file { create link open read setattr unlink write };
        class dir { add_name create read remove_name rmdir write };
}

#============= logwatch_t ==============

#!!!! This avc is allowed in the current policy
allow logwatch_t mail_home_rw_t:dir { add_name create read remove_name rmdir write };

#!!!! This avc is allowed in the current policy
allow logwatch_t mail_home_rw_t:file { create link open read setattr unlink write };

こうやって作成したテキストのteファイルを modファイル経由で pp形式に出力

# checkmodule -M -m -o mktemp.mod mktemp.te
checkmodule:  loading policy configuration from mktemp.te
checkmodule:  policy configuration loaded
checkmodule:  writing binary representation (version 19) to mktemp.mod
# semodule_package -o mktemp.pp -m mktemp.mod
#

現在のモジュール状況を確認して、読み込み

# semodule -l | grep mktemp
mktemp  1.0.7
# semodule -i mktemp.pp
# semodule -l | grep mktemp
mktemp  1.0.8
#

モジュールのバージョンが変更されたことを確認。

なお、不要になったモジュールは「semodule -r モジュール名」で削除できる。