Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to enable the port 7777 from my VPS which runs Ubuntu 11.04, I have added rules from the iptables which is listed here,

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere            udp dpt:7777 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere            udp dpt:7777 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere            udp dpt:7777 

However, when I telnet to port 7777, it says connection refused from my side, telnet xx.xx.xx.xx 7777, even if I telnet on the server with telnet localhost 7777.

How should I effectively open it to allow connections to port 7777 to my server?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

telnet uses TCP. If there is no TCP listener on the port you specify, then the connection request will be refused. Try using nc instead:

$ nc -zu <IP> 7777
$ echo $?
0

Exit status 0 returned means that this port is open.

or nmap:

$ sudo nmap -p 7777 -sU -P0 <IP>

for e.g:

$ sudo nmap -p 9 -sU -P0 192.168.6.142

Starting Nmap 5.51 ( http://nmap.org ) at 2012-08-30 21:31 ICT
Nmap scan report for (192.168.6.142)
Host is up.
PORT  STATE         SERVICE
9/udp open|filtered discard

Nmap done: 1 IP address (1 host up) scanned in 2.12 seconds
share|improve this answer
    
Doh how did i miss this. I feel so stupid. –  ItsGC Aug 30 '12 at 14:30

You are actually allowing all traffic to pass through your firewall. The default policy of all chains is set to ACCEPT and you don't have any DROP rule.

As for the connection refused error, you are trying to connect using telnet and this tries to established TCP-based connection. To test UDP connectivity, you need to use netcat or nc with -u option.

You can check whether the requested service is listening on the port 7777, you can use:

netstat -anp | grep 7777
share|improve this answer
    
I got this udp 0 0 0.0.0.0:7777 0.0.0.0:* 9733/samp03svr when I ran the netstat -anp | grep 7777 command. –  MacMac Aug 30 '12 at 14:26
1  
So, you have a process listening on this port. Using telnet is wrong to check the connectivity. You can use netcat instead as I said in the answer. –  Khaled Aug 30 '12 at 14:28

Are you positive there is a service running on that port? netstat -n to be sure.

The default policy for this chain is ACCEPT. So there is actually no block active currently. Flush all the chains and all the tables, reboot and try telnetting.

Let us know.

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.