Find the IP of an internet host using its MAC adress only - network-programming

I would like to avoid VPN for permanent connection to a remote host, I would like to replace the static IP address with the MAC address, and using the MAC to find the IP.

You can't. The MAC is used for local routing, not global routing. A MAC on a remote network is hidden by a gateway on the remote side. You can't even tell which gateway is doing that. It's even possible that the IP address doesn't have a MAC address behind it. This was the case for instance with dial-up lines; there would be a phone number behind it.
This explains why there's no API for this.

Related

How do i find the ip address of a server in a homegroup

I have a number of devices connected to a server. When it restarts the ip address might change. How would the remaining devices find the new address?
I want to automate the process since I want to distribute the software and there won't be any network administrator.
I found solutions like configuring a DHCP server or manually configuring the router, but it won't possible to manually configure the routers of the devices that would use the software.
What you could do is following :-
Assign static IP-Address to the server; it could be done by adding a reservation for server's IP-Address based on the MAC address of the server in the router. Check your router manual for how to add IP-Address reservation for a designated MAC-Address.
Once server has got a static IP-Address, your work would be so easy to achieve. You either need to ensure that the clients make an entry of the server's hostname and the corresponding static IP into the client's host name OR if you've an adhoc connection(WiFi/Bluetooth), it would do that automatically without your intervention.
That's it, you have a static IP-Address for your server and you have mapping of server's IP-Address and hostname into each client's etc/hosts file(not needed for adhoc connections as explained above).

Can't connect to local rails API from iOS native app

I have an iOS native app.
I have an API developed in Rails (4.1.4), which lives at : http://api.myapp.local:5000.
I have configured my /etc/hosts to do my basic API / web development, no problem everything work perfectly.
My problem is that I want to consume my local API through my iOS app (in an actual device, not in simulator) over WiFi.
Here's what I've tested (that does not work)
Using xip.io with my local en0 inet ip with thin webserver.
Using xip.io with my local en0 inet ip with pow webserver.
I've done some port forwarding to connect via my public IP
The problem is essentially due to the subdomain, indeed: all above solutions work if my app doesn't have any subdomain. (I can reach my local API this way, but this is not what I want)
My issue is that I can't tell my iOS app, "connect to this IP, using this subdomain"
I probably have a lack of knowledge in term of network, but I'm really annoyed by this problem, since I really need to test my local webserver with my iOS app.
Here is what my routes file looks like:
constraints subdomain: 'api', format: 'json' do
scope module: :api do
scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do
resources :packs, only: [:index, :show]
end
end
end
In order to access your local API server, you need to connect to the "local" IP address (or hostname) of the computer running the API on the same network. So if the computer and the iPhone are on the same WiFi network, they will be able to communicate.
To get your local IP address, you can use ifconfig:
$ ifconfig en0 | grep "inet "
inet 10.0.0.14 netmask 0xffffff00 broadcast 10.0.0.255
In this case, my local IP is 10.0.0.14. Now your iOS app can make an HTTP request to http://10.0.0.14:5000. However, I find it easier to use hostname:
$ hostname
Andrews-MacBook-Pro.local
Now your iOS app can make an HTTP request to http://Andrews-MacBook-Pro.local:5000.
However, since your Rails app routes the API requests based on an API subdomain, you won't be able to use the IP address alone.
One option is to specify the host as an HTTP header when your iOS App makes the request. Here's an example using curl:
curl -H "Host: api.myapp.local" http://10.0.0.1:5000
However, depending on how you've implemented your API requests throughout your codebase, it may be a lot of work to specify this HTTP header everywhere. If you can't do that, then your only other option, since you can't modify the iPhone's "/etc/hosts" file, is to create a publicly accessible domain which points to this local IP address. Here's what you need to do:
Register your domain. Something like benjiox-dev.com
Configure your domain's DNS with an "api" subdomain with either:
an A record that points to the local IP address of your computer.
a CNAME record that points to the local hostname of your computer.
Configure you iOS App to use your new domain http://api.benjiox-dev.com:5000
Note that your IP address may change on your internal network, so you may have to update your A record when it changes.
Since you're testing on a device, you do not have any networking access to your computer, which is hosting the server.
You may use an application like Charles to setup a proxy. There is WireShark as well. Upon setting either up, you would point your device to your computer via wifi settings on the phone.
Both options take some time & basic networking understanding to setup.
Sooo...
You're alternative to that would be to test from the iOS simulator. I highly advise this route because this requires no setup, just point your requests to http://api.myapp.local:5000 & you're good to go.
The last option you have would be to setup a "staging" server and point your requests to that domain and then compile the app to the device.

