Is there a way to find out on which port my asterisk software is running using command line interface or by any other way?
Asterisk supports more Protocols than SIP and IAX2, but these Ports are the typical Voice-Protocol Ports and may get forwarded from your Router (Firewall) to the Asterisk Server (because of NAT):
You can also check the asterisk (modules) ports with:
lsof -n -i -P
You may find additional ports, based on your loaded modules (modules.conf) and configuration, for example TCP:5038 (manager.conf).
List your modules with:
asterisk -rx 'module show'
or for older versions: asterisk -rx 'show modules'
.
Modules can be autoloaded and disabled with noload => modulename.so
in modules.conf.