<div dir="ltr">I guess I need try to workaround my problem in some other ways (like disable systemd-resolved and use iptables to redirect my DNS request). Thank you anyways.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 23, 2019 at 12:27 AM Mantas Mikulėnas <<a href="mailto:grawity@gmail.com">grawity@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 22, 2019, 15:32 Lejia Chen <<a href="mailto:monsoon.cl@gmail.com" target="_blank">monsoon.cl@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Environment: Fedora 29, Systemd version: 241. (My NetworkManager use systemd-resolved as a DNS resolver)</div><div><br></div><div>I setup a VPN, and my VPN created a virtual interface (named tun0). I use iptables to mark some processes packets and let these packets go through this virtual interface.</div><div><br></div><div>I add a DNS in this tun0 device, and want those marked processes to use this DNS to resolve domain. Also I want other processes to use my default network interface's (name enp7s0) DNS to resolve domain. The marked processes don't use enp7s0 interface DNS, and other process don't use tun0 interface DNS.</div><div><br></div><div>I try to configure my interface DNS settings many times, but I still can't solve my problem. systemd-resolved always sends DNS resolve requests to</div></div></blockquote></div></div><div dir="auto"><br></div></div><div dir="auto"><div dir="auto">There's the key part: <i>systemd-resolved</i> sends the DNS requests – not your processes themselves. So the iptables rules are never matched because the packets are generated by a different process with a different UID.</div><div dir="auto"><br></div><div dir="auto">There is no way for systemd-resolved to know what fwmark would have been applied to the original process, iptables rules are only known to iptables itself.</div><div dir="auto"><br></div><div dir="auto">(in fact, if you use the DNS emulation at 127.0.0.53, I'm not sure if systemd-resolved even knows which process sent the request.. )</div><div dir="auto"><div class="gmail_quote"></div></div></div>
</blockquote></div>