Find the answer to your Linux question:
Results 1 to 3 of 3
Hi there, What am I doing wrong?? Im trying to route traffic based on dst port. I have a server with 4 interfaces and I need to route traffic which ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    1

    Port based routing


    Hi there,

    What am I doing wrong??
    Im trying to route traffic based on dst port.
    I have a server with 4 interfaces and I need to route traffic which comes through bond3 to port 8888 that it will go back to same bond and to some specific GW.
    Now it is coming through bond3 and reply goes through bond1 to default GW.

    I was trying like this:

    iptables -A PREROUTING -t mangle -i bond3 -p tcp --dport 8888 -j MARK --set-mark 1

    ip rule add from all fwmark 1 table 11

    ip route add default via x.x.x.x table 11


    can you help?

    BR, Nejc

  2. #2
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    LiNUX Horizon - Linux Advanced Routing mini HOWTO
    second example

    Add option dev bonX after via x.x.x.x in your ip route add default line to see if it makes a difference.

    Good luck.

  3. #3
    Just Joined!
    Join Date
    Jul 2011
    Posts
    1
    Hopefully I can save someone else the weeks of pain I had, with this not working for no apparent reason!

    Still doesn’t work? Check these things below:

    rp_filter has to be set to 0 for given interfaces – 0 is the default value set by the Linux kernel, but some distributions (i.e. Ubuntu, Mandriva) alter it and set it to 1; just adding that to /etc/sysctl.conf should do the trick to make sure this value is set to 0 after reboot:

    net.ipv4.conf.default.rp_filter=0
    net.ipv4.conf.all.rp_filter=0

    If you’re not rebooting any time soon, see what these value currently are with:

    find /proc/sys/net -name rp_filter | xargs cat

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •