Forcing source ip and/or route
Posted: Sun Mar 31, 2024 9:37 am
I'm not sure how to properly express this. I had a problem that I tried to solve with various combinations of src-nat and routing policy, failed, and then fixed it by doing it properly - which means configuring the clients directly instead of trying to use network magic.
But I *want* to learn network magic. So while my original problem has been solved - I'd like to know how I *could* have accomplished this through the router.
My cloud server is has static public IP a.a.a.a. It provides wireguard service as b.b.b.a.
My office router has dynamic public IP so.me.th.ing. It has wireguard IP b.b.b.b.
My office server has a LAN IP c.c.c.c behind the router.
<deleted long story>
The question - how can I force traffic from c.c.c.c, destined to a.a.a.a, come from b.b.b.b? Or to put it another way how to force traffic from my office server destined to the public address of the cloud server, which is otherwise properly routed and reachable, instead through the VPN? And while in this particular case a valid answer *might* be via wireguard configuration - I really want to know how to do it via routing.
I tried
That didn't work.
I tried
And that didn't work.
What am I missing?
But I *want* to learn network magic. So while my original problem has been solved - I'd like to know how I *could* have accomplished this through the router.
My cloud server is has static public IP a.a.a.a. It provides wireguard service as b.b.b.a.
My office router has dynamic public IP so.me.th.ing. It has wireguard IP b.b.b.b.
My office server has a LAN IP c.c.c.c behind the router.
<deleted long story>
The question - how can I force traffic from c.c.c.c, destined to a.a.a.a, come from b.b.b.b? Or to put it another way how to force traffic from my office server destined to the public address of the cloud server, which is otherwise properly routed and reachable, instead through the VPN? And while in this particular case a valid answer *might* be via wireguard configuration - I really want to know how to do it via routing.
I tried
Code: Select all
/ip firewall nat add action=src-nat chain=srcnat dst-address=a.a.a.a src-address=c.c.c.c to-addresses=b.b.b.b
I tried
Code: Select all
/routing table add fib name=wg
/routing rule add action=lookup-only-in-table dst-address=a.a.a.a src-address=c.c.c.c table=wg
/ip route distance=1 dst-address=a.a.a.a gateway=b.b.b.b pref-src="" routing-table=wg scope=30 suppress-hw-offload=no target-scope=10
What am I missing?