Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

domain abc.com should send from ip 1.1.1.1 and domain xyz.com should send from ip 2.2.2.2

I could not find how to configure the the IP for bothh domains differently. However I already found where to change the IP for all domains (under TCP/IP Ports).

share|improve this question

2 Answers 2

That's not a decision hMailserver can easily make, as hMailserver relies on the TCP/IP stack in your system for the transport. Therefor the outgoing interface is decided by the routing decision your kernel makes. Typically you will have a routing table like this:

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0     192.168.0.42     192.168.0.16    266
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    306
      192.168.0.0    255.255.255.0         On-link      192.168.0.16    266
     192.168.0.16  255.255.255.255         On-link      192.168.0.16    266
    192.168.0.255  255.255.255.255         On-link      192.168.0.16    266
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    306
        224.0.0.0        240.0.0.0         On-link      192.168.0.16    266
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    306
  255.255.255.255  255.255.255.255         On-link      192.168.0.16    266
===========================================================================

All traffic to the internet (0.0.0.0/0) at this system goes from Interface 192.168.0.16. Even if you add a second interface with the same gateway, netmask and metric the computer will just pick one of the two and always use that one. So there is no easy way to do what you want.

share|improve this answer
    
Our server has multiple internet-visible ips because it serves multiple websites btw. –  usr Apr 21 '10 at 22:34
    
Well, having multiple IP addresses lets you bind services to multiple addresses. The server will still pick one to bind to when you create an outgoing connection. If you have a look at a guide to socket programming such as amk.ca/python/howto/sockets you will see that you only define the destination address for a client socket. –  pehrs Apr 22 '10 at 7:12
    
This iy python-specific. As a .net programmer I know that you can bind the socket before listening to a port and and ip if you want to (msdn.microsoft.com/en-us/library/…). EndPoint is a tuple of (ip, port). –  usr Apr 22 '10 at 11:45
    
@usr: You can always pick an IP when you open a socket to listen. But when you create a client socket to connect to another system you don't get to pick the local ip. Difference here is between server socket (or listening socket) and a client socket (or outgoing/connecting socket). –  pehrs Apr 22 '10 at 16:25
    
You can always pick a local endpoint, in both client and server modes. You can call bind before calling connect or listen. In my case all IPs are equivalent from a routing standpoint. For that reason any local endpoint will be able to send. –  usr Aug 15 '12 at 11:49

It's not hMailserver which decides which IP address is the sender. That's determined by normal network routing. You will need to pass the outgoing mail for one of the domains to another MTA, which is configured to send that mail out on a particular IP address. As this can be a tricky issue on a single machine I suggest having the second MTA on a separate machine. A minimal virtual machine would do nicely for this.

share|improve this answer
    
The application can specifiy which ip to use when sending (it can of course also say: i dont care). So in theory hMailserver can decide this. –  usr Apr 21 '10 at 22:33
1  
I've just had a look at my hMailserver and can't find that setting. I can tell it what IP address to listen to and what address to rout outgoing mail to but not what IP address to use as the sender. Maybe I've overlooked it, so can you tell me where to set the originating address for a domain so I can test it? –  John Gardeniers Apr 21 '10 at 23:04
    
Thanks for looking! Where can I find the setting where I can say the outgoing address? Thats exactly what I am looking for (hope I can set this per domain...). –  usr Apr 22 '10 at 11:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.