0

I have two clients

Android phone doing hotspot (192.168.43.1/24) Another device with static ip (192.168.1.10/24) I CAN'T change the network config of anyone, first because android hotspot is hardcoded inside (with root is possible but it's not a valid solution) and the other industrial device wich can't change the ip for now.

What I need to do is to get comunication between them, a simple ping for example. I know that with netmasks this is very easy, but as I said, it's not possible to change anything of the network configuration.

How would you solve this? My idea was about putting another device between them, for example a raspberry pi and capture paquets going to an ip of network1 and modify them to an ip of network2. Is that a possible solution?

Thanks

rul3s
  • 15
  • 5
  • Remove the router and put a subnet mask of 255.255.0.0 ? – yagmoth555 Dec 21 '16 at 18:19
  • 1
    What you say you're trying to do [doesn't make any sense](http://meta.stackexchange.com/q/66377/189912). What are you actually trying to accomplish with this setup? – Michael Hampton Dec 21 '16 at 18:54
  • First client is Android Hotspot, so it's imposible to change network address and/or subnet mask, and I need to access to the second client like if it was on this network, but it is not. So my idea was to put a linux between then actint as a router. Have any other idea? Thanks! – rul3s Dec 22 '16 at 08:07
  • I've edited the question in order to be more "open" of solution. Let's see if now someone can help me a little. Thanks. – rul3s Jan 02 '17 at 11:58
  • At the moment, this looks like a classic and completely standard application for a VPN: routing between two non-overlapping RFC1918 ipv4 networks is their bread-and-butter. – MadHatter Jan 02 '17 at 13:19
  • Yes! I would be a perfect solution if I could make a VPN between them, but the industrial device cant :(. Maybe make a VPN between both interfaces of the device between them? – rul3s Jan 02 '17 at 14:55

1 Answers1

0

Finally the solution it's a mixed of IPTABLES and VIRTUAL IP's, all made in the intermediate Linux gateway between them. This Linux device between them has two ifaces, wlan0 (43.20) and eth0 (1.1)

First I've added two virtual ip's

ifconfig wlan0:1 192.168.43.21/24
ifconfig eth0:1 192.168.1.2/24

And then I play with IPTABLES to redirect those virtual IP's to the other side of the gateway:

iptables -t nat -A PREROUTING -i wlan0 -s 192.168.43.1 -d 192.168.43.21 -j DNAT --to-destination 192.168.1.10
iptables -t nat -A POSTROUTING -o eth0 -d 192.168.1.10 -j MASQUERADE

iptables -t nat -A PREROUTING -i eth0 -s 192.168.1.10 -d 192.168.1.2 -j DNAT --to-destination 192.168.43.1
iptables -t nat -A POSTROUTING -o wlan0 -d 192.168.43.1 -j MASQUERADE

I hope this help someone.

rul3s
  • 15
  • 5