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.

  • 1
    The clean solution is obviously to assign different IP addresses to the gopro's. Why is this not possible?
    – dirkt
    Mar 22, 2017 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, 2017 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, 2017 at 10:40
  • 1
    See also: cam-do.com/pages/ip-address-changer Aug 4, 2020 at 15:04
  • 1
    @MikkoRantalainen that seems to be the best solution: fix the brokenness so that the workaround I've no longer necessary Dec 22, 2023 at 10:36

3 Answers 3


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.

  • These commands don't seem to work. I would expect to be able to do ping and end up hitting Is there a step missing? Do you have to create a VLAN or something that is set to Feb 14, 2021 at 23:51
  • This was very helpful! Now how would be the setup to achieve the opposite operation? I mean redirecting packets from: * wlan0 -> * wlan1 -> * wlan2 ->
    – Eric
    Dec 22, 2023 at 0:05

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.


The very same problem was described on this thread: https://forum.developer.parrot.com/t/multiple-parrot-anafi-controlled-via-olympe-on-linux-configure-ip/9590/2

It gives a complete solution, that indeed uses both iptables rules and routing

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .