2009/6/19 Stagg Shelton stagg@3pconnect.com:
Is force_send_socket([proto:]address[:port]) the function that I need to be trying to use to meet this requirement? Is there a simpler method that can be used instead?
I'm not 100% sure about it, but try this: Every packet on linux goes through a routing table, which includes an outbound interface. You can specify an alias for each 'local' ip address. Then - routes are matched beginning with the longest prefix, so...
- for original interface ethX (for example eth0) create interfaces ethX:1 .. ethX:N with the source ips assigned to them - set a route for each interface: route add -host gw_ip_1 dev ethX:1 route add -host gw_ip_2 dev ethX:2 ... - you may need to add a network, which covers those gateways, so in case 'add -host' complains: route add -net gw_ip_1 netmask minimal_netmask_covering_all_gws dev ethX:1 ...
In theory it should work ;) I haven't tested it, so you may need to tweak it a bit (lot)...