I am running a k3s cluster on some raspberry pi 4, in my local network. I have a DNS server (dnsmasq) on the master nodes. I want that the pods of my cluster use that DNS server, via coredns. However when I ping an adress from within a pod I always pass via the google DNS servers and overpass my local DNS rules.
apiVersion: v1
kind: ConfigMap
data:
  Corefile: |
    .:53 {
        errors
        health
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          upstream
          fallthrough in-addr.arpa ip6.arpa
        }
        hosts /etc/coredns/NodeHosts {
          reload 1s
          fallthrough
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }
this is my coredns config. As you see there is the forward . /etc/resolv.conf 
my /etc/resolv.conf
domain home
nameserver 127.0.0.1
Any suggestions ?
                        
You might try just forwarding to the Master node's real IP where your DNS server is running. This would be the IP that can be utilized by the other nodes in the cluster. So rather than /etc/resolv.conf, it would be something like:
forward . <master node ip>