2

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 ?

wadkar
  • 960
  • 2
  • 15
  • 29

2 Answers2

1

It will be actual public IP of your server.

ioseb
  • 16,625
  • 3
  • 33
  • 29
1

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.

Narcis Radu
  • 2,519
  • 22
  • 33
  • ermm, I have eth1 = 1.1.1.1 , eth1:0 = 2.2.2.2 , eth1:1 = 3.3.3.3 , so all my communication, irrespective of where/how I configure Apache/php , will go through eth1 = 1.1.1.1? what if I have eth0 = 1.1.1.1 and eth1 = 2.2.2.2 , both can connect to outer world, what happens in this case? – wadkar Dec 08 '11 at 10:03
  • Yes, all communications go through eth0. For the second question: I will update my answer. – Narcis Radu Dec 08 '11 at 10:40
  • Also, your problem will probably find a better answer on serverfault instead. – Narcis Radu Dec 08 '11 at 10:48
  • You may have as many public IP's as you want, but you may have only one link interface. Things are more complicated when it comes to load balancing, but I have almost no knowledge about that. – Narcis Radu Dec 08 '11 at 10:51
  • Hmm. Pardon me if I am not getting the concept of link interfaces, but when I say I have two eth cards, I get the idea that by plugging two _different_ n/w cables, I can have two _different_ links (and corresponding Public IP). I somehow can not digest when you say _you may have only one link interface_ – wadkar Dec 08 '11 at 11:27
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/5684/discussion-between-narcisradu-and-sudhi) – Narcis Radu Dec 08 '11 at 11:37