Wednesday, March 3, 2010

8. Postfix Transport Table - SMTP Routing


    This feature allows to route messages to additional domains according to the Map defined. Here Postfix accepts the message and rather than consulting the DNS for MX record it routes the mail by checking the transport map. In sendmail this feature is called mailertable

Transport Map
The map format is as follows
Left Handside                    Right Hand Side
user@domain.com                 transport:nexthope       
domain.com                       transport:nexthope
host1.domain.com                 transport:nexthope
   In the above format the Right Hand side defines the list of the domains that Postfix accepts the messages and routes. In Left Hand Side defines the transport mechanism that used and the destination of the mails.

Setting up the Transport Mechanism to Route the messages:
Check the derivative that supports transport map
# postconf |grep transport_maps
    transport_maps is the derivative that enables the transport map. By default the derivative will be undefined. The types of transport that supported by the Postfix can be determined by examining the "/etc/postfix/master.cf" file. smtp, local, error etc are the types of the transport defined.
Create the transport map file
# vim /etc/postfix/transport
sales.domain.com           smtp:[internalhost1.domain.com]
tax.domain.com              smtp:[internalhost2.domain.com]
finance.domain.com       smtp:newdomain.com
    The Left hand side we have mentioned the "mails coming from domains" which has to be routed (sales.domain.com) and in the Right hand side we have mentioned the transported which has to be use (smtp) and the destination machine (internalhost1.domain.com).
Note: "While using the transport table, when mails subjected to route, to disable the MX lookup by postfix for the destination domains we have to add the recieving domains inside the square bracket ("[]"). This will tell Postfix to "not perform" the MX lookup of the destined domains.
# postmap /etc/postfix/transport
   Now we have generated the transport map file named transport.db
Enable the transport map feature in the postfix
# vim  /etc/postfix/main.cf
transport_maps = hash:/etc/postfix/transport
# postfix reload
    Now we have integrated the transport map with the postfix.

Testing the configuration
# postconf |grep transport_maps
    Check the maps are defined correctly.
Make sure that the MX record for all the domains that needs to route the mail to another server points to the Mail Routing Server. Now try sending mails destined to domains sales.domain.com, tax.domain.com, finance.domain.com. According to the map defined the Mail Routing server will route the mails to respective host. It is understood that the receiving host has configured to accept the mails from the Mail Router.

1 comment:

tag ur valuable ideas below