Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #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
    NYC, moved from KS & MO
    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
    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:


    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

Posting Permissions

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