proxymap Command in Linux



The proxymap in Linux is a Postfix service that provides lookup table access to read-only or read-write the Postfix processes. It helps to bypass chroot restrictions and reduces open lookup tables by sharing one among multiple processes.

Table of Contents

Here is a comprehensive guide to the options available with the proxymap command −

How the proxymap Server Works?

The proxymap server handles the following requests −

  • open maptype:mapname flags − Opens the specified table with the given flags. The response includes maptype-specific flags.
  • lookup maptype:mapname flags key − Retrieves data for the given key. The response includes the status code and lookup result.
  • update maptype:mapname flags key value − Updates data for the given key. The response includes the status code. For single-updater maps, set the proxywrite service limit to 1 in master.cf.
  • delete maptype:mapname flags key − Removes data for the given key. The response includes the status code.

Status codes − OK, RETRY, NOKEY (key not found), BAD (malformed request), DENY (access not allowed). There is no close command; tables remain open to share across client processes.

Configuration Parameters of proxymap Service

These parameters control how proxymap accesses lookup tables and handles requests −

Parameter Description
config_directory Default location of main.cf and master.cf configuration files.
data_directory Directory for Postfix-writable data files (e.g., caches, pseudo-random numbers).
daemon_timeout (18000s) Maximum time a daemon process can handle a request before termination.
ipc_timeout (3600s) Time limit for internal communication.
max_idle (100s) Maximum idle time before a daemon process terminates.
max_use (100) Maximum number of connections a daemon process handles before termination.
process_id (read-only) ID of a Postfix command or daemon process.
process_name (read-only) Name of a Postfix command or daemon process.
proxy_read_maps Lookup tables accessible to the proxymap(8) server (read-only).
proxy_write_maps Lookup tables accessible to the proxymap(8) server (read-write).

Examples of proxymap Service in Linux

This section explains how to use the proxymap service in Linux with examples.

Reading Lookup

To read the lookup with proxymap, first, ensure proxy_reads_maps is configured in the main.cf file. If not, then define it.

proxy_read_maps = proxy:hash:/etc/aliases
proxymap Command in Linux1

Next, ensure the aliases file exists and is updated −

sudo nano /etc/aliases

After updating the file, reload the postfix service −

sudo postfix reload

Now, check if the alias for root is correctly retrieved −

sudo postmap -q root proxy:hash:/etc/aliases
proxymap Command in Linux2

Reading-Writing Lookup

To read-write the lookup with proxymap, first, ensure proxy_write_maps and proxy_read_maps are configured in the main.cf file. If not, then define them.

proxy_write_maps = proxy:btree:/etc/postfix/virtual
proxy_read_maps = proxy:btree:/etc/postfix/virtual
proxymap Command in Linux3

Next, update the /etc/postfix/virtual

sudo nano /etc/postfix/virtual

After updating the file, convert it into a lookup table and reload the postfix service −

sudo postmap /etc/postfix/virtual
sudo postfix reload

Update (write) the new entry −

echo "newuser@test.com localuser" | sudo tee -a /etc/postfix/virtual
proxymap Command in Linux4

Run postmap to convert the text file into a .db file −

sudo postmap btree:/etc/postfix/virtual

Verify the change −

sudo postmap -q newuser@test.com proxy:btree:/etc/postfix/virtual
proxymap Command in Linux5

Conclusion

The Postfix proxymap service in Linux optimizes lookup table access by sharing tables among multiple processes, reducing resource usage, and bypassing chroot restrictions. It supports read and write operations with various lookup tables, ensuring efficient data retrieval and updates.

Proper configuration in main.cf and master.cf allows control over parameters like timeouts, process limits, and access permissions. Using proxymap involves defining read and write maps, updating lookup tables, and verifying changes.

In this tutorial, we covered the Postfix proxymap service, its configuration parameters, and how to configure it for reading and writing.

Advertisements