Route 53 alias record not working? - amazon-web-services

I previously had a website working on AWS. It was created & registered with AWS. It was setup in the hosted zone and point to an EC2 instance. Everything was working fine.
I got "smart" and created a load balancer, which pointed to the EC2 instance, and then I deleted the previous hosted zone record (and associated recordset) and re-added the hosted zone record which would point to the load balancer.
After much googling I determined I needed to add an "A" record, make it an alias and point it to the load balancer. All good so far.
Then I went to access the website in browser and Im getting ERR_NAME_NOT_RESOLVED. I waited hours for DNS servers to update and still no luck. Flushed DNS cache and no luck.
Ive changed multiple other things - tried www in front of name in recordset, tried a ptr record which pointed to load balancer DNS name, and even tried to sync the dns server names between the domain record and the hosted zone record. Still no luck. Same error.
Ive performed "nslookup debug" and honestly dont know what Im looking at.
C:\Users\sam>nslookup -debug abc.com
Got answer:
HEADER:
opcode = QUERY, id = 1, rcode = NOERROR
header flags: response, auth. answer, want recursion, recursion avail.
questions = 1, answers = 1, authority records = 0, additional = 0
QUESTIONS:
1.1.168.192.in-addr.arpa, type = PTR, class = IN
ANSWERS:
-> 1.1.168.192.in-addr.arpa
name = xyz
ttl = 0 (0 secs)
Server: xyz
Address: 192.168.1.1
Got answer:
HEADER:
opcode = QUERY, id = 2, rcode = SERVFAIL
header flags: response, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
abc.com, type = A, class = IN
------------
Got answer:
HEADER:
opcode = QUERY, id = 3, rcode = SERVFAIL
header flags: response, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
abc.com, type = AAAA, class = IN
------------
Got answer:
HEADER:
opcode = QUERY, id = 4, rcode = SERVFAIL
header flags: response, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
abc.com, type = A, class = IN
------------
Got answer:
HEADER:
opcode = QUERY, id = 5, rcode = SERVFAIL
header flags: response, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
abc.com, type = AAAA, class = IN
*** xyzcan't find abc.com: Server failed
Im sure its something dumb. But Ive spent too much time on this and cant think anymore.
What did I do wrong?
Thanks for your help.

even tried to sync the dns server names between the domain record and the hosted zone record.
If that was necessary, then it sounds like at some point you deleted and recreated the hosted zone... which does not work the way you may have anticipated.
The simplest way out of that, is this:
Leaving the existing zone exactly as it is, create a new hosted zone with the same domain. (Yes, this works).
Note the four name servers assigned for the new hosted zone.
Go to the domain record (the registrar component of Route 53, not the hosted zone component) and change the 4 name servers to match those assigned to your new hosted zone.
In the new hosted zone, create a new A record, hostname box empty, Alias = Yes, and select the ELB name.
Once it's working, delete the old hosted zone.

Related

Drupal 8 |Mysql Gone Away Error when connection remote DB server

I am facing mysql gone away issue. Site was working fine past 2 days i am getting this issue.
I have tried all the combination max_allowed_packet , wait_timeout & Intractive_timeout still not working.
Tried with different Drupal instance in different servers & different DB servers same issue. Please help me to fix this issue. there is not network issue also ping , telnet working fine with 3306 port.
Additional uncaught exception thrown while handling exception.
Original
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {cache_discovery} (cid, expire, created, tags, checksum, data, serialized) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6) ON DUPLICATE KEY UPDATE cid = VALUES(cid), expire = VALUES(expire), created = VALUES(created), tags = VALUES(tags), checksum = VALUES(checksum), data = VALUES(data), serialized = VALUES(serialized); Array ( [:db_insert_placeholder_0] => entity_type [:db_insert_placeholder_1] => -1 [:db_insert_placeholder_2] => 1621427865.35 [:db_insert_placeholder_3] => entity_types [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => a:8:{s:6:"action";O:42:"Drupal\Core\Config\Entity\ConfigEntityType":44:{s:16:"*config_prefix";N;s:15:"*static_cache";b:0;s:14:"*lookup_keys";a:1:{i:0;s:4:"uuid";}s:16:"*config_export";a:5:{i:0;s:2:"id";i:1;s:5:"label";i:2;s:4:"type";i:3;s:6:"plugin";i:4;s:13:"configuration";}s:21:"*mergedConfigExport";a:0:{}s:15:"*render_cache";b:1;s:19:"*persistent_cache";b:1;s:14:"*entity_keys";a:8:{s:2:"id";s:2:"id";s:5:"label";s:5:"label";s:8:"revision";s:0:"";s:6:"bundle";s:0:"";s:8:"langcode";s:8:"langcode";s:16:"default_langcode";s:16:"default_langcode";s:29:"revision_translation_affected";s:29:"revision_translation_affected";s:4:"uuid";s:4:"uuid";}s:5:"*id";s:6:"action";s:16:"*originalClass";s:27:"Drupal\system\Entity\Action";s:11:"*handlers";a:2:{s:6:"access";s:45:"Drupal\Core\Entity\EntityAccessControlHandler";s:7:"storage";s:45:"Drupal\Core\Config\Entity\ConfigEntityStorage";}s:19:"*admin_permission";s:18:"administer actions";s:25:"*permission_granularity";s:11:"entity_type";s:8:"*links";a:0:

Add PTR record using dnspython

Im trying to add a PTR record with dnspython to bind9 using this code:
def send_query(query, server):
update = dns.query
update.tcp(query, server)
def add(name, rdtype, rdata, ttl=300, zone):
server = dns.resolver.Resolver()
server.nameservers = '<dns server>'
keyring = dns.tsigkeyring.from_text({
'key-name': 'key'
})
record = dns.update.Update(zone=zone, keyring=keyring)
record.add(name, ttl, rdtype, rdata)
send_query(record, server.nameservers)
Im able to successfully add the record when passing:
name = last octet
rdtype = PTR
data = server-FQDN
zone = z.y.x.in-addr.arpa
but when querying the dns server via nslookup I get:
~ nslookup X.Y.Z.6
Server: NS server
Address: NS server#53
6.Z.Y.X.in-addr.arpa name = server-FQDN.Z.Y.X.in-addr.arpa.
The problem is the "Z.Y.X.in-addr.arpa." part added to the query.
In the zone file the record is in the right syntax
Is there a better way to add PTR record with dnspython?
The reason this didn't work was that I forgot to add the ending "." at the end of the hostname FDQN and therefore the domain was completed automatically.

what are the values in _ga cookie?

I am using universal analytics. universal analytics creates first party cookie _ga
_ga=1.2.286403989.1366364567;
286403989 is clientId
1366364567 is timestamp
what is 1 and 2 in _ga cookie?
_ga=1.2.286403989.1366364567;
1st Field
This is a versioning number. In case the cookie format changes in the future. Seems to be fixed at 1 at the moment. The one above is an old format. Newer cookies have this value set at "GA1"
2nd Field
This field is used to figure out the correct cookie in case multiple cookies are setup in different paths or domains.
By default cookie are setup at path / and at the domain on document.location.hostname (with the www. prefix removed).
You could have a _ga cookie set at sub.example.com and another cookie set at example.com. Because the way the cookie API on browsers works there's no way to tell which is the correct cookie you use.
So the second number is the number of components (dot separated) at the domain.
for sub.example.com the number would be 3
for example.com the number would be 2
The path defaults to / but you can also change it by passing the cookiePath option to the ga.create method. If you pass it this field becomes 2 numbers dash separated. And the second number is the number slashes in the path.
Using these numbers the analytics.js script can correctly identify the cookie to be used in case there are multiple cookies set.
eg:
Imagine that you have a site that lives at sub1.sub2.example.com/folder1 in case you want to store the cookie only on your site and not make it visible to other subdomains or folders you can use the following configs:
ga('create', 'UA-XXXX-Y', {
'cookiePath': '/folder1/',
'cookieDomain': 'sub1.sub2.example.com'
});
In this case the cookie will look somoething like this;
_ga=1.4-2.XXXXXXXX.YYYYYYY
3rd Field
This is a random generated user ID. Used to identify different users.
4th Field
It's a timestamp of the first time the cookie was set for that user.
new Date(1366364567*1000)
> Fri Apr 19 2013 06:42:47 GMT-0300 (BRT)
This is also used to uniquely identify users in case of userId collisions.
Worth mentioning that a cookie is not an API. In the future it may completely change. Google doesn't recommend reading/writing the _ga cookie directly. You should interact with Google Analytics through one of the tracking libraries such as analytics.js. There's not a lot of use for this information other than curiosity.
If you are reading/writing directly the cookie you are doing it wrong.
I think this would be helpful.
/**
* Get Google Analytics UID
* #return int
*/
public function getGAUID() {
$uid = 0;
if ($_COOKIE['__utma'])
list($hash_domain, $uid, $first_visit, $prew_visit, $time_start, $num_visits) = sscanf($_COOKIE['__utma'], '%d.%d.%d.%d.%d.%d');
elseif ($_COOKIE['_ga'])
list($c_format, $c_domain, $uid, $first_visit) = sscanf($_COOKIE['_ga'], 'GA%d.%d.%d.%d');
return $uid;
}
Written in NodeJS with ES6 Syntax. Might help someone?
// Example: GA1.2.494614159.1574329064
const gaCookieGeneration = ({ version = 1, domain, rootpath = '/' }) => {
const subdomains = (domain.match(/./) || []).length + 1;
const rootpathDirs = (rootpath.match(/\//) || []).length;
const cookiePath = rootpathDirs > 1 ? `-${rootpathDirs}` : '';
const uniqueId = Math.random().toString().substr(2, 9);
const timeStamp = (+new Date()).toString().substr(0, 10);
return `GA${version}.${subdomains}${cookiePath}.${uniqueId}.${timeStamp}`;
};
const gaCookie = gaCookieGeneration({
domain: '.example.com',
});

Can't decrypt cookie with a custom domain name

I'm using an Windows Azure Cloud Service and when I access to it using my domain name instead of [CLOUDSERVICENAME].cloudapp.net I have problems with authentication cookies.
I'm creating the cookies
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
1,
serializeModel.Username,
DateTime.Now,
DateTime.Now.AddMinutes(15),
false,
userData);
string encTicket = FormsAuthentication.Encrypt(authTicket);
System.Web.HttpCookie faCookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
Response.Cookies.Add(faCookie);
But when I try to decrypt it I get a null value.
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie != null)
{
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
JavaScriptSerializer serializer = new JavaScriptSerializer();
if (!String.IsNullOrEmpty(authTicket.UserData))
{
This is strange since this only happens using my domain name to access it.
I've found that when I use my custom domain (running under a SSL Certificate) the cookie size increase. I believe that this is related with certificate encryption.
To solve this I have to remove some parameters from cookie userdata to guarantee that it doesn't grow to more than 4096 bytes (Browser Cookie Limits: http://browsercookielimits.x64.me/)

NetUserGetInfo doesn't work for trusted domain

I am using following piece of code to fetch the current user. problem here is that network management APIs doesn't seem to work for trusted domain. I replaced the NetGetAnyDCName with DsGetDcName successfully. Now the problem is that NetUserGetInfo fails to retrieve the user info from a domain controller of a trusted domain.
Question - How do I get the user profile from the trusted domain ? Is there any substitute of NetUserGetInfo method similar to DsGetDcName ? I can't figure it out. Please help.
ns = NetGetAnyDCName(NULL, domain, &pDCName);
if (ns != NERR_Success)
{
if(fLog!=NULL)fprintf(fLog,PGPTXT_MACHINE8("Non-fatal error: NetGetAnyDCName failed: %d.\n"), ns);
pDCName = (LPBYTE) domain;
bFreeDCName = FALSE;
}
else
{
if(fLog!=NULL)fprintf(fLog,PGPTXT_MACHINE8("NetGetAnyDCName *%S*.\n"), (LPWSTR)pDCName);
}
if(fLog!=NULL)fprintf(fLog,PGPTXT_MACHINE8("NetUserGetInfo *%S* *%S*.\n"), (LPWSTR)pDCName,userName);
ns = NetUserGetInfo ((LPWSTR)pDCName, (LPWSTR)userName, 4, (LPBYTE*)&pui4);