Background :
My apache webserver runs on two virtual host with two different IP address. I have whitelisted both of these IPs to the remote SMPP server/system. I would be communicating to the remote server from a single machine which has these two IP addresses.
Situation :
I am trying to open a socket connection to a remote SMPP server. But I want to initiate connection to the server from different IP address.
What I tried : I created two folders mkdir /var/www/html/server{1,2}
and added following lines to my http.conf
Listen 1.1.1.1:80
Listen 2.2.2.2:80
<VirtualHost 1.1.1.1:80>
DocumentRoot /var/www/html/server1
</VirtualHost>
<VirtualHost 2.2.2.2:80>
DocumentRoot /var/www/html/server2
</VirtualHost>
and in each folder I write the same php file which opens a socket connection and does whatever it is supposed to do. I will be moving the server2 and the second IP on a new machine. But before doing that, I just want to know for sure that the second IP is actually whitelisted and I will be able to communicate via that IP.
Question : When you fsockopen
inside PHP , what IP address is sent to the remote server? will it be same as $_SERVER['SERVER_ADDR']
or something else ?
Note on IPs :
I saw couple of answers mentioning actual IP address of my machine. Assume that I have two eth cards, providing me with two, i.e., eth0 and eth1 interfaces with 1.1.1.1 and 2.2.2.2 IP addresses. Both are linked to external world and I can call my machine by any of the address. So if your answer is something along the lines of actual-public-linked-up-ip-address-of-your-server please tell me which one 1.1.1.1 or 2.2.2.2 ? How do you decide which one is actual and which one is virtual ?
It will be actual public IP of your server.
Let's assume you have 3 IP's on the server:
1.1.1.1 - main IP (link IP)
2.2.2.2, 3.3.3.3 - on some other network interfaces
All requests will go to other servers from the main IP.
There is another case where 1.1.1.1, 2.2.2.2 and 3.3.3.3 are link interfaces. In this case you may need to contact your network administrator and check how those interfaces are configured and what is the main connection IP.
For example I have 2 interfaces: eth0 and eth1 bridged and the public IP is associated with the bridge.