Multiple IP addresses - set the primary
I have a SMTP server in Hetzner Cloud. Have added floating IPv4 and IPv6 (in case I switch server and the IP's can follow to the new server)
How to set the floating IP's as primary?
When a client sends a mail it is sent to the floating IP (smtp.server.com), but when the SMTP forwards the mail to recipient server the primary IP is used and SPF fails
How to set the floating IP's as the primary IP addresses?
I want to set eth0:1
as the primary outbound IP address for both the IPv4 and IPv6
/etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
dns-nameservers xx.xx.xx.xx xx.xx.xx.xx xx.xx.xx.xx
iface eth0 inet6 static
address [primary IPv6]
gateway fe80::1
# Additional IPv4 (floating IP)
auto eth0:1
iface eth0:1 inet static
address [additional IPv4]
netmask 32
# Additional IPv6 (floating IP)
auto eth0:1
iface eth0:1 inet6 static
address [additional IPv6]
netmask 64
Solution 1:
I found a solution
# ip route replace default via 172.31.1.1 dev eth0 src [additional IPv4]
# ip -6 route replace default via fe80::1 dev eth0 src [additional IPv6]