Local network tool that transparently redirects all X/Twitter traffic to xcancel.com, allowing you to browse Twitter content without directly accessing X's servers.
Guide for configuring DNS overrides on various routers and DNS servers besides Pi-hole and dnsmasq.
Regardless of your DNS solution, the goal is the same:
twitter.com, x.com, and t.co to your nginx server’s IPReplace 192.168.1.100 in examples below with your actual nginx IP address.
Most modern routers allow custom DNS entries.
192.168.1.1 or 192.168.0.1)twitter.com → 192.168.1.100x.com → 192.168.1.100t.co → 192.168.1.100192.168.1.100 twitter.com
192.168.1.100 x.com
192.168.1.100 t.co
Or via SSH:
# Edit /etc/hosts
nvram set dhcp_staticlist="<MAC_address>,<hostname>,192.168.1.100"
nvram commit
service restart_dnsmasq
twitter / x / tcom / com / co192.168.1.100For wildcard support:
local-zone: "twitter.com" redirect
local-data: "twitter.com A 192.168.1.100"
local-zone: "x.com" redirect
local-data: "x.com A 192.168.1.100"
twitter / x / tcom / com / coA (IPv4)192.168.1.100Newer UniFi Network versions have a built-in UI for local DNS:
twitter.com (or x.com, t.co)192.168.1.100For older versions or if you prefer command line:
# SSH to your UniFi gateway
ssh admin@<gateway-ip>
# Edit dnsmasq config
configure
edit service dns forwarding options
set address=/twitter.com/192.168.1.100
set address=/x.com/192.168.1.100
set address=/t.co/192.168.1.100
commit
save
exit
# Restart DNS
sudo /etc/init.d/dnsmasq force-reload
Note: SSH method settings may be lost on firmware updates. UI method persists.
# Via console
/ip dns static add name=twitter.com address=192.168.1.100
/ip dns static add name=x.com address=192.168.1.100
/ip dns static add name=t.co address=192.168.1.100
# For wildcards
/ip dns static add name=*.twitter.com address=192.168.1.100
/ip dns static add name=*.x.com address=192.168.1.100
Or via WebFig:
address=/twitter.com/192.168.1.100
address=/x.com/192.168.1.100
address=/t.co/192.168.1.100
# SSH to router
ssh root@<router-ip>
# Edit dnsmasq config
vi /etc/dnsmasq.conf
# Add:
address=/twitter.com/192.168.1.100
address=/x.com/192.168.1.100
address=/t.co/192.168.1.100
# Restart dnsmasq
/etc/init.d/dnsmasq restart
Or via LuCI web interface:
/twitter.com/192.168.1.100
/x.com/192.168.1.100
/t.co/192.168.1.100
Edit zone file or create a custom view:
# /etc/bind/named.conf.local
zone "twitter.com" {
type master;
file "/etc/bind/db.twitter.redirect";
};
zone "x.com" {
type master;
file "/etc/bind/db.x.redirect";
};
Zone files:
# /etc/bind/db.twitter.redirect
$TTL 86400
@ IN SOA ns1.local. admin.local. (
2025010101 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
86400 ) ; Minimum
@ IN NS ns1.local.
@ IN A 192.168.1.100
* IN A 192.168.1.100
Restart BIND:
sudo systemctl restart bind9
# /etc/powerdns/recursor.conf
forward-zones=twitter.com=192.168.1.100
forward-zones+=x.com=192.168.1.100
forward-zones+=t.co=192.168.1.100
Or use Lua config for more control:
-- /etc/powerdns/recursor.lua
addNTA("twitter.com")
addNTA("x.com")
rpzFile("twitter-redirect.rpz", {policyName="nxdomain"})
twitter.com → Next192.168.1.100* → IP: 192.168.1.100Repeat process for x.com and t.co.
Edit Corefile:
.:53 {
# Redirect specific domains
rewrite stop {
name regex (.*\.)?twitter\.com twitter.com
answer name twitter.com {$1}twitter.com
}
file /etc/coredns/db.redirect twitter.com
file /etc/coredns/db.redirect x.com
file /etc/coredns/db.redirect t.co
# Forward everything else
forward . 1.1.1.1 8.8.8.8
cache
errors
log
}
Zone file /etc/coredns/db.redirect:
$ORIGIN twitter.com.
@ IN A 192.168.1.100
* IN A 192.168.1.100
If you’re using Cloudflare Zero Trust (formerly Teams):
Hostmatches regex(.*\.)?twitter\.com|(.*\.)?x\.com|t\.coNote: Cloudflare DNS cannot redirect to RFC1918 private IPs. Only useful if your nginx has a public IP.
Public DNS services cannot be customized. You must run your own DNS server.
If you can’t configure a DNS server, you can modify each device’s hosts file.
# Run as Administrator
notepad C:\Windows\System32\drivers\etc\hosts
Add:
192.168.1.100 twitter.com
192.168.1.100 www.twitter.com
192.168.1.100 x.com
192.168.1.100 www.x.com
192.168.1.100 t.co
192.168.1.100 www.t.co
Save and flush DNS:
ipconfig /flushdns
sudo vim /etc/hosts
Add same entries as above. Save and flush:
# macOS
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# Linux
sudo systemd-resolve --flush-caches
Requires jailbreak/root. Not recommended. Use network-wide DNS instead.
Regardless of which method you used:
# Test DNS resolution
nslookup twitter.com
# Should return 192.168.1.100
nslookup x.com
# Should return 192.168.1.100
# Test the redirect
curl -I http://twitter.com
# Should show: HTTP/1.1 301 Moved Permanently
# Location: https://xcancel.com/
chrome://net-internals/#dns or edge://net-internals/#dns and click “Clear host cache”about:networking#dns to view cache (restart browser to clear)sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder in Terminal# Check what DNS server your device is using
nslookup twitter.com
# "Server:" line shows which DNS answered
Some DNS servers don’t support wildcards in the way you configured them:
Solution: Add specific subdomains manually:
192.168.1.100 mobile.twitter.com
192.168.1.100 api.twitter.com
192.168.1.100 mobile.x.com
If you’re using DNSSEC validation, custom overrides may fail validation:
validate-except { "twitter.com"; "x.com"; };domain-insecure: "twitter.com"For best results:
If your router doesn’t support custom DNS and you don’t want to run a DNS server, the included dnsmasq container is your best option - see DNSMASQ_SETUP.md.