株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

結論、/proc/net/tcpを見る。
コンテナ自体がユーザー権限で動作させていると、起動しているコンテナでパッケージインストールができないので、それ以外の方法でなんとかするしかない。

  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode
   0: 00000000:0050 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 16353 1 0000000000000000 100 0 0 10 0
   1: DB51020A:CE98 5BDA7734:01BB 01 0000014E:00000000 01:00000014 00000000     0        0 19688 4 0000000000000000 20 4 31 10 -1
   2: DB51020A:A51C CCCCB512:01BB 06 00000000:00000000 03:00001482 00000000     0        0 0 3 0000000000000000
  ~ 省略

local_address、rem_address、stが重要。
netstatのLocalAddress,ForeingAddres、Statusに対応している模様。
16進数表記なので10進数に変換する。
0行目の意味するところは、0.0.0.0:80がListenしている。
stの紐付けは下記の通り。

  • ESTABLISHED = 01
  • TIME_WAIT = 06
  • LISTEN = 0A (10)
>>> int('00000000',16)
0
>>> int('0050',16)
80
>>>
>>> int('0A',16)
10

2行目移行はこのような感じ

>>> import ipaddress
>>> int('DB51020A',16)
3679519242
>>> ipaddress.IPv4Address(3679519242)
IPv4Address('219.81.2.10')
>>> int('CE98',16)
52888
>>>
>>>

参考
https://elixir.bootlin.com/linux/latest/source/include/net/tcp_states.h#L13

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)