I worked on a simple app....which works by sending simple instructions to Arduino over my WiFi router, just like - 192.168.0.177/status or 192.168.0.177/currenttemp etc,while my phone is directly connected to the router.
What I am trying to achieve now,is to be able to send same instructions to Arduino(which is connected to router) over the 3G/2G data of my android(which is not directly connected to router).
I tried to research a bit,but its all is just fuzzing up things more & more....
(I m big nooooob).
So,what should I do to get that to happen?
is it--[PUBLIC IP of router]/status. I just cant understand.
Some port forwarding,router remote access,I do not know. Direction reqd.
++I dont know...how can i get this Public IP,,it quite keeps on changing & if so,,,how to set up.?.? :-(
So this seems like a question of 2 parts - but overall you're going to have to become familiar with your routers status page. It should allow you to do port forwarding (which you will have to do) and may help with your IP changing.
Finding your Router Status Page
Your router status page is usually available from one of these two urls:
http://192.168.0.1
http://192.168.1.1
Hopefully one of these will take you to a web page, where you can configure things- if neither do then you're going to have to find out what the right address is - this should be the same as your default gateway so you can follow these instructions: https://wiki.amahi.org/index.php/Find_Your_Gateway_IP
Port Forwarding
Simply put, for home internet connections you're probably going to use Port Forwarding whenever a device that's not on your network (in this case your phone) initiates a connection to a device that is on your network (your arduino).
This is because when your phone connects it will do so to an internet IP address rather than a local IP address and the internet IP can't specify which device within a local network you want to talk to. If your Arduino were to make the connection you wouldn't need to port forward on your home network.
Within your Router Status page you should find configuration options for port forwarding, without knowing your router I can't say much about where you'll find them but they're usually obvious - once there typically you can pick a port or range of ports you want to forward and which IP address you want to forward them too. Judging by your question the port you want is 80, the default one for web browsing - the IP address you want is the internal IP of the Arduino which seems to be 192.168.0.177.
Once you save that you should be able to make connections to your Arduino from off your network but you've still got your IP issue left.
Dynamic IPs
You're quite right you'll need your public IP to connect, this can easily be found from within your network by going to a site like https://www.whatismyip.com
However as you've mentioned, your IP changes quite a lot, so if you don't want to keep looking it up you've only got a couple of choices:
Pay for a static IP from your internet service provider (if they offer this)
Use a dynamic DNS updating service
Probably the most well known amongst those services is DynDNS though there are free alternatives, it's worth remembering that you may be getting what you pay for and I'd perhaps look for recommendations from other StackOverflow users on which to use.
In terms of the actual updating you have two options, the easier one is to install a client on a supported computer which will periodically update your IP. Alternatively, some more sophisticated routers have Dynamic DNS updating built in and this would also be accessible by your router status page, which you're hopefully already a pro at rooting around in.
yes you need public ip of your router as your both device is not in the same network.
Related
I'm not sure if this is possible, I'm trying to redirect traffic from a mobile app that is connected to the internet through a hotspot wifi from my laptop. The app is Sending requests to a cloud server, and the idea is that the traffic should first go through a proxy that is listening to a local port in my laptop, as per this rough sketch:
I believe this could maybe be solved using iptables, but I'm using Windows, I've looked into netsh but so far I haven't found a command (such as portproxy) that suits my needs, partly because I don't know if this is possible at all. I'm purposefully being a bit general here but if there's any questions we can go more in-depth.
Can someone give me a hint here?
Im currently developing a number of online applications with mobile friendly interfaces and would like to test them on my mobile device without having to upload (having problems with my internet connection)
Ive researched and seen there's a way it can be done with static IPs but since my internet connection requires an automatically assigned IP. Can this procedure also be done with a dynamic IP
My nachine and device specs are
Windows 10 64bit
Android 4.4.2
Xampp/Apache
Thanks in advance
There are two ways of achieving this
1) Server behind router
In this approach, you simply use your home/work Wi-Fi to connect to the server, hooked in to the same network. Later on, buy a domain/sub-domain and publish there.
2) Server beyond router
This will require some hacking in most cases. There are websites out there that provide dynamic DNS options. Almost all after-market router firmwares will support registering on to (many of) such websites. And then do port-forwarding to the server behind the router. In essence, you're asking for someone on the outside, to redirect traffic to (your) server, which is on the inside(behind the router).
I followed a chat app tutorial that connects devices using TCP sockets.
For simplicity, I split the app into 2, so that one is the server and the other is the client.
The app works fine when I am using the same wifi network, but it does not when one of my devices jumps into a different network.
This is where I get confused on the concepts.
Because they are different networks, I cannot use the local IP as I have been doing. I did find using the public IP is possible, but I'm still new to coding so am not sure if that's the right method. Should I look into VPS? Or GCM?
Do I need to rewrite my app such that I have 2 clients (that talk to each other) and that they go through the server with a static IP (like a middle man)? But then I get confused because in that case, Client would start first and then talk to Server. But I always thought Server was to start first and wait for an accepting socket??
Not sure if this is the right place to ask these questions, I'm just really confused on the concepts. Thanks!
For socket programming in your apps, the only info you need is IP address and port number. After switching to another network, the only modification to your source code is IP address.
When devices are not in the same local area network, you need routers to locate each other, in theory. If you don't own control to routers, using a public and static IP is the right solution. The app acting as a server should have this static IP and should always be alive, and listen to connections. The app acting as a client starts later and connects to the server with its IP address and the port number you've defined.
Normally when you get access to Internet, you get a public IP from your ISP, and it keeps static if you keep online, in most cases. So just find out the IP address on your server, and connect to this IP address from your client app. If your internet access is gained from a wireless router, you should set up port forwarding on the router, and use the IP address of this router at client.
I'm aware it's been asked before (with limited or no solution) but I haven't seen any recent updates and I think my scenario is unique so I'll start a new thread.
I have a Raspberry Pi and it's functioning as a hot spot among other things. By design, DHCP isn't handing out a default gateway. My use case is one or more devices interacting with the Pi as a server.
One of the connected devices will be a mobile device(edit: running a custom app of my design which is part of the total solution), and that device will maintain its cellular connection, not for tethering or routing but so that the application can access internal and external resources simultaneously.
Currently:
IOS: This works exactly as I expect on IOS - it senses that the WiFi network doesn't have a default gateway and sends external traffic over cell.
Android: This doesn't work at all. Android stubbornly sees WiFi connected and disables cellular, even with no default gateway.
Windows Phone: Kind of a hybrid. Both networks stay up but my scenario has a DNS entry in public DNS, and a public site links to a resource on the Pi. If I link to the resource directly using the WiFi IP address of the Pi, it works fine (although this causes other issues related to security). If I link via a FQDN, I'm actually not sure what's going on. It doesn't resolve from the web browser although every networking utility I've installed on the phone for troubleshooting correctly resolves the FQDN to the Pi address via DNS.
Hope this makes sense. The question: How can I enable this functionality across the board in 2015? :) For my purposes, the Pi as a private nonroutable hotspot works better than WiFi direct or Bluetooth. And remember I'm not asking the phone to ROUTE; I need my custom application to be able to simultaneously connect to the Pi and to the public Internet. I want all the phones to do what IOS does in this regard.
My current scenario is the Pi hosting a web page (among other things) and that's my preference, but can this even be solved natively?
You say that this is not a tethering or routing situation, but if you think about it, it really is both.
It is routing because the traffic from the phone needs to be routed to one of the two interfaces. There may not be routing through the phone, but it's still a routing problem. Fortunately, it seems that the routing part is working on all three platforms.
It is also an unusual form of tethering. The only differences are that traffic does not originate from the Pi, but from the phone, and that the Pi rather than the phone acts as the access point.
Thinking of it in terms of tethering is important because it shows that the Android CAN have WiFi and cellular active at the same time (at least in hotspot mode, but probably also in client mode). In this respect, my answer isn't complete - I can't tell you HOW to accomplish that.
As for the Windows phone problem you mentioned: in order to troubleshoot that, first identify where the DNS server is located that knows about the Pi's FQDN. Does a public DNS server know about it, even though it is obviously on a private network?
There are two possible explanations for your observation:
There is no public DNS server that even knows this FQDN. In that case, IOS is probably using something like mDNS to locate the Raspberry Pi.
There is a public DNS server that knows this FQDN. In that case, maybe Windows Phone checks the DNS reply for martians and rejects it, thinking that it is an attack.
Either way, what you'd really need is to have two separate DNS infrastructures. One way to do this is to include a small DNS server (dnsmasq maybe) with your app, and configure a forwarder for the zone with the Pi's FQDN to forward to the Pi's IP address (which would have to be hardcoded, obviously). All other requests should go to the normal DNS servers.
Another way might be to not use DNS at all, but use the hosts file instead.
For Android phone you can use application named "WiFi & Mobile Data Switch" (https://play.google.com/store/apps/details?id=com.totemsoft.wifimd). For me it solves the problem of simultaneous connecting to internet (via mobile data) and to local network (via WiFi, internet is inaccessible via WiFi). This applications works ok on Samsung Galaxy A8. I hope, my comment helps to somebody.
I want to know about all the device that are connected to the dhcp server.
I have the IP of the device it may be a android phone or printer but I think dhcp is having the information of this devices.
I got something like the "vendor information " in the dhcp protocol stack.
My doubt is I have to identify at least a android phone is on the network ,
Is it possible by this.or how to Identify a android phone is one the network.I have the IP of the android also but I am not getting any information from any way.
I got something like nmap but this tool is not giving a perticular details of the phone.The information provided by the nmap is confusing I am not able to identify whether it is a phone or a linux system as both the system having linux as the os.
Then i got this dhcp -vendor information : but I don't have any idea about how to read these data..
kindly give any suggestion.....Needed for my project.
Thanks
The problem you will have is that modern day switches will stop you sniffing traffic destined for specific MAC addresses so if its hard-wired then you are going to run into trouble. If on the other-hand its a unsecured WiFi connection, or a network with hubs (rare now!) rather than switches then you may have a chance.
You'd need to switch the ethernet controller into promiscuous mode and listen for the DHCP REQUEST and DHCP OFFER commands, inspect the contents and see whats going on.
Another method would be to listen for ARP and RARP requests on the network and use a hardware lookup table for the MAC id to determine who makes the chip-sets, its not going to give you awesome accuracy since a lot of chips are re-used on different devices but it may give you a little bit more info.
In terms of the DHCPd server, unless you have access to that physical machine I'm afraid your probably out of luck, DHCP is a designed as a offering protocol, not a querying protocol.