Jump to content

Recommended Posts

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!
Link to comment
https://forums.phpfreaks.com/topic/282915-ports-needed-for-ldap-connection/
Share on other sites

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                 :::*                                -

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
  • 2 weeks later...

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.