GoAdmio

mynetworks

Set the IP addresses and networks trusted to relay mail through Postfix without logging in (localhost and the server's own IP are always included), then restart the mail server

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

/go/mynetworks sets Postfix's mynetworks list: the IP addresses and networks whose mail the server accepts without an SMTP login. This is how, for example, another server or an office network can send mail through this server without a username and password.

It saves your list in GoAdmio's configuration database, writes it to the Postfix configuration, and restarts the mail server.

[!WARNING] Trusted networks can send mail through this server without authenticating. Only add addresses you control. A range that is too wide, such as 0.0.0.0/0, turns the server into an open relay, which spammers will find quickly and which can get the server's IP blocklisted.

[!NOTE] The command replaces the list each time. Pass every network you want to keep, not only the new one.


Quick start

# Trust one outside IP address
/go/mynetworks 203.0.113.10/32

Syntax

/go/mynetworks ["<network> [<network> ...]"]

Put all networks in one quoted argument, separated by spaces or commas. Run the command as root.


Arguments

Argument Required Notes
"<networks>" No One or more IP addresses or networks, as a single quoted value. With no argument, the list is reset to localhost and the server's own IP.

Network formats

Format Example
Single IPv4 address 203.0.113.10/32
IPv4 network 198.51.100.0/24
IPv6 address or network, in square brackets [2001:db8::1]/128, [2001:db8::]/64

Do not use quotation marks inside the list. The command does not check the values.


Output

The command prints nothing of its own. Any messages come from the tools it runs (sqlite3, postconf, and the mail restart). Every call is also appended to /var/log/go/mynetworks.log.


Examples

# One address
/go/mynetworks 203.0.113.10/32
# Several addresses and a network, in one quoted argument
/go/mynetworks "203.0.113.10/32 198.51.100.0/24"
# Same, separated by commas
/go/mynetworks "203.0.113.10/32,198.51.100.0/24"
# Reset to localhost and the server's own IP only
/go/mynetworks
# Check what is active
postconf mynetworks
sqlite3 /var/lib/sqlite/config.db "SELECT MyNetworks FROM Config;"

Troubleshooting

Symptom Likely cause Fix
The command fails or the list is not saved when you give several networks The networks were passed as separate arguments. Put them in one quoted argument. See Passing several networks.
Mail from another server is rejected with Relay access denied The sender's IP is not in the list, or the address Postfix sees is different (for example, behind NAT, or IPv6 instead of IPv4). Check the sender's real address in the mail log, add it, and check with postconf mynetworks.
Earlier networks disappeared Each run replaces the list. Run again with every network you want to keep.
The server's own IP is missing from postconf mynetworks The public IP lookup failed, for example because the server had no outbound access. Run the command again.
The server is sending spam A trusted network is too wide. Run /go/mynetworks with no argument to reset, then add back only the addresses you control. Review with mailtop and outgoing.
An error mentioning an unterminated string or a syntax error The list contains a quotation mark. Remove it and run again.

Details

What the list contains

The Postfix setting is built as:

mynetworks = 127.0.0.0/8 [::1]/128 <server public IP> <your networks>

The first three entries are always present. The part you pass is saved separately in the MyNetworks field of GoAdmio's configuration database (/var/lib/sqlite/config.db), without those three.

Passing several networks

The script places its arguments directly inside the database command and the postconf command. Separate arguments are therefore split apart, which breaks both commands. A single quoted argument is passed intact:

# Works
/go/mynetworks "203.0.113.10/32 198.51.100.0/24"

# Can fail
/go/mynetworks 203.0.113.10/32 198.51.100.0/24

What it does

flowchart TD
    A["mynetworks ..."] --> B["Look up the server's public IPv4"]
    B --> C["Save your list in config.db"]
    C --> D["Set Postfix mynetworks"]
    D --> E["Restart the mail server"]
  1. Appends the command line to /var/log/go/mynetworks.log.
  2. Looks up the server's public IPv4 address with checkip.amazonaws.com.
  3. Saves the arguments in the MyNetworks field of the Config table in /var/lib/sqlite/config.db.
  4. Sets mynetworks in Postfix with postconf -e to localhost, the server's IP, and your networks.
  5. Restarts the mail server with /go/mail restart.

See also

Command Description
mail Create an email address in GoAdmio via the command line
installmail Install and configure webmail services (Postfix and Dovecot)
checksmtp Check that the server's SMTP service accepts a login on port 587
postfwd Build the Postfwd rate-limiting rules
mailtop Check the most active email accounts in GoAdmio
outgoing Report today's outbound mail sessions
troubleshoot Troubleshoot email problems in GoAdmio