Xray-core icon indicating copy to clipboard operation
Xray-core copied to clipboard

How to block (TLD) Top level domain in routing?

Open unknown-qp opened this issue 2 years ago • 1 comments

Hi all, i want to block TLD and i don't know how to set this config for my server... for example, i want to set direct role for all domain like [ aaa.tk, aaa.xyz ] can you help me to fix this ?

its current my Xray Setup :

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "dns": {
    "hosts": {
      "dns.google": ["8.8.8.8","8.8.4.4"],
      "dns.pub": "119.29.29.29",
      "dns.alidns.com": "223.5.5.5",
      "geosite:category-ads-all": "127.0.0.1",
      "dns.cloudflare.com": "1.1.1.1",
      "aws.amazon.com":"169.254.169.253"
    },
    "servers": [
      {
        "address": "https://1.1.1.1/dns-query",
        "domains": ["geosite:geolocation-!cn"],
        "expectIPs": ["geoip:!cn"]
      },
      "1.1.1.1",
      {
        "address": "localhost",
        "skipFallback": true
      }
    ],
    "queryStrategy": "UseIP"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blocked"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByIp"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByDomain"
    }
  ],
  "policy": {
    "levels": {
      "0": {
        "handshake": 4,
        "connIdle": 300,
        "uplinkOnly": 2,
        "downlinkOnly": 5,
        "statsUserUplink": false,
        "statsUserDownlink": false,
        "bufferSize": 4
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "domainMatcher": "hybrid",
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:cn",
          "geoip:private"
        ],
        "outboundTag": "blockedByIp",
        "type": "field"
      },
      {
        "type": "field",
        "domain": [
          "geosite:category-ads-all",
          "geosite:geolocation-cn"
        ],
        "outboundTag": "blockedByDomain"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "domain": [
          "geosite:cn" 
        ]
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "ip": [
          "geoip:private",
          "geoip:cn"
        ]
      }
    ]
  },
  "stats": {}
}

unknown-qp avatar Nov 14 '22 14:11 unknown-qp

            {
                "type": "field",
                "domain": [
                    "regexp:.aaa.tk$"
                    "regexp:.aaa.xyz$"
                ],
                 "outboundTag": "blockedByDomain"
            },

reference : https://xtls.github.io/config/routing.html#ruleobject https://www.guru99.com/linux-regular-expressions.html

kingwilliam avatar Nov 15 '22 04:11 kingwilliam

close as solved

yuhan6665 avatar Nov 28 '22 04:11 yuhan6665