On Mon, Apr 22, 2002 at 11:00:56PM -0500, Peter Caldes wrote:
> Hopefully somebody here can help me. I'm not that familiar with the detailed Linux 
>Networking stack.
> 
> I have a box which acts as a gateway and need a way for (multiple) user (root) level 
>applications to
> insert IP packets into the IP stack and somehow bypass normal routing which is based 
>on the
> destination IP addr of the packet.
> 
> I want the application(s) to specify the next hop the packet takes without modifying 
>the IP packet
> itself, so that the packet can be directed/forwarded to a particular router based on 
>the application
> parameters. The real reason is that IP addresses in the same subnet might reside 
>behind different
> routers. (ie. 1.2.3.1 is behind RouterA, 1.2.3.2 is behind RouterB). The application 
>knows which
> router to use.
> 
> I've been able to do this under AIX V4.2.1(with some kernel extensions) using RAW IP 
>sockets and
> then specifying a source route option on the socket with setsockopt(). The kernel 
>mod checks the
> socket options and if it sees a source-route option, it computes a route to the 
>first ip address in
> the source-route list instead of the ip destaddr.
> 
> Now I need to do something similar with Linux.
> 
> It seems I can register a NF_IP_LOCAL_OUT hook, but I don't know how to mangle 
>skb->dst.
> I also assume that when the NF_IP_LOCAL_OUT hook is called, I can scan the socket 
>options to do
> something similar.

You don't need kernel modules under Linux. Simply put an fwmark on the
packets using an iptables rule, and then use policy routing to route the
packets based on that value.

ip rule add fwmark 100 lookup table 100
ip route add default via x.x.x.x table 100

-- 
Bazsi
PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1

Reply via email to