Reverse lookup in Ruby (preferably with Dnsruby) - ruby-on-rails

Using Dnsruby, which is great, but how do I do a reverse lookup for the hostname associated with an IP address? Or if not dnsruby, other suggested routes?
Here is what I am working with so far, and I figured that my query would have the resolved name also, but its not apparent to me.
resolver = Resolver.new
query = resolver.query("example.com")
ip = query.answer.first.address.to_s
As for more background, I am basically using this in a monitoring app, and with apps on Amazon EC2, and I'd like to see what the IP we've been assigned resolves to. I am hoping I can then use that to further assess potential its location etc.

Socket class can be used for looking up host name based on address.
See this answer for an example.

Related

How to set private IP address name to a generic name to show to user?

I have a rails app that is running on heroku server.
According to my knowledge, Ip addresses are managed by heroku itself but when I have scanned through Probely vulnerability scanner, it gave me Private IP addresses disclosed. Even I have not displayed my ips to any view.
Well after some analysis, I came to that point that Remote_addr: 127.0.x.x kind of ip address is showing in the rails error screen and scanner is pointing out for this.
It also suggested that to fix this issue give a generic name to the ip address so it will be displayed over there instead of its actual value.
But I don't know how to do this on my server or app. How can I give a name to my private ip address???
You can't control much on the Heroku apps.
Anyway, 127.x.x.x is localhost... regardless of what the X's are.
What is suggested is to use the etc/hosts to provide a name and don't access the host directly through IP, in case the IP changes. (not available for Heroku afaik)

Realmlist - IP works but domain doesn't

I'm struggling to get my AzerothCore Docker instance to allow logins via the internet when using a domain instead of an IP address. My ISP only offers dynamic IPs so I'm using dynu for simplicity.
If Realmlist set to domain in acore_auth.realmlist I can connect over LAN but external connections get stuck at realm select screen. However if I change the realmlist to just my external IP it works for both so doesn't look like a firewall issue.
The domain is working with webserver hosted on the same machine so that can't be the issue. Any ideas?
I don't know exactly the reason why this fixed it, but I tweaked some of my pfSense settings for DNS resolution (removing my domain from the overrides) to get it going. Hopefully this might be useful to someone else!

Are there changes in Workbench connecting to Google Cloud MySql?

I have seen some similar posts, but this one is intriguing me a lot. I moved from the Pacific area (with my instance in USA Central) to Finland. I have been able to connect to the MySql database with WorkBench without any issue before (with whitelisted IP address). Since the move to northern Europe, I have not been able to connect to the DB at all, with no changes to my local setup.
I thought that it may be a time-out issue, but I have just created an instance in the Europe-North region, and the same problem exists.
I have also switched from my company's WiFi (and IP) to a mobile based IP address (I have been able to use both in the past in the Pacific area).
My only remaining (illogical) thought is that is a local firewall issue, but I am not sure and do not know how to fix that.
I am scratching my head - anyone with an answer?
The error messages looks like this (similar to other posts, but with no similar solutions!)
If you have moved locations, you likely have changed IP addresses as well. Make sure that you have authorized your network's current IP, and that your firewall is open to your instances public IP on port 3306.
You can also look into using the Cloud SQL proxy, which doesn't require authorizing an IP address.

Find public IP address of the session user in Grails

I want to request the remote address of the session user in grails. I found a question here which describes the problem (Grails find public IP address of the session user) and the answer really works. I use only request.getRemoteAddr() and I receive 0:0:0:0:0:0:0:1 in my localhost.However, what I have to do to see the real IP address of the user?
In this previous question which I have found it is said "Try looking at the output of request.remoteAddr when viewing the site from a different computer". I really don't know what this means and I need your help here. I can load the server only in my own browser and I use "localhost:8080/..."
Please,tell me how and where to get the correct request. Thanks!!!
"Try looking at the output of request.remoteAddr when viewing the site
from a different computer"
means that you will need to connect to the application running on your machine from another machine in your LAN.
If you have another machine in your LAN, you will need to find your local network IP address (use ipconfig) and from the other machine connect to this address. For example if your IP is 192.168.0.2, connect to http://192.168.0.2:8080
As tim_yates mentioned request.getRemoteAddr() may not always return the correct address due to dynamic addressing and proxy servers. However you may find the original address from various HTTP headers such as: HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, HTTP_X_FORWARDED
Take a look at the answers to this question which provides more information about this subject.
That's the best you're going to get.
0:0:0:0:0:0:0:1
Is your local address. Also, this cannot be guaranteed to be unique to a user due to dynamic addressing and proxy servers

Can I set a url to my EC2 instance instead of the IP?

I am working on an AWS EC2 instance, I installed an apache server.
Is it possible to set a url to my server?
I would like to write on my browser:
http://myServiceWebSite
instead of
http://23.26.31.178
Can I hide the ip of my server by a face name?
Thank you.
You can set a DNS using a domain registrar such as Go Daddy
You can use FREE domain names such as co.nr though I think that 13$ a year for a .com is a descent price.
As ajay wrote, Amazon Does provide a default DNS but it is "ugly" and you will probably not use it.
By default, every time you restart a machine it will probably assign a different IP address, and the DNS name is ugly because it is based on IP, and it is released on instance shutdown.
If your server is used by the public internet you might have at least 3 choices:
Make the IP address static by using Elastic IP option from EC2 console and register this IP using some DNS Service such as Go Daddy.
Leave your IP assigned dynamically and use a dynamic DNS service such as DynDns.
If need to use an Elastic Load Balancer use the AWS Route 53 DNS Service, and instead of creating an A Resource Record pointing to a static IP address, you could use an Alias Resource Record pointing to your Elastic Load Balancer, I think this would be the best option if you have more than 1 server.
If you want a quick and dirty solution, you could use a url shortener and use the url it generates from your default AWS DNS. This is not a long term solution, but just something to use if, for example, you want to deploy a prototype quickly and display it for someone temporarily without handing them an IP address.

Resources