sending email on a different IP

Haloweb

Well-Known Member
Jul 2, 2004
88
0
156
Hi Everyone

Ok I am no genous so please bear with me :)

I have my own box and my main hosting services site on its own dedicated IP
however sending mail is done via the servers shared IP

Due to some clients sending spam which has now been corrected my legit emails
were being returned by other mail servers, to prevent this from happening in future
I would like to send mail on a different IP .... is there anyway this can be done
on the same box

I know I could probably setup a hosting account somewhere else and then change
my mx entries but is there another way

thanks for your help in advance
 

madaboutlinux

Well-Known Member
Jan 24, 2005
1,051
2
168
Earth
If your IP is blocked due to spaming reason and you wish to route all the outgoing emails from a different IP, you can do so by using a Iptable rule.
All the outgoing packets for port 25 will then have there source address changed to the new IP and emails will start working without any problems. You will have to add the rule in NAT table and under postrouting chain.
 
Last edited:

tweakservers

Well-Known Member
Mar 30, 2006
379
0
166
You may edit your exim.conf under the "Transports Configuration", find the following line :

remote_smtp:
driver = smtp
Add in the following :

interface = xxx.xxx.xxx.xxx
Result will be :

remote_smtp:
driver = smtp
interface = xxx.xxx.xxx.xxx
Replace xxx with one of the IP you have added to the server and restart the exim services. This will have your outgoing mails sent using the above IP instead of the share IP.
 

Haloweb

Well-Known Member
Jul 2, 2004
88
0
156
Thanks everyone

tweakservers I think I will definatly be using your option

Thanks again
 

madaboutlinux

Well-Known Member
Jan 24, 2005
1,051
2
168
Earth
Here's the iptable rule if other solution won't help you :-
iptables -t nat -A postrouting -o eth0 -p tcp -j SNAT --dport 25 --to-source xx.xx.xx.xx

where,
xx is the new ip on the server from where you will route your emails from.

Then execute :-
service iptables save
service iptables restart

Also you can check whether the rule is added properly or not by :-
iptables -t nat -n -L
 

RickG

Well-Known Member
Feb 28, 2005
238
2
168
North Carolina
Is it possible to use this technique to change the sending IP for a specific domain (or account) that you host?

For example, if one of the accounts on your server has a dedicated IP, can you change the sending IP for that one account (but have all others accounts use the default shared IP for sending mail)?
 

Haloweb

Well-Known Member
Jul 2, 2004
88
0
156
Rick

How would I do this as the other solution above did not seem to work
mails were still going out on the shared IP