Jump to content


Photo

Ports needed for LDAP connection


  • Please log in to reply
7 replies to this topic

#1 TheOneAndOnlyChosenOne

TheOneAndOnlyChosenOne

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 12 October 2013 - 09:57 AM

Hi

I have the next set up:
A server (1) that is reachable from the internet and an internal server (2) that is not reachable externally, but can be reached through server 1.
Now. When I run next script on server 1, everything works. 'startsuccess!' is printed.

<?php
echo "start";
$host = 'server2';
$port = '389;
$ds = ldap_connect($host, $port);
echo "success!";
?>
When I run this on my local pc, it doesn't work.
I forward port 389 to port 1337. This tunnel should work, because portforwarding of other ports (like 22) work.
This is the script I run locally:
<?php
echo "start";
$host = 'localhost';
$port = '1337;
$ds = ldap_connect($host, $port);
echo "success!";
?>
Only 'start' is printed out.

Am I doing something wrong, or do I have to forward more ports?

Thanks!

#2 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,387 posts
  • LocationMississauga, Canada

Posted 12 October 2013 - 09:24 PM

The outputs of netstat -tulpn from the both servers should be a good start for us.



#3 TheOneAndOnlyChosenOne

TheOneAndOnlyChosenOne

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 14 October 2013 - 11:35 AM

Thanks for your reply!

Server 1:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:5126          0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:4040          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:80              0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:113             0.0.0.0:*               LISTEN      -               
tcp        0      0 193.190.253.193:53      0.0.0.0:*               LISTEN      -               
tcp        0      0 193.190.253.225:53      0.0.0.0:*               LISTEN      -               
tcp        0      0 193.190.253.208:53      0.0.0.0:*               LISTEN      -               
tcp        0      0 192.168.0.160:53        0.0.0.0:*               LISTEN      -               
tcp        0      0 192.168.0.150:53        0.0.0.0:*               LISTEN      -               
tcp        0      0 192.168.0.182:53        0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:8022          0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:4951          0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:59266           0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:5123          0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:51651           0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:389             0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:5125          0.0.0.0:*               LISTEN      -               
tcp6       0      0 ::1:4040                :::*                    LISTEN      -               
tcp6       0      0 :::111                  :::*                    LISTEN      -               
tcp6       0      0 :::44593                :::*                    LISTEN      -               
tcp6       0      0 :::4949                 :::*                    LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      -               
tcp6       0      0 ::1:4951                :::*                    LISTEN      -               
tcp6       0      0 :::25                   :::*                    LISTEN      -               
tcp6       0      0 :::40859                :::*                    LISTEN      -               
tcp6       0      0 :::389                  :::*                    LISTEN      -               
tcp6       0      0 ::1:5125                :::*                    LISTEN      -               
udp        0      0 193.190.253.193:53      0.0.0.0:*                           -               
udp        0      0 193.190.253.225:53      0.0.0.0:*                           -               
udp        0      0 193.190.253.208:53      0.0.0.0:*                           -               
udp        0      0 192.168.0.160:53        0.0.0.0:*                           -               
udp        0      0 192.168.0.150:53        0.0.0.0:*                           -               
udp        0      0 192.168.0.182:53        0.0.0.0:*                           -               
udp        0      0 127.0.0.1:53            0.0.0.0:*                           -               
udp        0      0 0.0.0.0:67              0.0.0.0:*                           -               
udp        0      0 0.0.0.0:69              0.0.0.0:*                           -               
udp        0      0 0.0.0.0:111             0.0.0.0:*                           -               
udp        0      0 193.190.253.193:123     0.0.0.0:*                           -               
udp        0      0 193.190.253.225:123     0.0.0.0:*                           -               
udp        0      0 193.190.253.208:123     0.0.0.0:*                           -               
udp        0      0 192.168.0.160:123       0.0.0.0:*                           -               
udp        0      0 192.168.0.150:123       0.0.0.0:*                           -               
udp        0      0 192.168.0.182:123       0.0.0.0:*                           -               
udp        0      0 127.0.0.1:123           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:123             0.0.0.0:*                           -               
udp        0      0 0.0.0.0:36056           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           -               
udp        0      0 0.0.0.0:33009           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:55549           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:850             0.0.0.0:*                           -               
udp        0      0 127.0.0.1:875           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:60281           0.0.0.0:*                           -               
udp        0      0 127.0.0.1:921           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:517             0.0.0.0:*                           -               
udp        0      0 0.0.0.0:518             0.0.0.0:*                           -               
udp6       0      0 :::40540                :::*                                -               
udp6       0      0 :::111                  :::*                                -               
udp6       0      0 fe80::219:dbff:fec5:123 :::*                                -               
udp6       0      0 ::1:123                 :::*                                -               
udp6       0      0 fe80::219:dbff:fec5:123 :::*                                -               
udp6       0      0 :::123                  :::*                                -               
udp6       0      0 :::53430                :::*                                -               
udp6       0      0 :::5353                 :::*                                -               
udp6       0      0 :::850                  :::*                                -               
udp6       0      0 :::52110                :::*      

