* nftables routing decision
@ 2020-02-03 19:37 Иванов Роман
2020-02-05 11:33 ` Florian Westphal
0 siblings, 1 reply; 2+ messages in thread
From: Иванов Роман @ 2020-02-03 19:37 UTC (permalink / raw)
To: netfilter
How nftables make router decision about packet directed to input or
forward chains?
Please see my example
We have router with nftables, private host and public host that redirect
traffic to private host through tunnel
Private host Router Public host
[LAN 192.168.40.12] (5)=> [WAN 95.0.0.1] (1)=> [WAN 96.0.0.1]
(2)=!
|<=(4) [Tunnel 192.168.40.1] <=(3) [Tunnel
192.168.40.2] <=!
If i try to connect from private network to public host connection fails
On step (5) when private host send answers back to 95.0.0.1, nftables on
router put packets in input chain but not forwarding chain.
This behaviour apears regardless any packet marks.
How i can change this behavior? May be some options on raw, mangle or
other chains that overrides routing decision and put packet directly in
forward chain?
By steps:
0. From other host in lan query 96.0.0.1, http get for example
1. Router make masq or snat. Src ip 95.0.0.1, Dst ip 96.0.0.1
2. Public host makes dnat, Src ip 95.0.0.1, Dst ip 192.168.40.12.
3. Packet sent via tunnel.
4. Router forward packet to 192.168.40.12
(net.ipv4.conf.tnl.accept_local must be 1). Src ip 95.0.0.1, Dst ip
192.168.40.12.
5. Private host receive packet and send response. Src 192.168.40.12, Dst
ip 95.0.0.1
6. Nftables on router receive packet with Dst ip 95.0.0.1 and put it on
input chain. Initial host on step 0 never get response.
Best Regards
Krey
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: nftables routing decision
2020-02-03 19:37 nftables routing decision Иванов Роман
@ 2020-02-05 11:33 ` Florian Westphal
0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2020-02-05 11:33 UTC (permalink / raw)
To: Иванов
Роман
Cc: netfilter
Иванов Роман <krey@irinium.ru> wrote:
> How nftables make router decision about packet directed to input or
> forward chains?
It doesn't, just like with iptables. INPUT vs. FORWARD decision
depends on routing decision done in network stack.
> Please see my example
> We have router with nftables, private host and public host that redirect
> traffic to private host through tunnel
>
> Private host Router Public host
> [LAN 192.168.40.12] (5)=> [WAN 95.0.0.1] (1)=> [WAN 96.0.0.1]
> (2)=!
> |<=(4) [Tunnel 192.168.40.1] <=(3) [Tunnel
> 192.168.40.2] <=!
>
> If i try to connect from private network to public host connection fails
> On step (5) when private host send answers back to 95.0.0.1, nftables on
> router put packets in input chain but not forwarding chain.
> This behaviour apears regardless any packet marks.
> How i can change this behavior? May be some options on raw, mangle or
> other chains that overrides routing decision and put packet directly in
> forward chain?
There is no such thing. Routing decision is only relevant factor.
You can set packet marks if you need policy routing ("ip rule"),
but that doesn't allow to override the routing table, it merely allows
(with "ip rule" in place) to select the routing table to use.
> By steps:
> 0. From other host in lan query 96.0.0.1, http get for example
> 1. Router make masq or snat. Src ip 95.0.0.1, Dst ip 96.0.0.1
> 2. Public host makes dnat, Src ip 95.0.0.1, Dst ip 192.168.40.12.
> 3. Packet sent via tunnel.
> 4. Router forward packet to 192.168.40.12
> (net.ipv4.conf.tnl.accept_local must be 1). Src ip 95.0.0.1, Dst ip
> 192.168.40.12.
> 5. Private host receive packet and send response. Src 192.168.40.12, Dst
> ip 95.0.0.1
> 6. Nftables on router receive packet with Dst ip 95.0.0.1 and put it on
> input chain. Initial host on step 0 never get response.
Yes, step6 looks correct because 95.0.0.1 is a local address after all,
"ip route get 95.0.0.1" on router will say its local address.
If you really want this config (I don't understand this snat), you need
to use policy routing to have the kernel consult a different routing
table for the packet.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-05 11:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03 19:37 nftables routing decision Иванов Роман
2020-02-05 11:33 ` Florian Westphal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.