Linux kernel: how to force TCP RST to be sent on incoming interface and not making routing decisions? -
i'm working in environment services isolated no routing between them. therefore need send tcp rst
message through incoming interface , not make routing decisions @ since no route available dst
, rst
messages lost.
i've added line in linux kernel tcp_v4_send_reset function:
arg.bound_dev_if = (skb->dev != dev_net(skb->dev)->loopback_dev) ? skb->dev->ifindex : 0;
but can see tcpdumps rst message not sent on incoming interface routing decision made.
any help?
did miss something?
you not need modify kernel achieve this, use ip rule
instead.
first mark connection coming different interface, , save mark in conntrack table (i'm using eth2/4 example):
iptables -t mangle -a routemark -i eth2 -j mark --set-mark 0x100 iptables -t mangle -a routemark -i eth4 -j mark --set-mark 0x200 iptables -t mangle -a routemark -m mark ! --mark 0x0/0xff00 -j connmark --save-mark --mask 0xff00
then create rt_table each interface in /etc/iproute2/rt_tables
, insert default route table:
ip route add default via gateway-ip-eth2 dev eth2 table rt-eth2 ip route add default via gateway-ip-eth4 dev eth4 table rt-eth4
for every outgoing packet, restore connection mark packet mark, , lookup corresponding rt_table:
iptables -t mangle -a prerouting -m connmark ! --mark 0x0/0xff00 -j connmark --restore-mark --mask 0xff00 ip rule add fwmark 0x100/0xff00 ! iif eth2 lookup rt-eth2 ip rule add fwmark 0x200/0xff00 ! iif eth4 lookup rt-eth4
so responding packet sent interface origin packet comes from.
Comments
Post a Comment