Recipe 2.12 Fixing a .forward Loop

Problem

Mail addressed to a user is being bounced with the error "too many hops."

Solution

First, check the aliases database to make sure that it is not the cause of the problem. If the aliases database is not the source of the loop, create an alias for the looping username to bypass the user's .forward file and force local delivery. The alias field of the new database entry should be the looping username and the recipient field should be the looping username preceded by a \ character.

Second, check out the contents of the user's .forward file. If the user forwards to a remote system, and you have root access to that system, print out the user's .forward file on that system. If you don't have root access, telnet to the SMTP port of the remote system and use the SMTP EXPN command to see how that system delivers mail addressed to the looping account.

If these tests show you the loop, tell the user exactly what is wrong and what needs to be fixed. If you cannot get the necessary information quickly from the remote system, tell the user that he probably has a loop in his .forward files, that he needs to fix it, and that his .forward file on your system will be ignored until he does.

Discussion

Users create and maintain their own .forward files. Sometimes, of course, a user makes a mistake when configuring the .forward file, and it is up to you to help him correct that mistake. One of the most common configuration errors is a forwarding loop in which the user configures the .forward file to forward mail to another system and then configures the .forward file on that system to forward mail back to the original system. Sometimes, more than two systems are involved because users often have login accounts on several systems. Let's look at an example.

Assume the username for which mail is bounced is norman . Examine how your system handles the norman email address by adding the verbose option ( -v ) to the sendmail -bv command, as follows :

 #  sendmail -v -bv norman  /home/norman/.forward: line 1: forwarding to norman@crab.wrotethebook.com norman@crab.wrotethebook.com... deliverable: mailer esmtp, host crab.wrotethebook. com., user norman@crab.wrotethebook.com 

Adding -v to the sendmail -bv command provides additional information on how an address is rewritten on the local system. In this case, there is no alias for norman , so the aliases database cannot be part of the forwarding loop. (It is always best to make sure that you are not the cause of a problem before you get a user involved.) In fact, the sendmail -v -bv command makes clear that the information used to rewrite the norman address comes from the /home/norman/.forward file.

Add an alias to the aliases database to break the loop:

 norman:          \norman 

The \ syntax terminates aliasing before Norman's .forward file is read. Mail addressed to norman that arrives at this host is no longer forwarded off of this host, which breaks the loop.

If you want to investigate further, you can examine the user's .forward file on the remote system or use the SMTP EXPN command to check how the remote system handles the user's mail. The sendmail -bv command just shown tells us that Norman forwards his mail to crab.wrotethebook.com . The following test shows how crab handles Norman's mail:

 #  telnet crab.wrotethebook.com smtp  Trying 192.168.0.15... Connected to crab.wrotethebook.com. Escape character is '^]'. 220 crab.wrotethebook.com ESMTP Sendmail 8.12.9/8.12.9; Mon, 11 Aug 2003 10:31:49 - 0400  HELO rodent.wrotethebook.com  250 crab.wrotethebook.com Hello rodent.wrotethebook.com [192.168.0.3], pleased to  meet you  EXPN norman  250 2.1.5 Norman Edwards <norman@wrotethebook.com>  QUIT  221 2.0.0 crab.wrotethebook.com closing connection Connection closed by foreign host. 

The local system forwards Norman's mail to crab.wrotethebook.com, and crab forwards the mail to wrotethebook.com . If the local system is the mail exchanger for wrotethebook.com , the cause of the loop is obvious. This example uses the SMTP EXPN command to examine forwarding on the remote system. However, many mail hosts do not implement the EXPN command. In that case, an error message similar to the following is displayed in response to the EXPN command:

 502 5.7.0 Sorry, we do not allow this operation 

It is not absolutely necessary that you gather information from the local and remote .forward files. If it is simple to do, your insights about what is wrong with the configuration of these files may speed a permanent solution. However, the .forward file is the user's responsibility. If the norman alias you added to the aliases database breaks the loop and the information about the .forward files cannot be gathered easily, you probably have more productive ways to spend your time than trying to gather forwarding information. Norman can easily print out his .forward files and bring the information to you later if he needs help.

See Also

The SMTP commands, including EXPN , are covered in the "Simple Mail Transfer Protocol" section of TCP/IP Network Administration , Third Edition, by Craig Hunt (O'Reilly). The sendmail book covers EXPN in Section 10.3.2.



Sendmail Cookbook
sendmail Cookbook
ISBN: 0596004710
EAN: 2147483647
Year: 2005
Pages: 178
Authors: Craig Hunt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net