殺死特定IP的監聽端口

殺死特定IP的監聽端口

我有一個具有多個網路介面的 SIP 伺服器。 (虛擬)當我執行命令時,netstat -nlput它顯示所有偵聽 IP 和端口,如下所示。

root@DUO-CALLSERVER004:/etc/init.d# netstat -nlput
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      723/rpcbind
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 172.20.112.238:8021     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1835/sshd
tcp        0      0 0.0.0.0:5666            0.0.0.0:*               LISTEN      1868/nrpe
tcp        0      0 172.20.112.118:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 172.20.112.117:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 172.20.112.114:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 172.20.112.112:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 172.20.112.110:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 172.20.112.238:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 172.20.112.111:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 172.20.112.116:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 172.20.112.115:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp        0      0 192.168.52.108:5060     0.0.0.0:*               LISTEN      21036/freeswitch
tcp6       0      0 :::111                  :::*                    LISTEN      723/rpcbind
tcp6       0      0 :::22                   :::*                    LISTEN      1835/sshd
tcp6       0      0 :::5666                 :::*                    LISTEN      1868/nrpe
udp        0      0 172.20.112.118:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 172.20.112.117:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 172.20.112.114:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 172.20.112.112:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 172.20.112.110:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 172.20.112.238:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 172.20.112.111:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 172.20.112.116:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 172.20.112.115:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 192.168.52.108:5060     0.0.0.0:*                           21036/freeswitch
udp        0      0 0.0.0.0:111             0.0.0.0:*                           723/rpcbind
udp        0      0 0.0.0.0:731             0.0.0.0:*                           723/rpcbind
udp6       0      0 :::111                  :::*                                723/rpcbind
udp6       0      0 :::731                  :::*                                723/rpcbind

我想要的是殺死正在偵聽 172.20.112.117:5060 的連接埠 5060。但另一組 IP 也列出了使用相同 PID 的相同連接埠。我不想殺掉那些人。只有172.20.112.117 IP需要從5060埠釋放。有沒有辦法做到這一點?

答案1

配置進程的方式使他僅綁定到正確的位址而不是0.0.0.0.如果過程是自由切換你應該看看配置。來自郵件清單(儘管已過時):

老兄,直接使用預設配置:

<!-- bind_server_ip
   Can be an ip address, a dns name, or "auto".
   This determines an ip address available on this host to bind.
   If you are separating RTP and SIP traffic, you will want to have
   use different addresses where this variable appears.
   Used by: sofia.conf.xml dingaling.conf.xml
-->
  <X-PRE-PROCESS cmd="set" data="bind_server_ip=auto"/>

或者從維基百科

相關內容