LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-11-2011, 11:59 AM   #1
rediff08
LQ Newbie
 
Registered: Jul 2011
Posts: 7

Rep: Reputation: Disabled
Listen to a port


Hey Guys,

I would like to open a port 1004. My firewall is disabled. I want a program to listen to this port. Is there a way I could check if the port is open/listening? I tried telnet localhost 1004 and it keep saying connection refused. I don't know if telnet is a way to check if the port is open?

Thanks
 
Old 07-11-2011, 12:04 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
On the server itself:
Code:
$ netstat -ltn
(i.e. Display "l"istening "t"cp sockets, and do "n"ot resolve IPs or port numbers.)
 
Old 07-11-2011, 12:12 PM   #3
rediff08
LQ Newbie
 
Registered: Jul 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
This is the output for that command
Code:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:617                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:2001                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:1521                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:4434                0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:3003                0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LISTEN
tcp        0      0 :::22                       :::*                        LISTEN
I am not seeing port 1004. I'm not sure how to add 1004 to that list.

Last edited by rediff08; 07-11-2011 at 12:14 PM.
 
Old 07-11-2011, 12:28 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Tcp port 1004 will appear on that list once you actually have a daemon that's listening for connections on it. Currently there isn't one.
 
1 members found this post helpful.
Old 07-11-2011, 12:50 PM   #5
rediff08
LQ Newbie
 
Registered: Jul 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Oh okay. Thank you
 
Old 07-11-2011, 01:03 PM   #6
baxzius
Member
 
Registered: Jan 2010
Location: India
Distribution: ubuntu
Posts: 134
Blog Entries: 1

Rep: Reputation: 21
once solved,please make this thread as solved .please!
 
0 members found this post helpful.
Old 07-11-2011, 01:25 PM   #7
saiju@wavecrest.gi
LQ Newbie
 
Registered: Jul 2011
Location: India
Distribution: Rhel,CentOS,Ubuntu
Posts: 11

Rep: Reputation: Disabled
Cool

HI ,

Try this method to open 1004 port..

1) check weather 1004 is listening or not.
[root@Saiju-VM-2 ~]# netstat -ant | grep 1004
[root@Saiju-VM-2 ~]#

2) if it is not listening.

[root@Saiju-VM-2 ~]# vi /etc/httpd/conf/httpd.conf
Edit httpd.conf in apache configuration.

Add Listen 1004 line .

#
#Listen 12.34.56.78:80
Listen 80
Listen 1004

3) restart httpd service.
[root@Saiju-VM-2 ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: apr_sockaddr_info_get() failed for Saiju-VM-2
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
4) check weather 1004 port is listening or not..

[root@Saiju-VM-2 ~]# netstat -ant | grep 1004
tcp 0 0 :::1004 :::* LISTEN

Let me know if you face any issues..

Thanks & regds
Saiju
 
1 members found this post helpful.
Old 07-11-2011, 01:28 PM   #8
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
@saiju: With respect, why in the world would he want to run an unnecessary daemon (Apache web server)?

If the goal is to put some arbitrary listener on tcp 1004, then nc(1) is lighter and is already installed on most systems.
 
Old 07-11-2011, 04:01 PM   #9
rediff08
LQ Newbie
 
Registered: Jul 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
I tried using nc -l 1004 but it doesn't really give me any output.
 
Old 07-11-2011, 04:51 PM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,267

Rep: Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440
Quote:
Originally Posted by rediff08 View Post
Hey Guys,

I would like to open a port 1004. My firewall is disabled. I want a program to listen to this port. Is there a way I could check if the port is open/listening? I tried telnet localhost 1004 and it keep saying connection refused. I don't know if telnet is a way to check if the port is open?

Thanks
The real question here would be, what are you trying to do? You can pretty much make ANY service listen on ANY port...what are you trying to run? What are you looking to do?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning: remote port forwarding failed for listen port 7869 windstory Linux - Newbie 1 08-02-2010 11:07 AM
MULTICAST address and port, socket listen only on port? jf.argentino Linux - Networking 2 03-09-2009 01:42 PM
Port 80 listen without WebServer? hacinn Linux - Security 5 06-30-2004 10:52 PM
Port won't Listen dvong3 Linux - Networking 4 05-12-2004 01:18 PM
Can vsftpd listen to another port? twelve Linux - Networking 9 05-05-2004 09:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration