LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-26-2018, 04:05 PM   #1
erabaddosi-2116
LQ Newbie
 
Registered: Mar 2018
Posts: 20

Rep: Reputation: Disabled
Not your average Policy-based routing question? (Help needed)


Hello!

I am attempting to perform port-based policy routing, but naturally "it" is not working. Environment:

There is an incoming openvpn tunnel landing on "problem" router (AWS EC2 Linux machine). Two upstream gateways: "normal" default gateway and "target" default gateway. Port 80 traffic needs to go to "target" gateway (running squid, for the curious -- I could run it on the "problem" host, but I'd like to separate compute resources for the time being).

The default firewall policy is accept for all tables. Openvpn dumps decrypted traffic (Internet-bound) through PREROUTING, so the marking rule is successfully picking it up (per iptables -t nat -L -v -n):

Chain PREROUTING (policy ACCEPT)
target prot opt source destination
MARK tcp -- anywhere anywhere tcp dpt:http MARK set 0x1

Later, POSTROUTING sees the mark and then MASQUERADE NATs the traffic (successfully).

iproute2 is available on this system and is configure:

"ip rule list" displays:

0: from all lookup local
32765: from all fwmark 0x1 lookup www
32766: from all lookup main
32767: from all lookup default
60000: from all fwmark 0x1 lookup www

"ip route show table www" displays:

default via 172.16.0.103 dev eth0

172.16.0.103 is the IP of the "target" gateway.

cat /proc/sys/net/ipv4/conf/*/rp_filter shows all 0.

cat /proc/sys/net/ipv4/tcp_fwmark_accept shows 1.

tcpdump -ni eth0 -xe port 80 never shows traffic leaving via the correct upstream MAC.

Is SNAT/MASQUERADE eating fwmarks? If I switch the configuration to TOS, the tcpdump successfully show TOS being marked on the packets...on the way to the wrong gateway...which is part of why I wonder if SNAT/MASQUERADE are being problematic.

Help? What add'l info can I provide?
 
Old 03-30-2018, 09:30 AM   #2
erabaddosi-2116
LQ Newbie
 
Registered: Mar 2018
Posts: 20

Original Poster
Rep: Reputation: Disabled
Update: Switching to ToS works. Perhaps I forgot to flush the route cache (ip route flu cache) or perhaps this was before I added the priority 60,000 rule (ip rule add fwmark 1 table www pri 60000).

Aside from the situation being resolved (for me), it is STILL strange that fwmarks are not being received by iproute2 after the PREROUTING chain. This will likely need attention again, by someone, at some point.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux distro supports Routing Based Policy oudmaster Linux - Networking 3 04-21-2015 06:06 PM
Port-policy based routing, not a gateway murmel Linux - Networking 0 09-13-2009 09:16 PM
Policy based routing, leaking packets tetra Linux - Networking 0 04-22-2009 02:15 AM
Source based policy routing with one NIC ardora Linux - Networking 3 12-02-2007 08:02 AM
help with policy based routing GaijinPunch Linux - Networking 4 06-19-2005 06:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration