Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Vince Stewart
I have a VPS on Ubuntu 12 and a home computer on Ubuntu 12. I have a Java application on the VPS which opens a tcp socket listening on port 4000 and also an Http listener. My ssh service operates on port 55555. Once the application has been started I get a this report when I enter on the command line: netstat -t -l

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 *:55555                 *:*                     LISTEN     
tcp6       0      0 [::]:http-alt           [::]:*                  LISTEN     
tcp6       0      0 [::]:55555              [::]:*                  LISTEN     
tcp6       0      0 vps.mdomai.com:4000     [::]:*                  LISTEN     

with denyhosts operating my /etc/hosts.allow is just one line

ALL: xxx.xxx.xxx.xxx
(xxx.xxx.xxx.xxx is my static home IP address)

/etc/hosts.deny is:

ALL:ALL

I can connect from home using:

telnet yyy.yyy.yyy.yyy 55555  or telnet yyy.yyy.yyy.yyy 8080
(yyy.yyy.yyy.yyy is for my VPS address)

but with:

telnet yyy.yyy.yyy.yyy 4000 

an error is thrown ("Unable to connect to remote host: connection refused"). This seems like a firewall issue. I am pretty sure I have not changed iptables so should be VPS default. Many thanks for any suggestions. When I issue sudo ufw raw, I get:

IPV4 (raw):
Chain INPUT (policy ACCEPT 21043 packets, 2314421 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 21077 packets, 2152970 bytes)
pkts      bytes target     prot opt in     out     source               destination         
Chain PREROUTING (policy ACCEPT 318 packets, 41345 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain INPUT (policy ACCEPT 42 packets, 7128 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 347 packets, 24571 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 347 packets, 24571 bytes)
pkts      bytes target     prot opt in     out     source               destination         
Chain PREROUTING (policy ACCEPT 6241 packets, 691583 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain INPUT (policy ACCEPT 5965 packets, 657366 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 5936 packets, 614188 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 10872 packets, 1131008 bytes)
pkts      bytes target     prot opt in     out     source               destination         
Chain PREROUTING (policy ACCEPT 6241 packets, 691583 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 5936 packets, 614188 bytes)
pkts      bytes target     prot opt in     out     source               destination         


IPV6:
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts      bytes target     prot opt in     out     source               destination         
share|improve this question

2 Answers 2

You have only opened the ipv6 port 4000, as per.

tcp6 0 0 vps.mdomai.com:4000 [::]:* LISTEN

Have you tried via ipv6 on vps.mdomai.com:4000?

What if you go:

netstat -an --inet | grep LISTEN

share|improve this answer
    
Thanks for your reply which solves my immediate problem. I now have to work out why the software used ipv6 and how to adjust the iptables for ipv6 –  user975920 Jan 31 '13 at 20:35
    
Thanks for your reply which solves my immediate problem. Your point about tcp6 was crucial because I was using telnet with the ipv4 address of my vps. I still have work to do but consider my question to have been answered. much appreciated ! –  user975920 Jan 31 '13 at 20:42
    
I do not have an accept answer link but when I get one I will accept the answer –  user975920 Jan 31 '13 at 21:05
    
Cool, its all about the karma rather than the points mate. –  Grizly Feb 1 '13 at 2:11

I am now providing what was the eventual solution to my problem because I think it highlights an important issue for non-experts (such as I am). That being the /etc/hosts file entry.

I was using the same java application at my VPS and my home computer and these were supposed to communicate over TCP. My home computer accessed the internet via a DSL modem which had a fixed IP address. When I tried to direct a message from home to VPS, the java reported timeout (which just meant that a connection could not be made).

I had already allocated my computer a fixed address withing the local network (ie 192.168.1.57) because it just seemed sensible. But the crucial change that I eventually made was to register my computer's internet address (ie 192.168.1.57) into the ubuntu file '/etc/hosts'; now the java running at the home machine read its own "inet address" as 192.168.1.57 instead of 127.1.0.1 and everything started to work. I also needed to provide the VPS with my DSL fixed IP address (203.x.x.x) and a port number which was port-forwarded to the 192.168.1.57 machine. I hope this might help someone.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.