Saturday, May 16, 2009

Reduce the number of ports opened by Asterisk

When I type the command netstat -lnp | grep asterisk as root, I found the following ports were opened by Asterisk.
tcp 0 0 192.168.0.1:5038 0.0.0.0:* LISTEN 2850/asterisk
tcp 0 0 0.0.0.0:2000 0.0.0.0:* LISTEN 2850/asterisk
tcp 0 0 192.168.0.1:8088 0.0.0.0:* LISTEN 2850/asterisk
udp 0 0 0.0.0.0:4569 0.0.0.0:* 2850/asterisk
udp 0 0 0.0.0.0:2727 0.0.0.0:* 2850/asterisk
udp 0 0 0.0.0.0:4520 0.0.0.0:* 2850/asterisk
udp 0 0 0.0.0.0:5060 0.0.0.0:* 2850/asterisk
unix 2 [ ACC ] STREAM LISTENING 762262 2850/asterisk /var/run/asterisk/asterisk.ctl


I know that the following ports are typically used by my Asterisk
tcp 5038 manager
tcp 8088 AsteriskNOW
udp 4569 iax2
udp 5060 sip
udp 18000-20000 rtp (rtp.conf)

Therefore I put the following lines into /etc/asterisk/modules.conf
; Don't load skinny (tcp port 2000)
noload => chan_skinny.so
; Don't load MGCP (udp port 2727)
noload => chan_mgcp.so
; Don't load dundi (udp port 4520)
noload => pbx_dundi.so


Upon restarting Asterisk, the command netstat -lnp | grep asterisk only shows the following:
tcp 0 0 192.168.0.1:5038 0.0.0.0:* LISTEN 3168/asterisk
tcp 0 0 192.168.0.1:8088 0.0.0.0:* LISTEN 3168/asterisk
udp 0 0 0.0.0.0:4569 0.0.0.0:* 3168/asterisk
udp 0 0 0.0.0.0:5060 0.0.0.0:* 3168/asterisk
unix 2 [ ACC ] STREAM LISTENING 764510 3168/asterisk /var/run/asterisk/asterisk.ctl

2 comments:

Anonymous said...

Thanks very much for this info! Saved me a bunch of time!

Seweryn Niemiec said...

Thanks, very useful info.