{"id":482,"date":"2024-11-19T03:00:10","date_gmt":"2024-11-18T19:00:10","guid":{"rendered":"https:\/\/cliffordjuan.com\/?p=482"},"modified":"2024-11-19T03:00:10","modified_gmt":"2024-11-18T19:00:10","slug":"my-journey-migrating-from-ipv4-to-ipv6-on-aws","status":"publish","type":"post","link":"https:\/\/cliffordjuan.com\/index.php\/2024\/11\/19\/my-journey-migrating-from-ipv4-to-ipv6-on-aws\/","title":{"rendered":"My Journey Migrating from IPv4 to IPv6 on AWS"},"content":{"rendered":"\n<p>As cloud hosting costs continue to evolve, it&#8217;s essential to review and optimize our infrastructure. Recently, I embarked on a journey to transition from IPv4 to IPv6 on my AWS-hosted website, primarily to eliminate the cost associated with AWS Elastic IPs. Here&#8217;s a recap of my experience, challenges, and ultimate success.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4>Why Migrate to IPv6?<\/h4>\n\n\n\n<p>AWS charges for Elastic IPs (EIP) even when they are associated with a running EC2 instance, making it a recurring cost that can be avoided. By adopting IPv6, I aimed to:<\/p>\n\n\n\n<ul><li><strong>Reduce expenses<\/strong>: Stop paying for Elastic IPs.<\/li><li><strong>Modernize the infrastructure<\/strong>: Future-proof my website&#8217;s networking.<\/li><li><strong>Enhance accessibility<\/strong>: Ensure the website is reachable over both IPv4 and IPv6 as more networks adopt the newer protocol.<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4>Initial Setup: My AWS Environment<\/h4>\n\n\n\n<p>My website, hosted on an AWS EC2 instance, runs a LAMP stack on Amazon Linux 2. The setup includes Apache, MariaDB, and PHP, supporting a WordPress-based site. Before the migration, the site was accessible only via IPv4, with an AWS Elastic IP attached.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4>The Migration Process<\/h4>\n\n\n\n<p>Here\u2019s a step-by-step breakdown of how I migrated to IPv6:<\/p>\n\n\n\n<ol><li><strong>Enable IPv6 in the VPC<\/strong><ul><li>I started by adding an IPv6 CIDR block to the VPC associated with my EC2 instance. AWS offers multiple options, but for simplicity, I chose an <strong>Amazon-provided IPv6 CIDR block<\/strong>.<\/li><\/ul><\/li><li><strong>Configure the Subnet for IPv6<\/strong><ul><li>Next, I allocated an IPv6 CIDR block to the subnet where my instance resides. This assignment allowed the EC2 instance to obtain an IPv6 address.<\/li><\/ul><\/li><li><strong>Update the Routing Table<\/strong><ul><li>One key step was updating the VPC&#8217;s routing table. I added a route for <code>::\/0<\/code> with the Internet Gateway as the target. While there was already a route for <code>0.0.0.0\/0<\/code> (IPv4), the IPv6 traffic required this new route.<\/li><\/ul><\/li><li><strong>Modify Apache Configuration for IPv6<\/strong><ul><li>I adjusted the Apache <code>httpd.conf<\/code> settings:<ul><li>Replaced <code>Listen 80<\/code> with <code>Listen [::]:80<\/code><\/li><li>Replaced <code>Listen 443<\/code> with <code>Listen [::]:443<\/code><\/li><\/ul><\/li><li>However, I retained the <code>&lt;VirtualHost *:80&gt;<\/code> and <code>&lt;VirtualHost *:443&gt;<\/code> blocks, as they worked fine for both IPv4 and IPv6 connections.<\/li><\/ul><\/li><li><strong>Update DNS Settings<\/strong><ul><li>I added an <strong>AAAA record<\/strong> in my DNS configuration to ensure that the domain resolves to the server&#8217;s IPv6 address. This step was crucial for making the website accessible over IPv6.<\/li><\/ul><\/li><li><strong>Restart Apache<\/strong><ul><li>After making these changes, I restarted the Apache service. Everything was configured properly, and the web server could now handle requests over IPv6!<\/li><\/ul><\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4>Challenges Faced and Lessons Learned<\/h4>\n\n\n\n<ol><li><strong>Routing Table Misconfiguration<\/strong><ul><li>Initially, the IPv6 setup didn&#8217;t work. I realized I had missed adding the <code>::\/0<\/code> route in the routing table, which is crucial for directing IPv6 traffic to the Internet Gateway.<\/li><\/ul><\/li><li><strong>Firewall and Security Group Settings<\/strong><ul><li>Ensuring security groups allowed IPv6 traffic on ports 80 (HTTP) and 443 (HTTPS) was another important task. Always double-check inbound and outbound rules when dealing with new protocols.<\/li><\/ul><\/li><li><strong>Understanding Apache&#8217;s Dual-Stack Configuration<\/strong><ul><li>Although I only needed to add <code>Listen [::]:80<\/code> and <code>Listen [::]:443<\/code>, I was initially unsure if I needed to update <code>&lt;VirtualHost&gt;<\/code> settings for IPv6. Fortunately, the existing configuration worked without modification.<\/li><\/ul><\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4>The Result: Cost Savings and Modernization<\/h4>\n\n\n\n<p>With everything set up correctly, my website is now accessible over both IPv4 and IPv6. More importantly, I no longer need to pay for an AWS Elastic IP, leading to tangible cost savings. The transition has made my website&#8217;s networking stack future-proof while ensuring broader accessibility as more users move to IPv6.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3>Conclusion<\/h3>\n\n\n\n<p>Migrating from IPv4 to IPv6 may seem daunting, but with a clear objective, proper planning, and attention to details like routing and DNS configuration, the process is smooth and rewarding. If you&#8217;re looking to cut down on cloud costs or modernize your setup, I highly recommend considering an IPv6 migration.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As cloud hosting costs continue to evolve, it&#8217;s essential to review and optimize our infrastructure. Recently, I embarked on a journey to transition from IPv4 to IPv6 on my AWS-hosted website, primarily to eliminate the cost associated with AWS Elastic IPs. Here&#8217;s a recap of my experience, challenges, and ultimate success. Why Migrate to IPv6? &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/cliffordjuan.com\/index.php\/2024\/11\/19\/my-journey-migrating-from-ipv4-to-ipv6-on-aws\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;My Journey Migrating from IPv4 to IPv6 on AWS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,15,32,26],"tags":[47,8,50,44,43,45,46,49,51],"_links":{"self":[{"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/posts\/482"}],"collection":[{"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/comments?post=482"}],"version-history":[{"count":2,"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/posts\/482\/revisions"}],"predecessor-version":[{"id":484,"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/posts\/482\/revisions\/484"}],"wp:attachment":[{"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/media?parent=482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/categories?post=482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cliffordjuan.com\/index.php\/wp-json\/wp\/v2\/tags?post=482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}