When mail is sent from my server, QMail uses an incorrect IP for the connection. How do I change the IP used for outgoing connections from my server?

Refers to:

  • Plesk for Linux

Created:

2016-11-16 13:23:13 UTC

Modified:

2016-12-21 20:36:06 UTC

0

Was this article helpful?


Have more questions?

Submit a request

When mail is sent from my server, QMail uses an incorrect IP for the connection. How do I change the IP used for outgoing connections from my server?

Symptoms

I would like to configure an IP address used by QMail for outgoing connections from my server.

Resolution

The default IP for outgoing connections can be set using the " ip " utility. First, check how routing is configured on the server:

# /sbin/ip route
192.168.50.0/24 dev eth1 proto kernel scope link src 192.168.50.53
169.254.0.0/16 dev eth1 scope link
default via 192.168.50.254 dev eth1

If no " src " is listed in the " ip " output for the default route, the main IP on the interface is used for outgoing connections. You can change it using the following command:

# /sbin/ip route change default via 192.168.50.254 dev eth1 src 192.168.50.100

Now:

# /sbin/ip route
192.168.50.0/24 dev eth1 proto kernel scope link src 192.168.50.53
169.254.0.0/16 dev eth1 scope link
default via 192.168.50.254 dev eth1 src 192.168.50.100

Note: Be careful. If you set the wrong IP as the source, you will lose the link to the server.

Additional Information

To preserve this result after reboot:

  • CentOS and RedHat OS'es:

    Route configuration can be stored per-interface in a /etc/sysconfig/network-scripts/route-interface file. For example, static routes for the eth0 interface would be stored in the /etc/sysconfig/network-scripts/route-eth0 file. The route-interface file has two formats: ip command arguments and network/netmask directives. See the ip-route(8) man page for more information on the ip route command

  • SuSE Linux:

    Insert the following lines into the /etc/sysconfig/network/if-up.d/staticroute file:

    /sbin/ip route change default via 192.168.50.254 dev eth1 src 192.168.50.100
    /sbin/ip route change 192.168.50.0/24 dev eth1 src 192.168.50.100
Have more questions? Submit a request
Please sign in to leave a comment.