<div style="color:#000; font-size: 14px;font-family: arial;"><div>Hi everyone,<br>        I'm a Chinese user with Internet access polluted by the GFW (the Great Firewall of China). To visit, e.g., the sites of Google, I have to setup a proxy and then redirect related packets to the proxy server at 127.0.0.1.<br>        Currently, I configure something like the following on my OpenWRT router:</div><div><br></div><div>        1. Add this line dnsmasq.conf (resolve Google's IP addresses via 8.8.4.4)<br>                - server=/google.com/8.8.4.4</div><div>        2. Add this line into the firewall script (make sure that the DNS reply from 8.8.4.4 is not polluted)</div><div>                - iptables -t nat -I PREROUTING -p udp -d 8.8.4.4/32 -j REDIRECT --to-ports 8001</div><div>        3. Add these lines into the firewall script (visit Google's sites via proxy; there're a lot of addresses to be included)<br>                - iptables -t nat -I PREROUTING -p tcp -d 173.194.127.0/24 -j REDIRECT --to-ports 8001<br>                - iptables -t nat -I PREROUTING -p tcp -d 216.58.221.0/24 -j REDIRECT --to-ports 8001<br>                - iptables ...<br><br>        4. Add this line into the firewall script (start the shadowsocks proxy at 127.0.0.1)<br>                - ss-redir -s server -p server_port -k password -m encryption_method -l local_port(8001) &<br><br>It works, but I find that I have to update the IP address list every few weeks. Of course I can create a cron job that do this automatically, something like:</div><div><br></div><div>        #!/bin/sh</div><div>        nslookup www.google.com > 01.log</div><div>        nslookup play.google.com > 02.log</div><div>        nslookup code.google.com > 03.log<br></div><div>        ...</div><div>        awk -f process_nslookup_result.awk 01.log > ip_list.txt</div><div>        awk -f process_nslookup_result.awk 02.log >> ip_list.txt <div>        awk -f  process_nslookup_result.awk 03.log >> ip_list.txt</div><div>        ...</div><div>        update_iptables_rules.sh ip_list.txt</div><div><br></div><div>A major problem of this scheme is that I have to create a lot of similar domain items, and I cannot have *.google.com like the server option in dnsmasq.conf. To find out the second-level domains I have missed, some packet tracing is needed, which is rather boring for most users.</div><div><br></div><div>Is there a way to solve this problem? If dnsmasq is able to export the ip addersses of specified hosts (e.g., *.google.com) to a file, or to execute an external program when domain names resovled, I think that I will be able to find a better solution.</div><div><br>Sincerely</div><div>Fengyu Gao</div></div></div><!-- jy5ContentSuffix -->