I'm developing a new android application in which i'm using ip webcam.when user clicks on a button ip web cam will open and it will trigger another phones application where i can watch the video of ip web cam. My problem is i'm getting the video only when i'm in the same network.If i changed to some other network it is not showing.I've searched for the solutions in the internet and i found about port forwarding.I tried that one by like this. If my local ip web cam address is nothing but devices ip address 192.168.1.15, and i'm using the port is 8080,so when i tried to connect with url "192.168.1.15:8080", from same network it is showing, from other network it is not showing.I'm using wireless network and Router is linksys, i opened my router's webpage and in "Application & Gaming ", i set "single port forwarding" by giving the application name, and ip address of the device(192.168.1.15), and port number 8080, and i enabled it.After saving, it is showing settings are successful. but i'm not getting the video.And i tried to check whether port is opened or not by using some port checking websites like "http://www.yougetsignal.com/", but it is always showing that port is closed. I checked some other networking sites saying that try with static ip address of router. I found my router's static (public) ip address by "whatismyip.com", and i tried with that one like "44.126.233.56:8080",still it is not showing the video. I tried with changing of ports like "6564" and "11100", still i'm not getting.So anybody please Help me to get this.
I hope I can help you here or at least point to some idea.
Your router defines the boundaries of the internet at your house by using an assigned IP (from your ISP) and using an internal IP address for the local network. The internal network IP address is intended to be in a range that the router would not "leak" to the outside - only indirectly by using something that is called NAT - network address translation. The problem that I am having with your question is that if your configuration is set for modem + Linksys and both are capable of processing NAT it will not work (NAT then NAT), your modem should be set for bridge mode and then use the NAT on the Linksys and configure the port triggering or forward as your device would function as game console. Hope this helps.
Thank you
Related
I wish to change the Ethernet IP Address of the Raspberry Pi3 board that is running Android Things OS. Currently it automatically fetches an IP Address available in the connected network. But I wish to assign a fixed/static IP to the device. Is it possible to set a static IP using ADB?
I don't know the solution based on Android-things.
But I usually try to prevent the use of fixed IP (unless the device runs forever) set in the device itself.
I prefer to use the DHCP of the modem to set the IP based on the MAC adress. This prevent some conflict.
You can see more information on this post
You can set a static IP usually through your router settings. Try accessing your router settings usually through the web browser at:
http://192.168.0.1/
Assuming you have never accessed this the username is usually admin, and the password is password. You can check the router name online to find the default username and password.
Navigate the menus to find a page which shows you he connected devices. See pic for an example.
Every routers interface is different.
If you have a setting that says DHCP see if you can change it to a reserved IP so that the IP address assigned doesn't change.
Remember different routers have different interfaces so you must do some searching about yours to find the setting.
You can do this from any computer connected to your internet, doesn't have to be on the raspberry to make the changes.
volley is not working when i want to fetch data from a system on my local network.
where URL is like http://192.168.x.x/data.php
it works well on emulator but not on a real device. it show a time our error.
even i tried setting a maximum time our and retry policy. but in vain.
There are two ways to solve this:
a) keep your device connected to the PC which is connected to your local network either using lan or wifi. Keep debugging mode on. Use ipconfig to check your pcs ipv4 address and use that.
forward your server's port on your router and then use the ipv4 address found on your pc's ipconfig command.
c) Best option-> i use this. Forward your pc's server port on your router, Go to your router's DHCP configurations and give your pc mac a preferred DHCP ip to make sure your router always gives that local ip to your pc(global will still be dynamic if you dont have a static ip). Register to a DDNS and use the set ip above and you will be able to access your web service from anywhere in the world. (i use dynudns for the ddns part)
see How can I access my localhost from my Android device? for other ideas
In the first two steps, make sure that the mobile is connected via wifi so that the router can forward it requests. in third, it can be connected to the internet anyway it likes. Also in the first, you will have to change the url everytime your local ip changes.
In second option, the dns will give a tool for auto ip updation :)
Disclaimer: I don't know this is the actual problem, I just suspect it is.
I have set up an Amazon Web Services EC2 instance as a remote git server. I have had to configure it to only accept incoming traffic from a single IP address though I had wanted to make it open to all because I will be using it while I travel.
The complication here is that mobile phones cannot have a static IP address and I will be accessing the server using my android phone tethered to my laptop. This means I have to make a new rule to accept traffic from my current IP address before connecting to the server via ssh.
When setting this rule there is an option to use "My IP Address". Amazon automagically checks my current IP address and sets it in the rule. It looks like 123.123.123.123/32. The "/32" part there being the actual end of the address.
When testing the server from home I have no problem accessing the server from my desktop computer over the home network with static IP. Equally no problem accessing the server from my laptop computer over the home network. I then tethered my phone to my laptop and tried to access the server via the cellular network with the home static IP address rule still in place. As expected the connection was not made because the phone is allocated a different IP address.
BUT...then I go out for a day of coding in a nice location and try to connect to the server and it does not work. I went in to my EC2 console and set a new rule to accept traffic from my current IP address over my tethered phone using the automagic "My IP Address" setting. Then tried to connect to the server via ssh. No joy.
The connection is not made. Just times out in the same way it did when I originally tested trying to access from an IP address not specified in the rule.
So I was thinking it has something to do with ports. Is that what the "/32" above is? Or have I got that all out of whack?
What can I do to gather more information to help define what the actual problem here is?
I had this same problem connecting to a Postgres database in AWS. Here is what I did to solve it:
I opened up the server to everyone 0.0.0.0/0
I went into the server and determined my actual ip address that it was trying to connet with.
Went back and fixed my rule with that IP address.
My automatically populated IP address was different than the actual one.
Find an Android VPN provider that will sell you a static IP for every use. That might be a way to use a static IP as a security measure. If the VPN provider offers the service on PC as well you can set both to the same IP. Your really ambitious you could set up a VPN service on your virtual machine and then configure it to only except connections from it's self via SSH. You would have to Adjust your "security group" to except VPS connects from any where. The second method would mean that you wouldn't need two static addresses for and added layer of security.
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.
I'm writing an Android Kiosk application for a closed business environment. My devices are connecting over Ethernet to a local web server to show webpages.
Now the problem I have is, that in the night, the server will be switched off, and if that happens, my DHCP server is off too. If my Android starts up in this situation, it won't get an IP address. My Kiosk application tries to connect to the server all the time (At this point I don't care if it does, when it's in a Power saving mode or not).
To make it more complicated, it's not just one site, my app will run on, so using static IP addresses for the server won't work. I managed to get a DHCP and DNS server, where I can define my server host name, which will be the same at all sites.
BUT, Android has a bug resolving not fully qualified domain names (Link), so my application can't directly connect to the host name (e.g. http://hostname/index.html), but has to resolve the IP address of the hostname manually and then connecting to that IP address. As the only solution I could find was dnsjava (Link), I used that to resolve the IP.
import org.xbill.DNS.*;
InetAddress addr = Address.getByName("hostname");
ipAddress = addr.getHostAddress();
This actually works, BUT here's the thing:
If Android and my starts up with no IP, it of course can't resolve the hostname. However if my DHCP/DNS server starts up, the device won't get an IP address unless I tell him to do so:
runShellCommand("killall dhcpcd");
runShellCommand("ifconfig eth0 192.168.99.99");
runShellCommand("ifconfig eth0 0.0.0.0");
runShellCommand("dhcpcd eth0");
runShellCommand will ... run a shell command and actually works well.
Anyway, this will get a new IP address from the DHCP (proven by the Log files of the DHCP server), but the hostname will not be resolved.
Restarting the app won't work, even using another app for testing (Ping & DNS) won't work.
The only way it works is when in Settings->Ethernet I unclick DHCP and click it again. Somehow this flushes the DNS cache?! But how to do that programmatically?
BTW: I tested to start my App and Android when the DHCP/DNS server is online, it will connect and work and when I switch off the server, my Android always answers DNS lookups with this IP address, even I don't have a local IP anymore.
For me it seems, that Android does do a flush when changing the Settings DHCP to fixed IP and back.
I hope someone can help!
You need to kick the resolver:
runShellCommand("ndc resolver setifdns eth0 \"\" 8.8.8.8 8.8.4.4");
runShellCommand("ndc resolver setdefaultif eth0");