Server 2:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:389             0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::389                  :::*                    LISTEN      -               
tcp6       0      0 :::4949                 :::*                    LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      - 

My own pc:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              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:1337          0.0.0.0:*               LISTEN      25768/ssh       
tcp6       0      0 :::22                   :::*                    LISTEN      -               
tcp6       0      0 ::1:631                 :::*                    LISTEN      -               
tcp6       0      0 ::1:1337                :::*                    LISTEN      25768/ssh       
udp        0      0 0.0.0.0:1900            0.0.0.0:*                           -               
udp        0      0 0.0.0.0:43048           0.0.0.0:*                           -               
udp        0      0 127.0.0.1:53            0.0.0.0:*                           -               
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -               
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           -               
udp6       0      0 :::51728                :::*                                -               
udp6       0      0 :::5353                 :::*                                -


#4 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,387 posts
  • LocationMississauga, Canada

Posted 14 October 2013 - 12:12 PM

So, run nmap from your local server terminal and give me the output of:

nmap -Pn -p 339 ip_address_of_server2




#5 TheOneAndOnlyChosenOne

TheOneAndOnlyChosenOne

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 14 October 2013 - 12:28 PM

You mean on my local pc?

Server 2 is not reachable from the outside.

Also, nmap is not installed on server 1 and server 2.



#6 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,387 posts
  • LocationMississauga, Canada

Posted 14 October 2013 - 12:31 PM

Yep, I mean to run nmap from your local PC! Server 2 should be reachable by port 389, but not sure if this port is not filtered.

 

PS: Are you using windows for home PC?

 

Try to run ldap but be careful about php syntax:

<?php
echo 'start';
$host = 'server 2 ip address';
$port = 389;
$ds = ldap_connect($host, $port);
echo 'success!';

Go to the php.net website and take a look at examples how to check if the connection of ldap is success or fail.

 

Never use php to do this before.


Edited by jazzman1, 14 October 2013 - 12:56 PM.


#7 TheOneAndOnlyChosenOne

TheOneAndOnlyChosenOne

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 27 October 2013 - 09:06 PM

Thanks for your reply!

Doesn't it have to be $port = 1337?

 

I'm running Linux on my local pc.

 

Nmap for both port 389 and 1337:

Server 2 has no external ip, so I used his internal ip.
Nmap scan report for ip_server_2
Host is up.
PORT    STATE    SERVICE
389/tcp filtered ldap

Nmap scan report for ip_server_2
Host is up.
PORT     STATE    SERVICE
1337/tcp filtered waste

Edited by TheOneAndOnlyChosenOne, 27 October 2013 - 09:06 PM.


#8 TheOneAndOnlyChosenOne

TheOneAndOnlyChosenOne

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 27 October 2013 - 09:16 PM

Error reporting did the trick!
"Call to undefined function: ldap_connect()"
-> Had to install php5-ldap.

Problem solved.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com