Get gateway's IP address - c++

Let I've an URL, for instance http://www.google.com/. I want to know all of gateway's IP addresses for package's path. Is it possible to do? If yes, please give me a pointing.

When you are outside of a local network (for example you are outside of google local network) then there is no such a thing like gateway IP of an IP. If you mean a default gateway, then read this for more info.
As an outside host which needs to connect to google.com you just can convert that domain to an corresponding IP address. To do this, you can use gethostbyname.

Related

How can I see which IP address Google Cloud Function instance use?

I want to see the IP address of my google function instance. I've tried to look request object's headers but couldn't find anything useful. Is there any way to find it?
I am using python SDK but I don't think this is language dependent.
Cloud Functions do not have a public IP address assigned to the function.
Cloud Function egress traffic is routed to a proxy which then forwards the traffic to the public Internet. The only method to determine the current public IP address is to call a public endpoint which returns the public IP address of the frontend to Cloud Functions.
Here is an example endpoint: https://api64.ipify.org/?format=json
If you want to have a outbound static IP with Cloud Functions, you can achieve this by configuration. 3 important steps
Create a serverless VPC Connector and plug it to your Cloud Functions
Set the egress param to "ALL" to route ALL (private and public IPs) the request from the Cloud Functions
Configure a Cloud NAT and reserve IP(s) to use when you perform an external call. And you can use the John's answer to check if it works.
Just if someone needs this.
After doing the steps described by guillaume and exploring the link that also John suggested, I was able to get my cloud function's IP with the following python code:
from requests import get
ip = get('https://api.ipify.org').text
print(f'My public IP address is: {ip}')
In my case, I was looking to see if my cloud function had the same IP address as my NAT gateway since I need to put the IP in a whitelist and this helped me a lot!

How to verify the hostname obtained by resolving IP is the correct one

I am very much new to network programming and maybe I am asking a very basic question.
I am working on a legacy C++ codebase where the windows 'getnameinfo' API is used to obtain the hostname from the given IP address. The obtained hostname is wrong and it belongs to a different VM in the domain.
Let us say, there is VM with hostname 'VM1' with IP 10.44.176.57 and
another VM with hostname 'VM2' and IP 10.44.176.24.
When IP 10.44.176.57 is passed to the getnameinfo() API, it resolves it to the hostname VM2.
The ping command also returns the same results.
When I ping hostname VM1 and VM2 both resolves to their correct respective IP addresses.
I checked in DNS manager, the IPs of VMs are assigned correctly.
My question is,
1) Why getnameinfo API is returning the wrong hostname?
2) Is there any way to verify the resolved hostname is the correct one ?

Aerospike config to use DNS instead of private ip

I am trying to configure aerospike to work in AWS. The recommended settings are to use Hearbeat mode mesh. Now I'm trying to use DNS say trial.example.com instead of IP in
mesh-seed-address-port 192.168.1.100 3002 in this config but am unable to do so. The problem is the cluster visibility is shown False in AMC. Can someone please help?
(I work at Aerospike). Specifying a DNS entry instead of an IP address in the mesh-seed-address-port is currently not supported. So you will have to use an IP address (or a list of IP addresses). This is something that we may support at some point in the future.

How to find the WAN ip for a connected computer

I have been trying to get the IP of a person on my network, so I tried pinging them and finding their ip on my network site, but it didn't give me their WAN ip. Please help.
if the client is in your network you will probably stay in your LAN - therefore you will get the response from the private IP of course.
the WAN IP is only used when the client tries to access some IP on a public range.
one option is to ask the client to visit something like http://www.whatismyip.com/ and tell you the output or host a service yourself that is doing something similar.

how do i add DNS record for a web service running on 8080 port on AWS

I have a web service running on aws under the following URL http://"54.194.164.164:8080"/webapi and the instance is associated with an Elastic IP 54.194.164.164. Now i want to add a DNS record so that i can access this easily like htttp://demo.mydomain.com/webapi.
what i have done so far is, i have added an A record called demo.mudomain.com to 54.194.164.164 in the Godaddy DNS console but still i cant access demo.mydomain.com/webapi.
Can you please guide me what i have to do where i can access the web service easily as demo.mydomain.com/webapi
Thanks
saththiyan
You can't do this. DNS maps names to IP addresses but not ports.
If you are going to access HTTP at an address it has to be:
Bound to the default port (80) if you don't want to specify the port.
Specified in the URL if it is a different port.
If you are trying to do this for an "easier" address you'll have to use port 80. If that is used by something else you are stuck with nominating a specific port.
You could consider assigning another ip address and setting up an address like api.mydomain.com to point to it. That way you could use http://api.mydomain.com/webapi by binding the API to that address rather than http://demo.mydomain.com which you are presumably using for something else.