On Mon, Oct 17, 2016 at 12:13:19AM +0200, Harald Welte wrote:
On Sun, Oct 16, 2016 at 11:55:33PM +0200, Neels
Hofmeyr wrote:
So normally when I send something, the routing
table (ip r show) determines
which local interface the remote side sees as sender.
Yes. Please note 'ip r show' will only show you 'table main'. Since
Linux 2.2.x (yes, ages ago) Linux supports and uses multiple routin
tables. See 'ip route show table all' to see all routes that exist in
the stack.
yep, that was a gotcha when I started to get used to Freifunk -- scratching my
head at the main table until I saw a hundred more routes in tables 'olsr' and
'olsr-default' (and having to fix the table priorities...)
[...]
[...]
So something like 'ip route add 8.8.8.8/32 via
192.168.100.1 src 1.2.3.4'
will teach the routing table to choose the local source address 1.2.3.4
whenever sending packets to 8.8.8.8 and route them via the gateway
192.168.100.1. This configuration is valid system-wide, for all
applications/sockets. Please note that 1.2.3.4 must be a valid local
address (i.e. one that has been added using 'ip addr add 1.2.3.4 ...'
before.
Thanks for the excellent explanation and link!
It's very clear to me now.
--
- Neels Hofmeyr <nhofmeyr(a)sysmocom.de>
http://www.sysmocom.de/
=======================================================================
* sysmocom - systems for mobile communications GmbH
* Alt-Moabit 93
* 10559 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B
* Geschäftsführer / Managing Directors: Harald Welte