プロセスリストを出力するlsof(エルエスオーエフ)をインストール

# pkg install lsof
Updating FreeBSD repository catalogue...
Fetching meta.conf: 100%    163 B   0.2kB/s    00:01
Fetching packagesite.txz: 100%    6 MiB   1.3MB/s    00:05
Processing entries: 100%
FreeBSD repository update completed. 30508 packages processed.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        lsof: 4.94.0,8

Number of packages to be installed: 1

112 KiB to be downloaded.

Proceed with this action? [y/N]:

[1/1] Fetching lsof-4.94.0,8.txz: 100%  112 KiB 114.2kB/s    00:01
Checking integrity... done (0 conflicting)
[1/1] Installing lsof-4.94.0,8...
[1/1] Extracting lsof-4.94.0,8: 100%
=====
Message from lsof-4.94.0,8:

--
NOTE: Due to the way the FreeBSD build clusters make packages,
you may see a warning similar to the following:

lsof: WARNING: compiled for FreeBSD release 11.1-RELEASE-p6; this is 11.1-RELEASE-p4.

This is because the poudriere jails that build the packages don't have the
corresponding kernel installed, so they don't know that the kernel version is different.

This warning can be ignored if you are using a system that is updated via freebsd-update
and are using pre-built packages.

 

ポート番号を指定して確認

# lsof -i:53
COMMAND PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
named   533 bind   16u  IPv4 0xfffff80003ad0020      0t0  UDP www.server-bff.net:domain
named   533 bind   18u  IPv4 0xfffff80003aee000      0t0  TCP www.server-bff.net:domain (LISTEN)
named   533 bind   19u  IPv6 0xfffff80003ad0000      0t0  UDP localhost:domain
named   533 bind   21u  IPv6 0xfffff80003aefb70      0t0  TCP localhost:domain (LISTEN)
named   533 bind   22u  IPv6 0xfffff80003ad1f80      0t0  UDP [fe80:2::1]:domain
named   533 bind   23u  IPv6 0xfffff80003aef7a0      0t0  TCP [fe80:2::1]:domain (LISTEN)
named   533 bind   24u  IPv4 0xfffff80003ad1f60      0t0  UDP localhost:domain
named   533 bind   25u  IPv4 0xfffff80003aef3d0      0t0  TCP localhost:domain (LISTEN)

 

ntpを指定して確認

# lsof -c ntp

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ntpd    13659 ntpd  cwd   VDIR              0,101     1024    2 /
ntpd    13659 ntpd  rtd   VDIR              0,101     1024    2 /
ntpd    13659 ntpd    0r  VCHR               0,18      0t0   18 /dev/null
ntpd    13659 ntpd    1r  VCHR               0,18      0t0   18 /dev/null
ntpd    13659 ntpd    2r  VCHR               0,18      0t0   18 /dev/null
ntpd    13659 ntpd    3u  unix 0xfffff8007744d6d0      0t0      ->0xfffff80003ada368
ntpd    13659 ntpd   20u  IPv6 0xfffff8007799a200      0t0  UDP *:ntp
ntpd    13659 ntpd   21u  IPv4 0xfffff8007799a9c0      0t0  UDP *:ntp
ntpd    13659 ntpd   22u  IPv4 0xfffff80003ad1020      0t0  UDP www.server-bff.net:ntp
ntpd    13659 ntpd   23u  IPv6 0xfffff8007799aa00      0t0  UDP localhost:ntp
ntpd    13659 ntpd   24u  IPv6 0xfffff80003ad1640      0t0  UDP [fe80:2::1]:ntp
ntpd    13659 ntpd   25u  IPv4 0xfffff8007799a6c0      0t0  UDP localhost:ntp
ntpd    13659 ntpd   26u   rte 0xfffff800b376e380      0t0

 

LISTEN確認

# lsof -i | grep LISTEN
named      533  bind   18u  IPv4 0xfffff80003aee000      0t0  TCP www.server-bff.net:domain (LISTEN)
named      533  bind   21u  IPv6 0xfffff80003aefb70      0t0  TCP localhost:domain (LISTEN)
named      533  bind   23u  IPv6 0xfffff80003aef7a0      0t0  TCP [fe80:2::1]:domain (LISTEN)
named      533  bind   25u  IPv4 0xfffff80003aef3d0      0t0  TCP localhost:domain (LISTEN)
named      533  bind   26u  IPv4 0xfffff80003aef000      0t0  TCP localhost:rndc (LISTEN)
mariadbd   797 mysql   21u  IPv4 0xfffff80003c593d0      0t0  TCP localhost:mysql (LISTEN)
sshd       833  root    3u  IPv6 0xfffff80003c5a3d0      0t0  TCP *:ssh (LISTEN)
sshd       833  root    4u  IPv4 0xfffff80003af17a0      0t0  TCP *:ssh (LISTEN)
sendmail   854  root    4u  IPv4 0xfffff80003af1b70      0t0  TCP localhost:smtp (LISTEN)
httpd    20117  root    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    20117  root    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    20117  root    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    20117  root    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    25574   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    25574   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    25574   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    25574   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    25747   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    25747   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    25747   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    25747   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    29014   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    29014   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    29014   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    29014   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    29508   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    29508   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    29508   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    29508   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    29523   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    29523   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    29523   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    29523   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    29525   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    29525   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    29525   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    29525   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    29528   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    29528   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    29528   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    29528   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    29592   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    29592   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    29592   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    29592   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    29674   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    29674   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    29674   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    29674   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)
httpd    29760   www    3u  IPv6 0xfffff800989db000      0t0  TCP *:http (LISTEN)
httpd    29760   www    4u  IPv4 0xfffff80077b9d000      0t0  TCP *:http (LISTEN)
httpd    29760   www    6u  IPv6 0xfffff80003af0b70      0t0  TCP *:https (LISTEN)
httpd    29760   www    7u  IPv4 0xfffff800772343d0      0t0  TCP *:https (LISTEN)

 

以上