Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ip rule fwmark doesn't work #11

Open
xedoc opened this issue Apr 9, 2018 · 1 comment
Open

ip rule fwmark doesn't work #11

xedoc opened this issue Apr 9, 2018 · 1 comment

Comments

@xedoc
Copy link

xedoc commented Apr 9, 2018

To reproduce it, add a rule:
ip rule add to 1.1.1.1 fwmark 1 lookup 1
ip route add default via 127.0.0.1

and check route for 1.1.1.1 with and without the mark:
ip route get 1.1.1.1
ip route get 1.1.1.1 mark 1

Both will return the same result and that's wrong behavior.
First command should return default gateway from the main table (ip route show)
Second command should return dev lo

What is weird - it works if I use tos instead of fwmark.

I've tried different distros (ubuntu, debian, centos) for my M2 Berry. It doesn't work. Seems there is some problem with the kernel options or something else.
CONFIG_IP_ADVANCED_ROUTER is set to y in /proc/config.gz

@bytescreator
Copy link

bytescreator commented May 2, 2020

It's not working because the default route you added is at the wrong table, you are adding it to the main table instead of table 1.

Here's my terminal output (Arch Linux 5.6.7-arch1-1)

#ip rule add to 1.1.1.1 fwmark 1 table 1
#ip rule
0: from all lookup local
32765: from all to 1.1.1.1 fwmark 0x1 lookup 1
32766: from all lookup main
32767: from all lookup default
# ip route get 1.1.1.1
1.1.1.1 via 192.168.42.129 dev enp0s4f1u5 src 192.168.42.143 uid 0
cache
# ip route get 1.1.1.1 mark 1
1.1.1.1 via 192.168.42.129 dev enp0s4f1u5 src 192.168.42.143 mark 1 uid 0
cache

As you could see it's not working
but when I add the default route

# ip route add default via 192.168.1.1 table 1
# ip route get 1.1.1.1 mark 1
1.1.1.1 via 192.168.1.1 dev enp3s0 table 1 src 192.168.1.254 mark 1 uid 0
cache
# ip route get 1.1.1.1
1.1.1.1 via 192.168.42.129 dev enp0s4f1u5 src 192.168.42.143 uid 0
cache

it wasn't working because it was using the backup main table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants