---
url: /configuration/outbound/socks.md
description: 通过 SOCKS4/SOCKS5 服务器出站
---

# socks

经由 SOCKS 服务器建立连接；默认 SOCKS5，也可使用 SOCKS4/4a。

```yaml check
outbounds:
  proxy:
    type: socks
    server: proxy.example:1080
    version: socks5

route:
  final: proxy

dns:
  servers:
    default: {type: udp, address: 127.0.0.1:53}
  final: default
```

## 字段

### type

* 类型：字符串。
* 必填：是，第一项。
* 取值：`socks`。

### server

* 类型：端点。
* 必填：是。
* 默认端口：`443`。

### tls

* 类型：[TLS 客户端占位页](/configuration/shared/tls-client)。
* 必填：可选。
* 默认：明文 SOCKS。
* 限制：显式 TLS 只在 Linux 上可用；其他平台写它会报错。

### version

* 类型：字符串枚举。
* 默认：`socks5`。
* 取值：`socks5`、`socks4`。
* 行为：`socks4` 遇主机名时使用 SOCKS4a。

### username

* 类型：字符串。
* 必填：可选。

### password

* 类型：字符串。
* 必填：可选。
* 行为：有用户名时作为密码，没有时视为空。

## 说明

SOCKS5 原生承载 UDP；SOCKS4 没有原生 UDP，默认改走 `over-tcp`。可以通过 `transport` 再套受支持的 stream transport。

## 相关

* [出站总览](/configuration/outbound/)
* [共享 TLS 客户端](/configuration/shared/tls-client)
* [共享 UDP](/configuration/shared/udp)
