I'm completely lost. I'm a real beginnqer about Linux networking.
What I’m trying to accomplish :
As bobstro said, I want to allow a wifi-connected UPnP camera to be moved around between wifi networks. The RPI is connected to these networks, the camera is connected to the RPi. But the RPi is not an access point. It’s connected to a server via TCP or websocket and receives orders to take pictures via the camera. It then sends back the picture via websocket or TCP.
My situation :
I have three interfaces on my Raspberry Pi: eth0, wlan0, and wlan1 (2 Wi-Fi USB dongles).
wlan1 will be used to connect to a Wi-Fi camera via SSDP.
wlan0 will be used to have a TCP connection to a server (ip/domain name known). I know nothing about the Wi-Fi network wlan0 is connected to via DHCP. It could change from time to time. It doesn't know the gateway specially.
eth0 will be used for debug SSH access, via my MacBook Air connection sharing service by example.
Server <---> Internet <--wlan0--> RPI <--wlan1--> Camera
|
etho
|
Macbook
Currently, all these interfaces are up. Here's the ifconfig output
(wlan1 and eth0 are on the same network, but that will not be the case
in the future):
eth0 Link encap:Ethernet HWaddr b8:27:eb:8c:e2:10
inet addr:192.168.0.19 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1174 errors:0 dropped:0 overruns:0 frame:0
TX packets:141 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:93616 (91.4 KiB) TX bytes:12342 (12.0 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr c0:4a:00:2a:ab:6c
inet addr:192.168.43.44 Bcast:192.168.43.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1142 (1.1 KiB) TX bytes:1145 (1.1 KiB)
wlan1 Link encap:Ethernet HWaddr 74:da:38:0c:c6:f0
inet addr:192.168.2.2 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1480 errors:0 dropped:0 overruns:0 frame:0
TX packets:155 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:222449 (217.2 KiB) TX bytes:29711 (29.0 KiB)
And here's the output of sudo route -n:
0.0.0.0 192.168.0.254 0.0.0.0 UG 0 0 0 eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan1
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.43.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
And here /etc/network/interfaces:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
post-up route del default dev wlan0
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "wifi1"
wpa-psk "psw1"
auto wlan1
allow-hotplug wlan1
iface wlan1 inet dhcp
wpa-ssid "wifi2"
wpa-psk "pwd2"
If I understand correctly what I've read in the past 24 hours, I need to do routing stuff. But I don't understand what and how.
Do I have to change the default route? If so, how can I manage to do that since I don't know the gateway for wlan0 or wlan1 before connecting to the network? Is that an impossible problem to solve?
This post might be a duplicate; but since yesterday I have found nothing helpful, so at least I need some help to find an original post. :)
Edit: As goldilocks mentioned, my question is broad. I'm really sorry. I don't know anything about networking. I don't know how to split this into more specific questions.
So, maybe a first failed attempt:
I've tried sudo ip route del default to remove the default eth0
gateway. Then sudo ip route add default dev wlan0, the command works
but results in this routing table:
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 wlan0
whereas I want the Raspberry Pi to find the wlan0 wifi router IP (I don't know it and it could change) and use it as gateway. It would be a good first step.
Edit 2: wlan1 is now on network 192.168.2.x.