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:~#
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:33:27:f8 brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 172.17.44.48/16 brd 172.17.255.255 scope global noprefixroute ens160
===buffer===
ip a s ens160
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:33:27:f8 brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 172.17.44.48/16 brd 172.17.255.255 scope global noprefixroute ens160
===str0===
inet 172.17.44.48/16 brd 172.17.255.255 scope global noprefixroute ens160
===str1===
172.17.44.48/16 brd 172.17.255.255 scope global noprefixroute ens160
====
valid_lft forever preferred_lft forever
inet6 fe80::cca7:388a:36e7:d688/64 scope link noprefixroute
valid_lft forever preferred_lft forever
条件を「inet (.*)\r」から「inet6 (.*)\r」に変更
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:33:27:f8 brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 172.17.44.48/16 brd 172.17.255.255 scope global noprefixroute ens160
valid_lft forever preferred_lft forever
inet6 fe80::cca7:388a:36e7:d688/64 scope link noprefixroute
valid_lft forever preferred_lft forever
===buffer===
ip a s ens160
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:33:27:f8 brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 172.17.44.48/16 brd 172.17.255.255 scope global noprefixroute ens160
valid_lft forever preferred_lft forever
inet6 fe80::cca7:388a:36e7:d688/64 scope link noprefixroute
valid_lft forever preferred_lft forever
===str0===
inet6 fe80::cca7:388a:36e7:d688/64 scope link noprefixroute
valid_lft forever preferred_lft forever
===str1===
fe80::cca7:388a:36e7:d688/64 scope link noprefixroute
valid_lft forever preferred_lft forever
====
ここからさらにIPアドレスの部分を取り出すには「string first ~」「string last ~」と「string range ~」を使って文字列を切り出す。
set str $expect_out(1,string)
set stred [string first "/" $str]
puts "[string range $str 0 $stred]"
set stred [expr $stred - 1]
puts "[string range $str 0 $stred]"
上記の実行結果としては下記のようになる。
172.17.44.48/
172.17.44.48
他の言語のsubstring系だと開始アドレスと、そこを起点に取り出す文字列の長さを指定するが、tclのstring range では、開始アドレスと終了アドレスの2つを指定する形になるので注意が必要になる。