How to get Mac Address from WAN IP? - c++

I'm using SendARP() to get mac address form an IP.
But this function only work correctly with LAN IP.
If I have many devices in other LAN network, they will have the same WAN IP (ex: 219.123.111.90), but their ports are different.
So if I call the function SendARP("219.123.111.90:80") or SendARP("219.123.111.90:81")..., it will return only one Mac Address.
I think the SendARP only get the Mac Address of the Modem without getting real devices on that LAN network.
Please show me how to get the real mac address of devices that belong to other LAN network?
Many thanks,
T&T

Related

How to get IP adress with WINSOCK ? c++

I'm not familiar with networks and etc so I dont get how to use it, so if anyone can help me how to get ip adress of my computer with it and I also have to get MAC adress too.
WinSock is a Windows-specific API. Most socket APIs in general do not provide information about local IP/MAC addresses. You might be able to use getaddrinfo() to query the IP addresses for localhost, but that would be implementation-specific whether it works or not, and it would not include MAC addresses anyway.
On Windows, the correct way to get the IP and MAC addresses for the local machine is to use GetAdaptersInfo() or GetAdaptersAddresses() to enumerate the local NICs.
On POSIX-based platforms, including OSX, you can use getifaddrs() to get the local IP addresses (family AF_INET/6) and MAC addresses (family AF_LINK).

How could I convert from IP address to MAC address

I want to store all the MAC the mac address which has access to my server.
All I know are only the IP addresses. All the machines are under unique gateway.
Could I got the MAC address from their IP address?
MAC addresses are not part of any protocol that gets routed, you will never get the MAC address of a machine that is on the other side of a router or switch.
They are are the addresses of the physical ports, not of machines (which are what you're taling to using IP).
If server and client are on the same network, you will have to use ARP. This protocol is designed to get the MAC address to a given IP address.
As soon as there is something like a router between client and server, ARP will only reveal the MAC address of the router since this is the target for your ethernet packets.
Simple answer is, no You Cannot get MAC Address from an IP Address for clients connecting to your server unless both the machines are on same Physical network
It is not possible to get MAC address from IP address. MAC address is a physical address of network device, and IP address is not.
IP address is not bound to one device in general.
I suggest you go through this
the post says
An IP address is usually assigned by the network administrator or internet
service provider, you are either provided a static one at the beginning or
given a dynamic one every time you connect to the network.
This is not true with MAC addresses as it is already embedded on the device
or the network card during manufacturing. It is supposed to be permanent and could
not be changed by anyone as it was meant to identify a specific network interface
card no matter where it is in the world.
There are however ways to change mac addess, but i don't think it is possible to get mac address using IP- Address

How to connect from a VMware guest machine to the server installed on a Windows 7 host machine?

How to connect from a VMware guest (virtual) machine to the server installed on the host (physical) machine? Things like typing "localhost" in the address bar of a browser in a guest machine don't work. My host machine's OS is Windows 7 64 bit with WMware Workstation installed on it, if it matters.
EDIT: The Bridged network connection in combination with referring to 192.168.0.10* from the guest machine did work (replace * with a digit starting from 0 until it works).
If you use "Bridged" Network Connection (see Virtual Machine Settings: Network Adapter), your VM will be given an IP address on the same LAN as your host machine. At that point, you can just HTTP to your host's IP address, eg. http://192.168.0.100
You can also do that with the other options, but with NAT and Host-only (if I recall correctly) your host machine will appear to your guest machine to have a different IP address than its real LAN address. So Bridged is the easiest and is likely your best bet, unless you have some specific needs.
First thing to do: Check that you have the network up and running. Try to ping the host system or any web site from the console of the guest OS, let's say ping www.google.com.
If you received any answers then please try writing the IP number of the host machine in the addressbar of the browser on the guest machine (NOT localhost :P). You should be able to see any web service running (Tip: Open the console of your windows 7 and type ipconfig, then find the ethernet adapter corresponding to VMWare and you'll find the IP number of your host system).
If you didn't received any answer at all when you did ping then check the network configuration of VMWare to use Bridged Connection --at least that's how it works for me.
Good luck!
In a guest machine, localhost refers to the virtual machine itself. Refer to the host just as you would from any other machine: by its IP address.
Note that it may be using a second "virtual" network adapter to communicate with the guest. Check the VMware to find out, and to find the second IP address.
Just use the same IP sub net for your VMware machine, if your windows system has ip address class C 192.168.0.10 So assign 192.168.0.120 IP to your Vmware machine and make sure that Firewall allow the traffic in vmware and also add the listener port manually in vm machine. go to system - administration- firwal-add port 1521.
Thanks

Detecting IP addresses of network cards and ethernet devices with Windows API

I am using the Microsoft code here to learn how to detect IP addresses of cards and devices:
http://msdn.microsoft.com/en-us/library/aa365949%28v=VS.85%29.aspx
I notice some strange behavior.
I have a system with two ethernet cards; one is connected to the internet and one is connected to an ethernet device. When I run the sample code, it will always give an IP address for the card that has the internet connection, but the other card will come up as 127.0.0.1 with a subnet mask of 255.0.0.0 unless I have the ethernet device plugged in and powered. But the card should have a default IP address whether its actually connected to anything, right? How can I modify this code to detect that?
There's a third IP address detected that appears to be just empty data. I tried this on another computer with a single network connection and it also detected a second, non-existent connection. Each time, this connection has an IP address of 127.0.0.1 and a subnet mask of 255.0.0.0. What does this represent?
Given the demo code, would this be easy to edit to be able to detect IP addresses of devices on the network that any card is connected to? I really just want to detect the IP address that a single ethernet device is set to. The device is directly connected to the card. The reason I want to do this is because the device and card obviously don't play nice when their subnets are different and I want to detect when this is the case.
Thanks!
R
That address of 127.0.0.1 is not the address of the other card. It is the address of the loopback adapter - a virtual IP address that can only send and receive data with itself. The other NIC (that isn't plugged into a network) is simply not in the address table.
You may just want to call GetAdapterAddresses and filter out all adapters with an IFType of IF_TYPE_SOFTWARE_LOOPBACK.
If you want to see use existing tools that provide the same thing, type either of the following from a command prompt:
route print
(This will dump the routing table)
ipconfig /all
(this will show you the state of ALL adapters including the loopback)
Dunno exactly, you should at least specify your configuration, is it DHCP or static IP, or something else?
It's the loopback interface
Some broadcasting may be required. ARP is the link-layer protocol, so it can be used without the IP address to broadcast a link to find the devices and then to detect their address. Don't know about windows precisely, but on Unix an arping command is present for this.

A Reliable way to Identify a computer by its ip address

I have a network of computers that they will connect to the a server with DHCP, so I don't know what Ip address a computer will get when I connects to the server. If 192.168.0.39 for example is connected to the server can I identify the real computer behinde this ip address? ( I can install an external application on each client in order to send some data to server for example mac address or so... )
If you are responsible for the DHCP server, you can configure it to hand out a specific IP to a specific MAC. Having done that, you can be reasonably confident of that mapping -- it is possible to spoof MACs, so if you are worried about security, you'll need a much more heavy duty approach. If this is a casual application where the risk of that is low, you configure your DHCP server to hand out IPs based on MACs and then make use of those mappings in your application.
You might not even need the IP address. On an Ethernet network, all communication from a computer, whether it's IPv4, IPv6, or even IPX will be labelled with a MAC address that's stable over time and unique per network card.