Migrate to ipv4 to ipv6 for AWS Ec2

How do I migrate my ec2 instance running MiaB from ipv4 to ipv6 because of the upcoming changes to ipv4 pricing.

Please note that it is not a good idea to fully migrate to IPV6 since only google accepts IPV6 only mail. The rest of the big ones such as outlook, msn, proton, icloud and yahoo will fail to connect. Their prefrence is IPV4 to limit spam. However if you wish to save on ipv4 there is a way to tell postfix to prefer ipv6 and thus use ipv6 whenever possible.
Here is how:

First make sure you are assigned an IPV6 address on AWS. I am not familiar with the IPV6 assignement process for AWS. Read and once you are assigned both ipv4 and ipv6 address on your box, make sure both have proper PTR records (reverse dns).

Test you box is working with IPV6 by pinging google’s ipv6 like this

ping -6 google.com.

If the ping is OK you are good to proceed with telling postfix to send via IPV6.

sudo nano /etc/postfix/main.cf

smtp_address_preference= ipv6

This entry tells postfix to prefer ipv6 over ipv4. Test ipv6 by sending yourself an email on a gmail account. Open your gmail account and if you receive the message press Show Original to see the headers. Inspect the headers and look for your IPV6 address SPF: PASS with IPV6 ADRESS.If there is IPV4 address try again posfix might have decided to send it over IPV4 anyway.

I do not recomend the following since you will be able to send to IPV6 capable servers only, but if you wish to send only via IPV6 edit

sudo nano /etc/postfix/main.cf

inet_protocols = ipv6


I did this recently. You can search online for the various actual guides but as per the other comment it isn’t realistic to switch to only IPv6 currently. The upcoming charging just focussed me on reducing the other costs to allow for the increase for my sole IPv4 address. The IPv6 isn’t an elastic one but, from memory, doesn’t get changed unless you terminate the instance.

In short, if I remember correctly, you are configuring your instance to have an IPv6 address as well, re-running MIAB setup to get it to recognise the address (you’ll then see it when logging in to SSH and in the MIAB status web page), and putting in an AWS request for an IPv6 rDNS as well to match your IPv4 one you’ll have done previously (it looks like the request is for IPv4 only but just add the comments to be what you’re after).

Worth pointing out that we might need to be careful with rDNS records if doing a bigger Ubuntu upgrade for MIAB as I think that was easiest by throwing away the old instance and creating a new one and reassigning the elastic IP. Should be fine by creating a new correct instance, setting it up, then moving the volumes across to replace the existing ones. Same as when shrinking volumes as part of a ‘reduce AWS bill’ drive to allow for the impending IPv4 charge.


Hmmm. Thanks Andrew for sharing this info. I am not quite sure what AWS is trying to do but I know that they have not as many reserved IPV4 addresses, as they have much more clients than the rest of the cloud providers and thus they want to compensate beacause they are running out of them. You are right that the IPV6 transition is unrealistic since most of the smtp servers seem to accept only IPV4 connections. Which is stupid. Again, this seems to be a spam reduction scheme or they are laisy to transition to IPV6. However the more smtp servers start to accept IPV6 connections, the more the “Big email service providers” will be forced to accept IPV6.

I am running both IPV4 and 6 Mailinabox setup as per the discription above and be ware that although revesrse dns might be set correctly for the IPV6, google seems to filter IPV6 messages as spam by default, until you register an abuse email address. When enabling IPV6 keep a watchful eye on a number of email blacklists and delist yourself by providing an abuse email adress in the warming up phase.
https://multirbl.valli.org/ has both IPV4 and IPV6 blacklists

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.