less daunting for you, we hope you’ll gain the confidence to tackle more complex configurations on your own. Prev Home Next Configuring elm Installing sendmail
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services
Linux Network Administrators Guide Prev Next Chapter 18. Sendmail Table of Contents Introduction to sendmail Installing sendmail Overview of Configuration Files The sendmail.cf and sendmail.mc Files Generating the sendmail.cf File Interpreting and Writing Rewrite Rules Configuring sendmail Options Some Useful sendmail Configurations Testing Your Configuration Running sendmail Tips and Tricks Introduction to sendmail It’s been said that you aren’t a real Unix system administrator until you’ve edited a sendmail.cf file. It’s also been said that you’re crazy if you’ve attempted to do so twice. sendmail is an incredibly powerful mail program. It’s also incredibly difficult to learn and understand. Any program whose definitive reference (sendmail, by Bryan Costales and Eric Allman, published by O’Reilly) is 1,050 pages long scares most people off. Information on the sendmail reference is contained in the bibliography at the end of this book. Fortunately, new versions of sendmail are different. You no longer need to directly edit the cryptic sendmail.cf file; the new version provides a configuration utility that will create the sendmail.cf file for you based on much simpler macro files. You do not need to understand the complex syntax of the sendmail.cf file; the macro files don’t require you to. Instead, you need only list items, such as the name of features you wish to include in your configuration, and specify some of the parameters that determine how that feature operates. A traditional Unix utility called m4 then takes your macro configuration data and mixes it with the data it reads from template files containing the actual sendmail.cf syntax, to produce your sendmail.cf file. In this chapter we introduce sendmail and describe how to install, configure and test it, using the Virtual Brewery as an example. If the information presented here helps make the task of configuring sendmail
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Linux Web Hosting services
Daemon and inetd modes are mutually exclusive. If you run Exim in daemon mode, you should make sure to comment out any line in inetd.conf for the smtp service. Equivalently, when having inetd manage Exim, make sure that no rc script starts the Exim daemon. You can check that Exim is correctly set up for receiving incoming SMTP messages by telnetting to the SMTP port on your machine. This is what a successful connect to the SMTP server looks like: $ telnet localhost smtp Trying 127.0.0.1… Connected to localhost. Escape character is ‘^]’. 220 richard.vbrew.com ESMTP Exim 3.13 #1 Sun, 30 Jan 2000 16:23:55 +0600 quit 221 richard.brew.com closing connection Connection closed by foreign host. If this test doesn’t produce the SMTP banner (the line starting with the 220 code), check that you are either running an Exim daemon process or have inetd correctly configured. If that doesn’t reveal the problem, look in the Exim log files (described next) in case there is an error in Exim’s configuration file. Notes [1] Other possible locations are /etc/rc.d/init.d and rc.inet2. The latter is common on systems using a BSD-style structure for system administration files in the /etc directory. [2] This is the new standard location of sendmail according to the Linux File System Standard. Another common location is /usr/lib/sendmail, which is likely to be used by mail programs that are not specially configured for Linux. You can define both filenames as symbolic links to Exim so that programs and scripts invoking sendmail will instead invoke Exim to do the same things. [3] Some user agents, however, use the SMTP protocol to pass messages to the transport agent, calling it with the bs option. [4] Use kill HUP pid, for which pid is the process ID of the inetd process retrieved from a ps listing. Prev Home Next Tips and Tricks If Your Mail Doesn’t Get Through
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services
they’re not, you can easily link them to it). When you run one of the commands, Exim checks the name you used to invoke it and sets the proper options itself. There are two links to Exim that you should have under all circumstances: /usr/bin/rmail and /usr/sbin/sendmail.[2] When you compose and send a mail message with a user agent like elm, the message is piped to sendmail or rmail for delivery, which is why both /usr/sbin/sendmail and /usr/bin/rmail should point to Exim. The list of recipients for the message is passed to Exim on the command line.[3] The same happens with mail coming in via UUCP. You can set up the required pathnames to point to Exim by typing the following at a shell prompt: $ ln -s /usr/sbin/exim /usr/bin/rmail $ ln -s /usr/sbin/exim /usr/sbin/sendmail If you want to dig further into the details of configuring Exim, you should consult the full Exim specification. If this isn’t included in your favorite Linux distribution, you can get it from the source to Exim, or read it online from Exim’s web site at http://www.exim.org. Running Exim To run Exim, you must first decide whether you want it to handle incoming SMTP messages by running as a separate daemon, or whether to have inetd manage the SMTP port and invoke Exim only whenever an SMTP connection is requested from a client. Usually, you will prefer daemon operation on the mail server because it loads the machine far less than spawning Exim over and over again for each connection. As the mail server also delivers most incoming mail directly to the users, you should choose inetd operation on most other hosts. Whatever mode of operation you choose for each individual host, you have to make sure you have the following entry in your /etc/services file: smtp 25/tcp # Simple Mail Transfer Protocol This defines the TCP port number that is used for SMTP conversations. Port number 25 is the standard defined by the Assigned Numbers RFC (RFC-1700). When run in daemon mode, Exim puts itself in the background and waits for connections on the SMTP port. When a connection occurs, it forks, and the child process conducts an SMTP conversation with the peer process on the calling host. The Exim daemon is usually started by invoking it from the rc script at boot time using the following command: /usr/sbin/exim -bd -q15m The bd flag turns on daemon mode, and q15m makes it process whatever messages have accumulated in the message queue every 15 minutes. If you want to use inetd instead, your /etc/inetd.conf file should contain a line like this: smtp stream tcp nowait root /usr/sbin/exim in.exim -bs Remember you have to make inetd re-read inetd.conf by sending it an HUP signal after making any changes.[4]
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Unix Web Hosting services
Linux Network Administrators Guide Prev Next Chapter 19. Getting EximUp and Running Table of Contents Running Exim If Your Mail Doesn’t Get Through Compiling Exim Mail Delivery Modes Miscellaneous config Options Message Routing and Delivery Protecting Against Mail Spam UUCP Setup This chapter gives you a quick introduction to setting up Exim and an overview of its functionality. Although Exim is largely compatible with sendmail in its behavior, its configuration files are completely different. The main configuration file is usually called /etc/exim.conf or /etc/exim/config in most Linux distributions, or /usr/lib/exim/config in older configurations. You can find out where the configuration file is by running the command: $ exim -bP configure_file You may have to edit the configuration file to reflect values specific to your site. In most common configurations there isn’t a great deal to change, and a working configuration should rarely have to be modified. By default, Exim processes and delivers all incoming mail immediately. If you have relatively high traffic, you may instead have Exim collect all messages in the so-called queue, and process them at regular intervals only. When handling mail within a TCP/IP network, Exim is frequently run in daemon mode: at system boot time, it is invoked from /etc/init.d/exim[1] and puts itself in the background, where it waits for incoming TCP connections on the SMTP port (usually port 25). This is beneficial whenever you expect to have a significant amount of traffic because Exim doesn’t have to start up for every incoming connection. Alternatively, inetd could manage the SMTP port and have it spawn Exim whenever there is a connection on this port. This configuration might be useful when you have limited memory and low mail traffic volumes. Exim has a complicated set of command-line options, including many that match those of sendmail. Instead of trying to put together exactly the right options for your needs, you can implement the most common types of operation by invoking traditional commands like rmail or rsmtp. These are symbolic links to Exim (or if
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Linux Web Hosting services
commands that properly configure TCP/IP networking on your computer. You should then replace any sample commands in your configuration scripts with your commands, make sure the script is executed from the basic rc script at startup time, and reboot your machine. The networking rc scripts that come along with your favorite Linux distribution should provide a solid example from which to work. Mounting the /proc Filesystem Some of the configuration tools of the Linux NET-2 and NET-3 release rely on the /proc filesystem for communicating with the kernel. This interface permits access to kernel runtime information through a filesystem-like mechanism. When mounted, you can list its files like any other filesystem, or display their contents. Typical items include the loadavg file, which contains the system load average, and meminfo, which shows current core memory and swap usage. To this, the networking code adds the net directory. It contains a number of files that show things like the kernel ARP tables, the state of TCP connections, and the routing tables. Most network administration tools get their information from these files. The proc filesystem (or procfs, as it is also known) is usually mounted on /proc at system boot time. The best method is to add the following line to /etc/fstab : # procfs mount point: none /proc proc defaults Then execute mount /proc from your /etc/rc script. The procfs is now configured into most kernels by default. If the procfs is not in your kernel, you will get a message such as: mount: fs type procfs not supported by kernel. You will then have to recompile the kernel and answer yes when asked for procfs support. Prev Home Next Serial Devices and the login: Prompt Installing the Binaries
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Unix Web Hosting services
Linux Network Administrators Guide Prev Next Chapter 5. Configuring TCP/IP Networking Table of Contents Mounting the /proc Filesystem Installing the Binaries Setting the Hostname Assigning IP Addresses Creating Subnets Writing hosts and networks Files Interface Configuration for IP All About ifconfig The netstat Command Checking the ARP Tables In this chapter, we walk you through all the necessary steps to set up TCP/IP networking on your machine. Starting with the assignment of IP addresses, we slowly work our way through the configuration of TCP/IP network interfaces and introduce a few tools that come in handy when hunting down network installation problems. Most of the tasks covered in this chapter will generally have to be done only once. Afterward, you have to touch most configuration files only when adding a new system to your network or when you reconfigure your system entirely. Some of the commands used to configure TCP/IP, however, have to be executed each time the system is booted. This is usually done by invoking them from the system /etc/rc* scripts. Commonly, the network-specific part of this procedure is contained in a script. The name of this script varies in different Linux distributions. In many older Linux distributions, it is known as rc.net or rc.inet. Sometimes you will also see two scripts named rc.inet1 and rc.inet2 ; the former initializes the kernel part of networking and the latter starts basic networking services and applications. In modern distributions, the rc files are structured in a more sophisticated arrangement; here you may find scripts in the /etc/init.d/ (or /etc/rc.d/init.d/ ) directory that create the network devices and other rc files that run the network application programs. This book’s examples are based on the latter arrangement. This chapter discusses parts of the script that configure your network interfaces, while applications will be covered in later chapters. After finishing this chapter, you should have established a sequence of
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Unix Web Hosting services
onto the loopback interface and completely avoid using the dummy interface. In more complex uses, you could configure your host to look like many different hosts, each with its own IP address. This configuration is sometimes called Virtual Hosting, although technically it is also used for a variety of other techniques.[6] To configure an alias for an interface, you must first ensure that your kernel has been compiled with support for IP Alias (check that you have a /proc/net/ip_alias file; if not, you will have to recompile your kernel). Configuration of an IP alias is virtually identical to configuring a real network device; you use a special name to indicate it’s an alias that you want. For example: # ifconfig lo:0 172.16.1.1 This command would produce an alias for the loopback interface with the address 172.16.1.1. IP aliases are referred to by appending :n to the actual network device, in which n is an integer. In our example, the network device we are creating the alias on is lo, and we are creating an alias numbered zero for it. This way, a single physical device may support a number of aliases. Each alias may be treated as though it is a separate device, and as far as the kernel IP software is concerned, it will be; however, it will be sharing its hardware with another interface. Notes [1] Anyone remember Pink Floyd’s Echoes ? [2] For example, all applications based on RPC use the loopback interface to register themselves with the portmapper daemon at startup. These applications include NIS and NFS. [3] Note that pointopoint is not a typo. It’s really spelled like this. [4] As a matter of caution, you should configure a PLIP or SLIP link only after you have completely set up the routing table entries for your Ethernets. With some older kernels, your network route might otherwise end up pointing at the point-to-point link. [5] The dummy device is called dummy0 if you have loaded it as a module rather than choosing it as an inbuilt kernel option. This is because you are able to load multiple modules and have more than one dummy device. [6] More correctly, using IP aliasing is known as network layer virtual hosting. It is more common in the WWW and STMP worlds to use application layer virtual hosting, in which the same IP address is used for each virtual host, but a different hostname is passed with each application layer request. Services like FTP are not capable of operating in this way, and they demand network layer virtual hosting. Prev Home Next Writing hosts and networks Files Up All About ifconfig
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services
Dynamic routing offers a much better option for temporary routes. You could use gated, a routing daemon, which you would have to install on each host in the network in order to distribute routing information dynamically. The easiest option, however, is to use proxy ARP (Address Resolution Protocol). With proxy ARP, vlager will respond to any ARP query for vlite by sending its own Ethernet address. All packets for vlite will wind up at vlager, which then forwards them to the laptop. We will come back to proxy ARP in the section the section called Checking the ARP Tables. Current net-tools releases contain a tool called plipconfig, which allows you to set certain PLIP timing parameters. The IRQ to be used for the printer port can be set using the ifconfig command. The SLIP and PPP Interfaces Although SLIP and PPP links are only simple point-to-point links like PLIP connections, there is much more to be said about them. Usually, establishing a SLIP connection involves dialing up a remote site through your modem and setting the serial line to SLIP mode. PPP is used in a similar fashion. We discuss SLIP and PPP in detail in Chapter 7 and Chapter 8. The Dummy Interface The dummy interface is a little exotic, but rather useful nevertheless. Its main benefit is with standalone hosts and machines whose only IP network connection is a dialup link. In fact, the latter are standalone hosts most of the time, too. The dilemma with standalone hosts is that they only have a single network device active, the loopback device, which is usually assigned the address 127.0.0.1. On some occasions, however, you must send data to the official IP address of the local host. For instance, consider the laptop vlite, which was disconnected from a network for the duration of this example. An application on vlite may now want to send data to another application on the same host. Looking up vlite in /etc/hosts yields an IP address of 172.16.1.65, so the application tries to send to this address. As the loopback interface is currently the only active interface on the machine, the kernel has no idea that 172.16.1.65 actually refers to itself ! Consequently, the kernel discards the datagram and returns an error to the application. This is where the dummy device steps in. It solves the dilemma by simply serving as the alter ego of the loopback interface. In the case of vlite, you simply give it the address 172.16.1.65 and add a host route pointing to it. Every datagram for 172.16.1.65 is then delivered locally. The proper invocation is:[5] # ifconfig dummy vlite # route add vlite IP Alias New kernels support a feature that can completely replace the dummy interface and serve other useful functions. IP Alias allows you to configure multiple IP addresses onto a physical device. In the simplest case, you could replicate the function of the dummy interface by configuring the host address as an alias
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services
It is quite useful to add information on the two interfaces to the hosts file as shown in the following example, so we have handy names for them, too: 172.16.1.1 vlager.vbrew.com vlager vlager-if1 172.16.2.1 vlager-if2 The sequence of commands to set up the two interfaces is then: # ifconfig eth0 vlager-if1 # route add brew-net # ifconfig eth1 vlager-if2 # route add wine-net If this sequence doesn’t work, make sure your kernel has been compiled with support for IP forwarding enabled. One good way to do this is to ensure that the first number on the second line of /proc/net/snmp is set to 1. The PLIP Interface A PLIP link used to connect two machines is a little different from an Ethernet. PLIP links are an example of what are called point-to-point links, meaning that there is a single host at each end of the link. Networks like Ethernet are called broadcast networks. Configuration of point-to-point links is different because unlike broadcast networks, point-to-point links don’t support a network of their own. PLIP provides very cheap and portable links between computers. As an example, we’ll consider the laptop computer of an employee at the Virtual Brewery that is connected to vlager via PLIP. The laptop itself is called vlite and has only one parallel port. At boot time, this port will be registered as plip1. To activate the link, you have to configure the plip1 interface using the following commands:[3] # ifconfig plip1 vlite pointopoint vlager # route add default gw vlager The first command configures the interface, telling the kernel that this is a point-to-point link, with the remote side having the address of vlager. The second installs the default route, using vlager as gateway. On vlager, a similar ifconfig command is necessary to activate the link (a route invocation is not needed): # ifconfig plip1 vlager pointopoint vlite Note that the plip1 interface on vlager does not need a separate IP address, but may also be given the address 172.16.1.1. Point-to-point networks don’t support a network directly, so the interfaces don’t require an address on any supported network. The kernel uses the interface information in the routing table to avoid any possible confusion.[4] Now we have configured routing from the laptop to the Brewery’s network; what’s still missing is a way to route from any of the Brewery’s hosts to vlite. One particularly cumbersome way is to add a specific route to every host’s routing table that names vlager as a gateway to vlite: # route add vlite gw vlager
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services