I have three wlan interfaces attached in my RaspberryPi:

  • wlan0
  • wlan1
  • wlan2

Each of them is connected to the different SSID:

  • gopro-0
  • gopro-1
  • gopro-2

GoPro cameras are set as a WiFi router, have always the same IP address:

With this configuration if I call:


then first wlan0 interface will be used (simplified assumption). If I'd like to call the camera gopro-2, I hve to invoke:

curl --interface wlan2

It works. However there is a problem that not all commands allows me to specify the interface (i.e. ffmpeg - or I don't know about it).

Is it possible to somehow trick Linux and delegate some IP address to be forwarded to on specific interface?

For example: -> @ wlan0 -> @ wlan1 -> @ wlan2

I would appreciate any solution or even other approach that will let me call the same IP on different interface using regular HTTP GET/POST methods.

  • The clean solution is obviously to assign different IP addresses to the gopro's. Why is this not possible? – dirkt Mar 22 '17 at 7:29
  • @dirkt Each GoPro camera - if works as a hotspot - creates wlan network with SSID that I can specify, but their IP addresses are always fixed: - there is no possibility to change it. – hsz Mar 22 '17 at 8:04
  • 2
    That sounds really broken. I'd use iptables with SNAT (incoming) and DNAT (outgoing) targets to map IPs depending on the interface, as you suggested. Make sure the routing tables match. I can't write rules for you because I can't test them without the hardware setup. – dirkt Mar 22 '17 at 10:40

I had this same issue for a different type of device and figured out a way to do it. You need a combination of iptables mangle and ip route

Give each interface a unique IP( below) on the same subnet as the device. In this example the virtual IP for the first device is

My physical devices were all at on 4 different interfaces and with this pattern and the virtual IPs I could reliably communicate with all of them.

iptables -t mangle -A PREROUTING -d -j MARK --set-mark 0x01

iptables -t nat -A PREROUTING -m mark --mark 0x01 -d -j DNAT --to-destination

iptables -t nat -A POSTROUTING -m mark --mark 0x01 --destination -j SNAT --to-source

With this in place, now add the following routes.

ip route add dev eth4 table 1
ip rule add from all fwmark 1 table 1
ip route flush cache

You can repeat this pattern any number of times, just keep increment the mark and the addresses for how ever many interfaces you have.

Hopefully this will be useful to others dealing with duplicate addresses on different network interfaces.

| improve this answer | |

I think the way is to use iptables, and set routes for that. Here is a similar answer for the question that you asked:


This is a bit less complex in OpenBSD/pf.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.