关闭特定 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"/>

或者从维基百科

相关内容