Hello humans of OpenWrt
I'm having a problem that I cannot solve, or maybe I'm too mentally convoluted.
Sometimes, I connect to my network with wifi (IP address Y)
Some other times, I connect to the same network via an ethernet cable (IP address X, but same computer)
When I connect via cable, firewall rules and mapped ports don't work anymore, obviously.
I could set up different firewall rules with different ports in each case, but I'd like to minimize time, not changing ports in programs continuously every time I switch ip address.
Currently, OpenWrt also cannot set 2 individual destination IPs on the same
dest_ip option for the same firewall rule, like this:
config rule option target 'ACCEPT' option src 'wan' option dest 'lan' option name 'random UDP rule' option proto 'udp' option dest_ip '192.168.1.14 192.168.1.121' option src_port '40799' option dest_port '40799'
it's suggested somewhere else on the web, but it doesn't work.
Also, if I change wifi card or adapter often, I will have to update every rule.
My ideal solution would be to set an universal "IP address alias", a pseudonym, for a series of different IP addresses. Not an alias for hostnames or other misleading names.
- these network devices can be (or not be) present on the local network (each IP is associated via mac addresses to a network card of course):
- let's choose a pseudonym IP address, A: e.g. 192.168.1.100
Ideally, on OpenWrt I'll do these:
- to set A as pseudonym for X, Y and Z
- to set firewall rules for A only
Therefore, this should happen:
- if X is present, redirect traffic destined for A to X and translate X's traffic as it was A's
- if Y is present, redirect traffic destined for A to Y and translate Y's traffic as it was A's
- if Z is present, redirect traffic destined for A to Z and translate Z's traffic as it was A's
- in case of multiple of these IP are active, either associate A following a strict X or Y or Z order, or one at random, or the fastest, or all active ones at the same time (this is another problem)
I've read a lot about DNAT and SNAT, but I'm not sure if continuously rerouting traffic to maybe non-existening IPs in the lan is the sane choice, and I couldn't get to work anyway.
Changing mac address of the network card is an option, but not always available (some usb cards are too fluky, or having active both ethernet and wifi interface can create real confusion).
Am I missing something?