arsoft.tools.net(DNS Server) Redirect traffic from one URL to another (DNS forwarding)
<p>Following the documentation of arsoft.tools.net on <a href="https://docs.ar-soft.de/arsoft.tools.net/" rel="nofollow">https://docs.ar-soft.de/arsoft.tools.net/</a>, we just developed a dns server to intercept every request from the network, everything is working fine!</p>

<p>The thing that is slowing us down is: When the client types www.google.com (for example), we want to show or redirect to www.yahoo.com(or an IP address), any clue of how can we achieve that?</p>

<p>There is some people looking for the same solution here:
<a href="https://arsofttoolsnet.codeplex.com/discussions?searchText=redirect" rel="nofollow">https://arsofttoolsnet.codeplex.com/discussions?searchText=redirect</a></p>

<p>Tks </p>

<p><strong>UPDATE 1:</strong></p>

<p>So far, this is what I have, but, redirecting is not working:</p>

<pre><code>class Program
{
    static void Main(string[] args)
    {
        using (DnsServer server = new DnsServer(System.Net.IPAddress.Any, 10, 10))
        {
            server.QueryReceived += OnQueryReceived;

            server.Start();

            Console.WriteLine("Press any key to stop server");
            Console.ReadLine();
        }
    }

    static async Task OnQueryReceived(object sender, QueryReceivedEventArgs e)
    {
        DnsMessage query = e.Query as DnsMessage;

        if (query == null)
            return;

        DnsMessage response = query.CreateResponseInstance();
        //response.AnswerRecords.Clear();
        //response.AdditionalRecords.Clear();

        if ((response.Questions.Count == 1))
        {
            // send query to upstream server
            DnsQuestion question = response.Questions[0];

            if (question.Name.ToString().Contains("www.google.com"))
            {
                DnsMessage upstreamResponse = await DnsClient.Default.ResolveAsync(DomainName.Parse("www.yahoo.com"), question.RecordType, question.RecordClass);
                //DnsMessage upstreamResponse = await DnsClient.Default.ResolveAsync(question.Name, question.RecordType, question.RecordClass);

                foreach (DnsRecordBase record in (upstreamResponse.AnswerRecords))
                {
                    response.AnswerRecords.Add(record);
                }
                foreach (DnsRecordBase record in (upstreamResponse.AdditionalRecords))
                {
                    response.AdditionalRecords.Add(record);
                }

                response.ReturnCode = ReturnCode.NoError;
                e.Response = response;
            }
        }
    }
}
</code></pre>