Question: How do I "set" the canonical hostname as reported by java's InetAddress.getCanonicalHostname()
method?
Context: I'm trying to run Neo4j (which has an embedded jetty server) on CentOS 5.6. The service starts up just fine, but it's binding to the wrong address (IPv6) as evidenced by netstat. Instead of :::*
, I need it to bind to 0.0.0.0
(IPv4).
Is there a JVM parameter I can use to force getCanoncialHostname()
to return the string I want? If not, what can I add to my hosts
file or other linux config file to achieve the same?
[edit - added netstat output]
$ netstat -plten
...
Proto Local Address Foreign Address State User Inode PID/Program name
tcp 0.0.0.0:930 0.0.0.0:* LISTEN 0 10240 -
tcp 0.0.0.0:139 0.0.0.0:* LISTEN 0 57484 -
tcp 0.0.0.0:111 0.0.0.0:* LISTEN 0 10104 -
tcp 127.0.0.1:25 0.0.0.0:* LISTEN 0 12714 -
tcp 0.0.0.0:445 0.0.0.0:* LISTEN 0 57483 -
tcp :::7474 :::* LISTEN 500 524965 28200/java
tcp :::22 :::* LISTEN 0 62967 -
tcp :::1337 :::* LISTEN 500 524953 28200/java
tcp :::15003 :::* LISTEN 500 481149 3926/java
tcp :::60156 :::* LISTEN 500 524951 28200/java
tcp :::15004 :::* LISTEN 500 524917 28177/java
Port 22 is ssh - I can ssh into the machine just fine, so there's evidence that the :::*
foreign address is (in principle) just fine.
[edit - added remote nmap output]
Running nmap from another host, specifically listing all the above produces this:
$ nmap -T4 -A -v -PE -PS22,25,80 -PA21,23,80,930,139,111,25,445,7474,22,1337,15003,60156,15004,3389 192.168.176.138
...
Initiating SYN Stealth Scan at 13:31
Scanning 192.168.176.138 [1000 ports]
Discovered open port 111/tcp on 192.168.176.138
Discovered open port 139/tcp on 192.168.176.138
Discovered open port 445/tcp on 192.168.176.138
Discovered open port 22/tcp on 192.168.176.138
Discovered open port 15003/tcp on 192.168.176.138
Discovered open port 15004/tcp on 192.168.176.138
Completed SYN Stealth Scan at 13:31, 0.04s elapsed (1000 total ports)