ytooyamaのブログ

サーバ構築とか、仕事で発見したこととか、趣味のこととかを書いています。

「utun」がいっぱい

導入

普段遣いのMac環境でifconfigコマンドを実行したら、utunインターフェイスがたくさんあるのがすごい気になりました。 早速、調べてみることにしました。

utun0: flags=8050<POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::4ef3:be8:dfda:e043%utun0 prefixlen 64 scopeid 0x12 
    nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
    inet6 fe80::3635:3459:5043:e309%utun1 prefixlen 64 scopeid 0x13 
    nd6 options=201<PERFORMNUD,DAD>
utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1000
    inet6 fe80::ce81:b1c:bd2c:69e%utun2 prefixlen 64 scopeid 0x14 
    nd6 options=201<PERFORMNUD,DAD>
utun3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::2b1c:bcb4:641c:5980%utun3 prefixlen 64 scopeid 0x15 
    nd6 options=201<PERFORMNUD,DAD>
utun4: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::8e4c:ba7d:8327:6fb9%utun4 prefixlen 64 scopeid 0x16 
    nd6 options=201<PERFORMNUD,DAD>
utun5: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::1312:b063:64b4:7c12%utun5 prefixlen 64 scopeid 0x17 
    nd6 options=201<PERFORMNUD,DAD>
utun6: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::e382:6131:1dff:8966%utun6 prefixlen 64 scopeid 0x18 
    nd6 options=201<PERFORMNUD,DAD>
utun7: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::5086:f647:cb54:d5e8%utun7 prefixlen 64 scopeid 0x19 
    nd6 options=201<PERFORMNUD,DAD>
utun8: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::fb14:6deb:4563:868a%utun8 prefixlen 64 scopeid 0x1a 
    nd6 options=201<PERFORMNUD,DAD>
utun9: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::bc9f:ddee:1142:601c%utun9 prefixlen 64 scopeid 0x1b 
    nd6 options=201<PERFORMNUD,DAD>
utun10: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::9b2c:1349:98c:a18a%utun10 prefixlen 64 scopeid 0x1c 
    nd6 options=201<PERFORMNUD,DAD>

何者が使っているのか調べたらルーティングされていますね。

$ netstat -rn | grep utun
default                                 fe80::%utun0                    UGcIg           utun0       
default                                 fe80::%utun1                    UGcIg           utun1       
default                                 fe80::%utun2                    UGcIg           utun2       
default                                 fe80::%utun3                    UGcIg           utun3       
default                                 fe80::%utun4                    UGcIg           utun4       
default                                 fe80::%utun5                    UGcIg           utun5       
default                                 fe80::%utun6                    UGcIg           utun6       
default                                 fe80::%utun7                    UGcIg           utun7       
default                                 fe80::%utun8                    UGcIg           utun8       
default                                 fe80::%utun9                    UGcIg           utun9       
default                                 fe80::%utun10                   UGcIg          utun10       
fe80::3635:3459:5043:e309%utun1         link#19                         UHLI              lo0       
fe80::ce81:b1c:bd2c:69e%utun2           link#20                         UHLI              lo0       
fe80::2b1c:bcb4:641c:5980%utun3         link#21                         UHLI              lo0       
fe80::8e4c:ba7d:8327:6fb9%utun4         link#22                         UHLI              lo0       
fe80::1312:b063:64b4:7c12%utun5         link#23                         UHLI              lo0       
fe80::e382:6131:1dff:8966%utun6         link#24                         UHLI              lo0       
fe80::5086:f647:cb54:d5e8%utun7         link#25                         UHLI              lo0       
fe80::fb14:6deb:4563:868a%utun8         link#26                         UHLI              lo0       
fe80::bc9f:ddee:1142:601c%utun9         link#27                         UHLI              lo0       
fe80::9b2c:1349:98c:a18a%utun10         link#28                         UHLI              lo0       
ff00::/8                                fe80::4ef3:be8:dfda:e043%utun0  UmCI            utun0       
ff00::/8                                fe80::3635:3459:5043:e309%utun1 UmCI            utun1       
ff00::/8                                fe80::ce81:b1c:bd2c:69e%utun2   UmCI            utun2       
ff00::/8                                fe80::2b1c:bcb4:641c:5980%utun3 UmCI            utun3       
ff00::/8                                fe80::8e4c:ba7d:8327:6fb9%utun4 UmCI            utun4       
ff00::/8                                fe80::1312:b063:64b4:7c12%utun5 UmCI            utun5       
ff00::/8                                fe80::e382:6131:1dff:8966%utun6 UmCI            utun6       
ff00::/8                                fe80::5086:f647:cb54:d5e8%utun7 UmCI            utun7       
ff00::/8                                fe80::fb14:6deb:4563:868a%utun8 UmCI            utun8       
ff00::/8                                fe80::bc9f:ddee:1142:601c%utun9 UmCI            utun9       
ff00::/8                                fe80::9b2c:1349:98c:a18a%utun10 UmCI           utun10       
ff01::%utun0/32                         fe80::4ef3:be8:dfda:e043%utun0  UmCI            utun0       
ff01::%utun1/32                         fe80::3635:3459:5043:e309%utun1 UmCI            utun1       
ff01::%utun2/32                         fe80::ce81:b1c:bd2c:69e%utun2   UmCI            utun2       
ff01::%utun3/32                         fe80::2b1c:bcb4:641c:5980%utun3 UmCI            utun3       
ff01::%utun4/32                         fe80::8e4c:ba7d:8327:6fb9%utun4 UmCI            utun4       
ff01::%utun5/32                         fe80::1312:b063:64b4:7c12%utun5 UmCI            utun5       
ff01::%utun6/32                         fe80::e382:6131:1dff:8966%utun6 UmCI            utun6       
ff01::%utun7/32                         fe80::5086:f647:cb54:d5e8%utun7 UmCI            utun7       
ff01::%utun8/32                         fe80::fb14:6deb:4563:868a%utun8 UmCI            utun8       
ff01::%utun9/32                         fe80::bc9f:ddee:1142:601c%utun9 UmCI            utun9       
ff01::%utun10/32                        fe80::9b2c:1349:98c:a18a%utun10 UmCI           utun10       
ff02::%utun0/32                         fe80::4ef3:be8:dfda:e043%utun0  UmCI            utun0       
ff02::%utun1/32                         fe80::3635:3459:5043:e309%utun1 UmCI            utun1       
ff02::%utun2/32                         fe80::ce81:b1c:bd2c:69e%utun2   UmCI            utun2       
ff02::%utun3/32                         fe80::2b1c:bcb4:641c:5980%utun3 UmCI            utun3       
ff02::%utun4/32                         fe80::8e4c:ba7d:8327:6fb9%utun4 UmCI            utun4       
ff02::%utun5/32                         fe80::1312:b063:64b4:7c12%utun5 UmCI            utun5       
ff02::%utun6/32                         fe80::e382:6131:1dff:8966%utun6 UmCI            utun6       
ff02::%utun7/32                         fe80::5086:f647:cb54:d5e8%utun7 UmCI            utun7       
ff02::%utun8/32                         fe80::fb14:6deb:4563:868a%utun8 UmCI            utun8       
ff02::%utun9/32                         fe80::bc9f:ddee:1142:601c%utun9 UmCI            utun9       
ff02::%utun10/32                        fe80::9b2c:1349:98c:a18a%utun10 UmCI           utun10 

調査

次のような情報を見つけました。

95個utunインターフェイスが出来ると、ネットワーク接続の問題が発生することがあるそうです。Venturaの場合。

本来は使わなくなればutunインターフェイスは削除されるらしくて、再起動することでいらないutunインターフェイスはクリーンアップされるらしいのですが、 私の環境はいくら再起動しても10個存在するまんまでした。

ifconfig utun10 downとかやるとエラーとかにはならないけど、リンクアップしたままでIPv6アドレスを掴んだままだし、ifconfig utun10 deleteはエラーでできません。

Tunnelblickはutunインターフェイスはきちんと切断すると一時的に作ったutunインターフェイスを削除するのだけど、 強制終了したりOpenVPNのバージョンによってはうまく消せずに残ってしまうことがあるようです。

