I'm working on some test project, basically I want to route all traffic when I'm in hotspot mode into a fixed address. I have the IP range for example 192.168.0.0/24 I don't know if I can use iptables without root or JNI functions (can't find any that match what I want)
Thinking out of the box is very welcomed (DNS, low level packet broadcast on client connect etc...)
Any Idea?
EDIT: How Android and iOS detect a Network Portal?
source : https://sudoroom.org/wiki/Mesh/Firmware/Splash_page
They try to HTTP GET on
iOS: http://www.apple.com/library/test/success.html and expect a 200 if not behind portal
Android: http://clients3.google.com/generate_204 and expect a 204 status when not behind portal, any other status is a portal
So, how can I respond correctly to those detections?
The easiest approach is to enable a socks proxy when configuring the wifi AP you are connecting to. This varies depending on the version of android, but it is typically something like:
Touch and hold the wifi network you want to connect to.
A dialogue box should pop-up. In that dialogue box, select advanced.
Find the proxy option and enter in the IP and port of the server you want to forward traffic to.
Android speaks SOCKS and so long as your proxy speaks SOCKS as well, you are good to go. If you root the device you can (depending on your version of Android), configure this proxy automatically. See, for instance, AdBlock Plus for Android which does exactly that.
If you don't want to go the proxy route you may be able to manually set ebtables rules if your device is rooted. This is significantly more work as you have to be careful not to mess up the NAT'ing that your device is already doing.
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?
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.
How can I direct all android data traffic excluding calls and SMS through a proxy server before it actually reaches its destination, I was able to retrieve and edit some system information like the net.eth0.gw. Will that help and if so, what exactly should I do with it? I'm very new to android and networking, any help will be appreciated.
Thank you.
You can direct your Android to use a Fiddler proxy. Or any HTTP proxy for that matter.
I do this from time to time on my Android phone for debugging HTTP network traffic. And that covers about 90% of everything you could think of needing to capture.
Setup Fiddler on your PC and enable it as a proxy server for other nodes. From the Fiddler Tool's menu, select Fiddler Options, and then Connections Tab. Then enable the "allow remote computers to connect" checkbox.
Then configure your Android device's Wifi settings such that a manual proxy setting is specified for the current Wifi connection. (You give it your PC's IP address at port 8888).
Then browse some websites on your phone. You should see the request/response flows in the Fiddler window.
This obviously only works for HTTP traffic - for code that uses the typical class libraries built into the connection. It doesn't work for code using sockets. Anything over HTTPS will be hard to view since its encrypted, although Fiddler has a few options that you can try (YMMV).
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.
I have an Android device. I need to forward packets arriving at the external IP to an internal IP to which Android is connected to.
I would like to know if I can write an App to enable this forwarding.
Also, if this doesn't what is the conventional way this is done. If I should use some scripts where should I place them??
And oh, can I test this using an android emulator??
Thanks.
It is may be possible to emulate a behavior like port forwarding but not routing for non rooted devices.
Also if you want to forward traffic from the mobile network to the wlan this is so far I know not possible. Android switches the connetion between mobile network and wlan. It is not possible to use both. Except some hot spot use cases.