How to get local ip address from ios device in asp.net c#?

Can i get a local ipaddress of ios device from asp.net? I want to get a ios device ip address and want to store into database.
You can obtain the IP addresss using ifaddrs. Full example e.g. here: iPhone/iPad/OSX: How to get my IP address programmatically?
And than you can use web service (asmx or WCF) to send the IP address to your ASP.NET based service. An example e.g. here:
http://highoncoding.com/Articles/809_Consuming__NET_Web_Services_in_an_iOS_Application.aspx
UDPATE:
Based on your clarification, this is what you might need:
Request.ServerVariables["REMOTE_ADDR"], //the address, but if you are behind e.g. badly configured load balancer the IP will be not of the origin of the request
Request.ServerVariables["HTTP_X_FORWARDED_FOR"] //if you are behind proxy or load balancer, this is where the original IP address should be

Blackberry Push notification : Java.io.IOException:Network operation(Subscribe)failed. Make sure that Content Provider Url is accessible

I am working on blackberry Push Notification and facing a big issue while registering from the device. I'm getting the Exception:
Java.io.IOException:Network operation(Subscribe)failed. Make sure that Content Provider Url is accessible..
I go through this guide and set up all things according to it.
However I am unable to register. My tomcat server is running and I can access content provider URL from my computer and the same from device's browser.
PC URL is: https:/loaclhost:8443/sample-push-initiator
I changed local host to IP address of my Computer. and can access it over WiFi.
Please help me regarding this.
Your push initiator URL must be publicly accessible from the internet to be accessible from your device. Using localhost or any local IP address (e.g. 192.168.0.2) won't work.
You'll have to set up your router to forward traffic on port 8443 to your PC's local IP.
You should ensure that this URL is accessible from your blackberry normal web browser (not the hotspot browser) before trying with the sample push app.

Developing Client server application using INDY

I am currently developing a client server app , but i want to clarify some information about the following.
What must be my idtcpserver binding IP adress (127.0.0.1 ,192.168.1.1 or my public IP)
I checked it using IPconfig it replied me 192.168.1.1 ;but i have connected to the internet using my home adsl router(single port).
I have assigned my client application with
idtcpclient.host := my public IP address
the application is working well when i assign both with 127.0.0.1 // as both are in the local machine
How to make my application work over the internet.When i try to connect over the internet the client is replying me
Socket error #10061 connection refused.
but my kaspersky network monitor is showing that my port is opened my myapplication (I set it to 6000)
original project
sourceforge
You don't need to create a binding on the server machine. Just assign the default port. At run time, a single binding will be created with that port and a blank IP address.
When you connect to your network from the outside using the external IP address, you are actually connecting to your router (or other hardware). You should be able to tell your router that traffic received on a specific port will be directed to an internal IP address.
I have a handful of servers running on my internal network, and this is how I make them available from the Internet.
You mention that you have a DLink router. If it works the same as mine:
Using your favourite web browser, open the router's settings page.
I think the default address is http://192.168.0.1. User name is "admin" with no password.
Click the Advanced tab and select Virtual Server.
The virtual server settings are pretty straight forward.

Resources