Skip to content

I've got a HUGE mystery for you. Crazy DNS weirdness

0

I could really use some help with this. Nothing makes sense. I have public IP's from new EC2s forwarding to the public IP of an EC2 that I terminated and I have no idea how or why it is happening!

So, I created a fault tolerant Wordpress site like this:

First, I created a custom VPC with public and private subnets- the web servers in the public and the RDS instance in the private. (security groups and such are all working).

Two EC2s in an auto scaling group behind load balancer. I set up an A record/alias pointing to the Application Load Balancer so that read traffic would be directed to these instances.

I have an EC2 that I use at the "writer node" for the site. I log into Wordpress using this EC2s public IP and update the site. I have a crontab setting that checks for updates every minute and syncs the WP code into one bucket and the WP media into another bucket. Of course, the actual WP database is sitting on an RDS instance.

If one of the EC2s behind the load balancer dies, a new one is spun up, a bootstrap scripts installs WP, Apache, etc... then checks the S3 buckets for the current copies of the code.

I have a Cloudfront distribution that serves the media (WP uploads folder) from an S3 bucket, and I have a redirect in the .htaccess to use that Cloudfront distribution for the media.

So, everything was working great! I could enter the DNS address for the load balancer- bam! I could enter the public IP address for the writer-node EC2- bam. No problems at all. Then I plugged Route 53 into the mix and everything fell apart and I can't seem to find any way to fix it short of completely rebuilding everything. Personally, I need to know WHY this happened, so I hope that YOU can provide some insight. Here's what the problem looks like:

I transferred a domain that I owned to Route 53. When it was cleared, I created a new hosted zone, an A record/alias, and pointed it at the ALB. So good so far. Except it didn't work.

After searching, I found a thread that had me create a duplicate hosted zone and copy the name server info over to the previous hosted zone fields. Then, when it was working, delete the old hosted zone. It worked! So, I had an A record/alias pointing to my ALB, then I created another record with the phrase write.myurl.com to my writer node IP address.

Well, it sort of worked. I thought it was working fine, but then at some point I noticed that when I went to myurl.com, it was loading the public IP address of my writer node instead of any of the EC2s behind my ALB. So, I deleted that writer node record from the hosted zone (write.myurl.com). Nope. Here's where it gets weirder.

Even if I copy and paste the DNS address of my ALB into the browser window, it still goes to the public IP of the writer node. Even if I copy and paste the public IPs of the individual EC2s behind the ALB it still goes to that writer node EC2.

Weirder yet! I stopped the writer-node instance so it would get a new public IP and then assigned an elastic IP to it, yet everything STILL forwards to the original public IP address that was assigned to that server.

I of course tried every possible option in Route 53- adjusting TTLs, deleting and creating records, and even deleting the whole dang zone- everything ALWAYS resolves to this IP: http://18.217.68.109 no matter what, and that is no longer the IP address to that server!

And even weirder, that IP now has a Hello World message that pops up, which just happened today LOL! I can't ssh into it because it's not in my account- I only have three EC2s spinning right now, so someone else must have that IP I guess.

So, what in the HECK am I missing?!?! It's been three days and nothing has changed other than that mystery Hello World showing up. Did I accidentally create artificial intelligence and it's now saying hello to me? I don't want to trash the resources and start over because I feel that there is a great lesson to be learned.

Here, check it out. Here are the three IPs of my EC2s in my account:
3.143.183.220
3.135.203.149
3.15.201.71

Here is the DNS name for my ALB:
DemoFaultTolerantLB-1083289545.us-east-2.elb.amazonaws.com

They will all magically forward to http://18.217.68.109. The ONE thing that is NOT forwarding at all is my URL, ironically. That just gives a "can't find the server" error even though I still have an A/alias pointing to the ALB.

Please tell me what I am missing. I have to figure this out. Thanks in advance for your time!

-Phil

UPDATE: I just tested the A/alias record using Route 53's tool and it said there was no error. Furthermore, the record response for that record says that it is pointing to these two IPs: 3.140.44.216 and 3.128.236.33, which (you guessed it) both forward to 18.217.68.109! Neither of those two IPs (or three, for that matter) are anywhere in my account. They are NOT the IPs of the two EC2s that I have behind that load balancer.

I should note that I never even turned on Sticky Sessions...

Edited by: Bassphil on Mar 27, 2021 1:26 PM

Edited by: Bassphil on Mar 27, 2021 1:30 PM

asked 5 years ago321 views

3 Answers
0

Sorry, it dawned on me that the only way this could be happening is if the RDS instance was calling the shots, i.e. making things redirect to that original URL. How? Because that was the URL that was entered when I initially set up the Wordpress installation.

I set up the entire environment BEFORE I imported my URL into Route53 and created the records. I completely forgot that Wordpress saves the site URL.

So, if anyone finds this thread someday in the future, there are two ways to fix this.

  1. Enter the site URL in the wp-config.php file, which should override the database info
  2. Install phpMyAdmin and alter its config file to point to the RDS endpoint. Then you can change the URL there. I found it in three places.

answered 5 years ago

0

Sorry, it dawned on me that the only way this could be happening is if the RDS instance was calling the shots, i.e. making things redirect to that original URL. How? Because that was the URL that was entered when I initially set up the Wordpress installation.

I set up the entire environment BEFORE I imported my URL into Route53 and created the records. I completely forgot that Wordpress saves the site URL.

So, if anyone finds this thread someday in the future, there are two ways to fix this.

  1. Enter the site URL in the wp-config.php file, which should override the database info
  2. Install phpMyAdmin and alter its config file to point to the RDS endpoint. Then you can change the URL there. I found it in three places.

answered 5 years ago

0

double post

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.