Results 1 to 11 of 11
  1. #1

    Check whether port is open or not ?

    How do I check whether certain ports (like 25, 53, etc.) are open on my server or not ? If it is not open how do I open the port ?

    It is a CentOS server with no Control Panel

  2. #2
    Join Date
    Apr 2003
    Location
    Los Angeles, CA
    Posts
    820
    1) Check if anyone is listening on the server:
    # netstat -ln | grep 25

    2) If it's a TCP port, you can try to connect to it.
    # telnet SERVER_ADDRESS 25

    Try it locally and remotely, in case there is a firewall and/or iptables in front of it blocking access.
    Pings <1 ms, Unlimited Transfer, Lowest Price: http://localhost/

  3. #3
    Join Date
    Mar 2006
    Location
    tikkabilla
    Posts
    51
    netstat -anp | grep LISTEN

    will list what ports are listening (open)
    http://parked.net -100% Google Adsense Revenue | http://viphotels.co.uk - Worldwide VIP Hotels

  4. #4
    It showed:

    netstat -ln | grep 25
    tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN

    I am able to telnet locally, but its not connecting from remote (my PC). I am able to telnet to other servers on port 25.



    @ruptbot:

    netstat -anp | grep LISTEN
    tcp 0 0 IP:80 0.0.0.0:* LISTEN 24367/httpd
    tcp 0 0 IP:53 0.0.0.0:* LISTEN 5467/named
    tcp 0 0 IP:53 0.0.0.0:* LISTEN 5467/named
    tcp 0 0 IP:53 0.0.0.0:* LISTEN 5467/named
    tcp 0 0 IP:53 0.0.0.0:* LISTEN 5467/named
    tcp 0 0 IP:53 0.0.0.0:* LISTEN 5467/named
    tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 5467/named
    tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 24163/sendmail: acc
    tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 5467/named
    tcp 0 0 :::22 :::* LISTEN 2693/sshd
    tcp 0 0 ::1:953 :::* LISTEN 5467/named
    unix 2 [ ACC ] STREAM LISTENING 6213514 2787/0 /tmp/ssh-cCwHfU2787/agent.2787
    unix 2 [ ACC ] STREAM LISTENING 6013 2744/gpm /dev/gpmctl
    unix 2 [ ACC ] STREAM LISTENING 6052 2762/dbus-daemon-1 /var/run/dbus/system_bus_socket

    (I have replaced the real IP with "IP" in the result)

    So I am not able to access port 25 and port 53 from remote location. Any clues ?

  5. #5
    Join Date
    May 2004
    Location
    India
    Posts
    439
    do a "iptables -F" and try. If it is a success, let us know the output of iptables -L -n | grep 25

  6. #6
    Join Date
    May 2004
    Location
    India
    Posts
    439
    Oops. I just noticed you are running sendmail. So the reason can be that sendmail is not listening to public IP address. Please try to do a --> grep Addr /etc/mail/sendmail.mc <-- and let us see the output. If it only localhost or 127.0.0.1, remove that Addr=127.0.0.1 and restart sendmail.

    But again it is showing 0.0.0.0:25..hmm..

  7. #7
    this is what it says...

    grep Addr /etc/mail/sendmail.mc
    DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
    dnl DAEMON_OPTIONS(`port=smtp,Addr=::1, Name=MTA-v6, Family=inet6')dnl

  8. #8
    I removed Addr=127.0.0.1, from the first line, restarted sendmail, but no luck yet

    shall I add it back ?

  9. #9
    Join Date
    May 2004
    Location
    India
    Posts
    439
    No, you may not. What about a telnet public_ipaddress 25 from the server itself ? Also any output on iptables -L -n | grep 25

  10. #10
    Yes, I am able to telnet to public IP 25 from the server.

    iptables -L -n | grep 25
    ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 icmp type 255
    ACCEPT udp -- 0.0.0.0/0 224.0.0.251 udp dpt:5353

    Thats the result

  11. #11
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,771
    Stop firewall in the server and try telnet from outside.

    service iptables stop
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •