Clash配置文件,clash.conf

基础配置:简单的路由和防火墙

这是一个最基本的配置示例,用于将流量路由到指定的网络接口或防火墙规则。

# 定义接口
interfaces:
  - name: eth
    type: eth
    mac: 00:1a:2b:3c:4d:5e
    mtu: 150
  - name: eth1
    type: eth
# 定义路由规则
rules:
  - rule: in-interface eth
    action: accept
  - rule: in-interface eth1
    action: accept
  - rule: destination 0.../
    action: accept
  - rule: source 0.../
    action: accept
# 定义防火墙规则(如果需要)
firewall:
  - rule: in-interface eth
    action: reject
  - rule: in-interface eth1
    action: reject

高级配置:流量监控和过滤

以下是一个更复杂的配置示例,用于监控和过滤网络流量。

# 接口配置
interfaces:
  - name: eth
    type: eth
    mac: 00:1a:2b:3c:4d:5e
    mtu: 150
# 定义流量监控规则
rules:
  - rule: in-interface eth
    action: count
    statistic: bytes
    destination: 0.../
  - rule: in-interface eth
    action: count
    statistic: packets
    destination: 0.../
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: reject
    statistic: packets
    destination: 0.../
# 定义路径(路由)
routes:
  - destination: 192.168.1./24
    interface: eth
    via: 192.168.1.1

配置限流器

以下是一个限流器的配置示例,用于限制某些地址或端口的访问流量。

# 定义限流规则
rules:
  - rule: destination 192.168.1./24
    action: limit
    count: 100
    statistic: bytes
    dscp: 0xf
  - rule: destination 808
    action: limit
    count: 100
    statistic: packets
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: reject
    statistic: packets
    destination: 0.../

使用插件扩展功能

Clash 提供了插件系统,可以扩展其功能,以下是一个使用插件的配置示例:

1 使用限流插件

Clash 提供了一个内置的限流插件,可以限制某些地址或端口的流量。

plugins:
  - name: limit
    settings:
      - rule: destination 192.168.1./24
        action: limit
        count: 100
        statistic: bytes
        dscp: 0xf
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: reject
    statistic: packets
    destination: 0.../

2 使用黑洞防护插件

Blackhole 插件可以过滤掉不必要的流量。

plugins:
  - name: blackhole
    settings:
      - rule: in-interface eth
        action: drop
        statistic: packets
        destination: 0.../
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: accept
    statistic: packets
    destination: 0.../

使用DNS过滤插件

Clash 提供了 DNS 插件,可以过滤 DNS 流量。

plugins:
  - name: dns
    settings:
      - rule: destination 53
        action: drop
        statistic: packets
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: accept
    statistic: packets
    destination: 0.../

使用负载均衡插件

Clash 提供了负载均衡插件,可以将流量分发到多个后端服务器。

plugins:
  - name: loadbalancer
    settings:
      - rule: destination 80
        action: loadbalance
        statistic: packets
        # 后端服务器地址和权重
        servers:
          - address: 192.168.1.1
            weight: 1
          - address: 192.168.1.2
            weight: 1
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: accept
    statistic: packets
    destination: 0.../

使用ARP插件

Clash 提供了ARP插件,可以控制局域网中的ARP请求和响应。

plugins:
  - name: arp
    settings:
      - rule: in-interface eth
        action:arp
        statistic: packets
        target: 192.168.1.1
        type: request
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: accept
    statistic: packets
    destination: 0.../

使用IP转发插件

Clash 提供了IP转发插件,可以将流量转发到指定的接口。

plugins:
  - name: ipforward
    settings:
      - rule: in-interface eth
        action:forward
        statistic: packets
        destination: 0.../
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: accept
    statistic: packets
    destination: 0.../

使用NAT插件

Clash 提供了NAT插件,可以配置网络地址转换。

plugins:
  - name: nat
    settings:
      - rule: in-interface eth
        action:nat
        statistic: packets
        source: 192.168.1./24
        destination: 0.../
        snat: 192.168.1.1
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: accept
    statistic: packets
    destination: 0.../

使用流量统计插件

Clash 提供了流量统计插件,可以统计网络流量的使用情况。

plugins:
  - name: statistics
    settings:
      - rule: in-interface eth
        action: count
        statistic: bytes
        destination: 0.../
# 定义防火墙规则
firewall:
  - rule: in-interface eth
    action: accept
    statistic: packets
    destination: 0.../

使用DNS过滤插件

Clash 提供了DNS过滤插件,可以过滤DNS流量。

plugins:
  - name: dns
    settings:
      - rule: destination 53
        action: drop
        statistic: packets
# 定义防火墙规则
firewall:
  - rule

Clash配置文件,clash.conf

@版权声明

转载原创文章请注明转载自原子VPN|多平台网络连接与线路优化工具,支持节点切换、网络测速及电脑手机端使用,满足不同网络环境下的连接需求,网站地址:https://yuanziapp.com.cn/