From: SamLT <sam@sltosis.org>
To: gapsf@yandex.ru
Cc: netfilter@vger.kernel.org, gnetravali@sonusnet.com
Subject: Re: Routing the DNS Traffic via specific interface.
Date: Fri, 27 Jan 2012 16:51:05 +0100 [thread overview]
Message-ID: <20120127155105.GA9371@tosh.sltosis.org> (raw)
In-Reply-To: <607824512.20120125163350@yandex.ru>
On Wed, Jan 25, 2012 at 04:33:50PM +0700, gapsf@yandex.ru wrote:
> No. You should use "Policy routing" with MARK target in iptables.
>
> Mark outgoing DNS packets with iptables in mangle PREOROUTING for example.
> # iptables -t mangle -A PREROUTING -p udp --dport 53 -j MARK --set-mark 0x4
>
> Create additional routing table with different routing rules.
> Add new entry in /etc/iproute2/rt_tables
> =========================================
> #
> # reserved values
> #
> 255 local
> 254 main
> 253 default
> 0 unspec
> #
> # local
> #
> #1 inr.ruhep
> 1 isp2 # <- new entry
> =========================================
>
> Then execute
> # ip route flush table isp2
> and add defalt route into newly created table
> # route add default via <ip_of_your_eth2_gateway> dev eth2 table isp2
>
> Add new policy in RPDB.
> # ip rule add from all fwmark 0x4 table isp2
Consider adding a preference/priority to your rule(s) to avoid potential
future headaches
>
> Check RPDB
> # ip rule show
> You should view somthing like this:
> 0: from all lookup local
> 32763: from all fwmark 0x4 lookup isp2
> 32766: from all lookup main
> 32767: from all lookup default
>
> In result: all traffic routed with main routing table, except marked DNS traffic routed
> via "isp2" routing table via its default route and iface.
> View picture http://postimage.org/image/nn9owf5x7/ for example.
>
> NG> Hi ..
>
> NG> I have 2 interfaces eth0 and eth1 on the system connected to different subnets. I need to route all the outgoing DNS traffic of the system via eth1 interface. Pls let me know if below IPTABLES rules is proper way ?
>
> NG> Block the output DNS traffic on eth0 interface.
>
> NG> iptables -A FORWARD -p udp -o eth0 --dport 53 -j DROP
>
> NG> Forward output DNS traffic from eth1 interface
>
> NG> iptables -A FORWARD -p udp -o eth1 --dport 53 -j ACCEPT
>
>
> NG> Thanks
> NG> Ganesh
>
>
> NG> --
> NG> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> NG> the body of a message to majordomo@vger.kernel.org
> NG> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-01-27 15:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-25 7:41 Routing the DNS Traffic via specific interface Netravali Ganesh
2012-01-25 8:41 ` Yann Lejeune
2012-01-25 9:33 ` gapsf
2012-01-27 15:51 ` SamLT [this message]
2012-02-02 4:52 ` Netravali Ganesh
2012-02-03 7:30 ` gapsf
2012-02-05 9:46 ` Olshvang, LevX
2012-01-25 18:00 ` Rick Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120127155105.GA9371@tosh.sltosis.org \
--to=sam@sltosis.org \
--cc=gapsf@yandex.ru \
--cc=gnetravali@sonusnet.com \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox