Sunday, January 20, 2008

listening on 0.0.0.0

After you start your Tomacat/Apache HTTPD Server:

just go to the command line and use netstat -an command to check the network statistics. You might have noticed
foobar:~ nrs$ netstat -an | grep LISTEN
tcp46 0 0 *.8080 *.* LISTEN
tcp4 0 0 192.168.2.101.3873 *.* LISTEN

that the listening port is listed as either *.8080 or 0.0.0.0:8080.

Basically this means that your server is listening for connection from all the network interfaces in your machine. i.e. if you have Wi-Fi, ethernet or couple of other VirtualMachine ethernet port configured. Then you can reach the server using any of those interfaces (IP address).

You could reach the server using 127.0.0.1 (local host), and any IP address of one of the network interfaces you have. So even when you write socket programming code, use the server host address as 0.0.0.0 if you want that your server to be reachable through all the interfaces.

You could also use the same feature to gain precise control of how your application can be reached. When you start the server in production or other critical environments it just be better that the server listens only in single IP address that is the expected interface for reaching the service.

In JBoss application server you can control this attribute either in the configuration file, or through system property jboss.bind.address. This property can also have multiple values separated by comma (i.e. jboss.bind.address=127.0.0.0,232.213.232.12). This helps to control precisely through which interface your service were accessible.
C:\jboss-home\bin>.\run.bat -Djboss.bind.address=0.0.0.0 -c default

1 comment:

Srinivasan said...

yes you are right. That's all. You can run ipconfig command in windows; or ifconfig on linux to get the current list of such ip addresses.

Recommended Blog Posts