使われるインターフェイス名は固定ではないので、使われていると判断されていない名前のインターフェイスを一時的に作るのだとか。 なので状況が悪いと無限にutunが量産されて、macOSの場合それが95個に達するとネットワークに色々問題が起きるようです。

utunインターフェイスはVPNアプリケーション以外でも作成する事があるらしいのですが、 Appleのデベロッパーフォーラムの記事の投稿の中にあった、以下の方法を実行してmacOSを再起動したらクリーンアップできました。

sudo route delete -inet6 fe80::%utun0 
...
sudo route delete -inet6 fe80::%utun10 

実行後

再起動後、3つのutunインターフェイスだけになりました。 0,1,2は本当に何かが使用中だったんですね。

$ netstat -rn | grep utun
default                                 fe80::%utun0                    UGcIg           utun0       
default                                 fe80::%utun1                    UGcIg           utun1       
default                                 fe80::%utun2                    UGcIg           utun2       
fe80::%utun0/64                         fe80::4383:5991:b097:a77f%utun0 UcI             utun0       
fe80::4383:5991:b097:a77f%utun0         link#18                         UHLI              lo0       
fe80::%utun1/64                         fe80::b81a:44e2:60ce:102f%utun1 UcI             utun1       
fe80::b81a:44e2:60ce:102f%utun1         link#19                         UHLI              lo0       
fe80::%utun2/64                         fe80::ce81:b1c:bd2c:69e%utun2   UcI             utun2       
fe80::ce81:b1c:bd2c:69e%utun2           link#20                         UHLI              lo0       
ff00::/8                                fe80::4383:5991:b097:a77f%utun0 UmCI            utun0       
ff00::/8                                fe80::b81a:44e2:60ce:102f%utun1 UmCI            utun1       
ff00::/8                                fe80::ce81:b1c:bd2c:69e%utun2   UmCI            utun2       
ff01::%utun0/32                         fe80::4383:5991:b097:a77f%utun0 UmCI            utun0       
ff01::%utun1/32                         fe80::b81a:44e2:60ce:102f%utun1 UmCI            utun1       
ff01::%utun2/32                         fe80::ce81:b1c:bd2c:69e%utun2   UmCI            utun2       
ff02::%utun0/32                         fe80::4383:5991:b097:a77f%utun0 UmCI            utun0       
ff02::%utun1/32                         fe80::b81a:44e2:60ce:102f%utun1 UmCI            utun1       
ff02::%utun2/32                         fe80::ce81:b1c:bd2c:69e%utun2   UmCI            utun2

再起動後にTunelblickでVPNを張るとutun3インターフェイスが増えましたが、切断すると元の状態に戻りました。 とりあえず良い感じです。

Tunelblickで接続後

utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::4383:5991:b097:a77f%utun0 prefixlen 64 scopeid 0x12 
    nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
    inet6 fe80::b81a:44e2:60ce:102f%utun1 prefixlen 64 scopeid 0x13 
    nd6 options=201<PERFORMNUD,DAD>
utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1000
    inet6 fe80::ce81:b1c:bd2c:69e%utun2 prefixlen 64 scopeid 0x14 
    nd6 options=201<PERFORMNUD,DAD>
utun3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
    inet 172.16.9.7 --> 172.16.9.7 netmask 0xffffff00 

Tunelblick接続前及び切断後

utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::4383:5991:b097:a77f%utun0 prefixlen 64 scopeid 0x12 
    nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
    inet6 fe80::b81a:44e2:60ce:102f%utun1 prefixlen 64 scopeid 0x13 
    nd6 options=201<PERFORMNUD,DAD>
utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1000
    inet6 fe80::ce81:b1c:bd2c:69e%utun2 prefixlen 64 scopeid 0x14 
    nd6 options=201<PERFORMNUD,DAD>

とはいえ、今更ですが気にしない方がいいと思います。 どうせしばらくしているとまた増えると思うので。

このブログサイトはJavaScriptを使っていますが、読み込んでいるJavaScriptは全てはてなが提供しているものであり、筆者が設置しているものではありません。