Force ipv4 for mail application

I am migrating to NethServer 8 and have a shared setup with on-premise and cloud hosted vps node. The cloud hosted VPS node only has a ipv4 address (and routes):

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group 
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether bc:24:11:17:ac:67 brd ff:ff:ff:ff:ff:ff
    altname enp0s18
    altname ens18
    inet 95.169.192.47/24 brd 95.169.192.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::be24:11ff:fe17:ac67/64 scope link
       valid_lft forever preferred_lft forever
3: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN 
...

But mail stays in the queue. Apparently the server tries to deliver through IPv6 instead of IPv4:

2025-12-26T22:23:24+01:00 [2:mail1:postfix/smtp] 76647603015E: to=<jonathan.martens@maastro.nl>, relay=none, delay=667, delays=577/0.03/90/0, dsn=4.4.1, status=deferred (connect to maastro-nl.mail.protection.outlook.com[2a01:111:f403:ca04::e]:25: Network unreachable)

I am supposed to force IPv4 traffic and would normally do something like postconf -e ‘inet_protocols = ipv4’ followed by a restart of postfix.

I want to make sure I did the right thing:

  1. I sudo-ed into mail1 user using sudo -iu mail1
  2. Then entered the postfix container using podman exec -it postfix sh
  3. Set IPv4 preference using: postconf -e ‘inet_protocols = ipv4’
  4. Reload postfix configuration using postfix reload

It seems to work as it is trying to deliver using IPv4 …

2025-12-26T22:52:46+01:00 [2:mail1:postfix/smtp] 76647603015E: to=<jonathan.martens@maastro.nl>, relay=none, delay=2429, delays=2309/0.06/120/0, dsn=4.4.1, status=deferred (connect to maastro-nl.mail.protection.outlook.com[52.101.68.29]:25: Operation timed out)

but I am wondering if this is the correct way to make changes persistent?

I still have one more thing to do as my VPS provider seems to block port 25.:-(. Off to see if they have a relay or are open to unblocking port 25.

No, it’s not persistent, after a service restart (or app update/restore) the changes will be lost.

To customize postfix, add inet_protocols = ipv4 to the /etc/postfix/main.cf.d/myoverride.cf file as explained in the mail app README.

1 Like

I have tried the instructions from the README, but seem to have some issues still:

I ran the following:

sudo -iu mail1
podman exec -ti postfix vi /etc/postfix/main.cf.d/myoverride.cf

Added the line inet_protocols = ipv4 line as can be observed:

podman exec -ti postfix cat /etc/postfix/main.cf.d/myoverride.cf
inet_protocols = ipv4

But when I run systemctl --user reload postfix as per suggestion of the README this seems to fail:

systemctl --user reload postfix
Failed to connect to bus: No medium found

I am still trying to get the hang of NethServer 8 administration/design philosophy (having experience and being on the development team of SME Server/Koozali as well as having ran ClearOS and other barebone linux distros).

Please try to run the following instead of the sudo command.

runagent -m mail1

Now the service reload should work:

systemctl --user reload postfix
1 Like