> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/integrations/cn/proxy-integrations/ubuntu.md).

# Ubuntu

使用 GNOME 设置或终端在 Ubuntu 上配置 Oxylabs 代理。系统级代理设置分步指南。

[**Ubuntu**](https://ubuntu.com/) 是 Linux 上面向企业服务器、桌面、云和 IoT 的开源软件操作系统。

在 Ubuntu 上设置代理服务器有多种方法。在本指南中，你会找到两种常见方法： [使用系统（GNOME）设置](#method-1-system-settings) 并 [使用终端](#method-2-terminal-sessions)适用于以下 Oxylabs 代理类型：

* **住宅代理和移动代理**
* **数据中心代理**
* **独享数据中心代理（企业版）**
* **独享数据中心代理（自助服务版）**
* **ISP代理**
* **独享ISP代理**

## 方法 1：系统设置

要设置系统范围的网络代理，请按以下步骤操作：

### **步骤 1**

[**下载**](https://ubuntu.com/download/desktop) 并安装 Ubuntu Desktop。

### **步骤 2**

找到 **设置** 在 Ubuntu 启动器中，并转到 **网络** 选项卡。

<figure><img src="https://1216392379-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU4lV7kLC2Df45W0aLQlX%2Fuploads%2Fgit-blob-6029cd9f36e3a75076a144570f7c9bdd37289d58%2Fimage.png?alt=media" alt="Network"><figcaption></figcaption></figure>

### **步骤 3**

一旦你点击 **网络**，它会打开一个新对话框。在这三个选项中，选择 **网络代理。**

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiwDdoZGfMbUe5cRL2417%2Fuploads%2F0QpbIwlPPRIdIB3jYFza%2Fimage.png?alt=media&#x26;token=e78a2185-2744-409b-9ae8-5f0307963093" alt="Network"><figcaption></figcaption></figure>

### **步骤 4**

选择 **手动** 来配置代理设置。接下来，会弹出几个文本框，你可以在其中设置 `HTTP`, `HTTPS`，或 `SOCKS` 代理。请填写你所选代理类型的详细信息：

* [**住宅代理和移动代理**](#residential-and-mobile-proxies)
* [**数据中心代理**](#datacenter-proxies)
* [**独享数据中心代理（企业版）**](#dedicated-datacenter-proxies-enterprise)
* [**独享数据中心代理（自助服务版）**](#dedicated-datacenter-proxies-self-service)
* [**ISP代理**](#isp-proxies)
* [**独享ISP代理**](#dedicated-isp-proxies)

#### 住宅代理和移动代理

**可用协议：** `HTTP`, `HTTPS`, `SOCKS5`

**主机/IP**: `pr.oxylabs.io`

**端口**: `7777`

<figure><img src="https://1216392379-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU4lV7kLC2Df45W0aLQlX%2Fuploads%2Fgit-blob-8252285ac4fa39bab4d7f653ad9a78620624af6a%2Fimage.png?alt=media" alt="Network Proxy" width="563"><figcaption></figcaption></figure>

你还可以使用 **附加参数** 搭配住宅代理和移动代理来设置地理位置（国家/地区、州、省、市等）并控制会话。查看 [住宅代理文档](/products/cn/proxies/residential-proxies.md) 以了解更多。

#### 数据中心代理

**可用协议：** `HTTP`, `HTTPS`, `SOCKS5`

**主机/IP：** `dc.oxylabs.io`

**端口：** `8001`

<figure><img src="https://1216392379-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU4lV7kLC2Df45W0aLQlX%2Fuploads%2Fgit-blob-03dc9536bc8108bf53adec9f5a46ba62dda6c707%2Fubuntu-dc.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

{% tabs %}
{% tab title="按 IP 计费订阅" %}
端口是分配给来自 [代理列表](/products/cn/proxies/datacenter-proxies/proxy-list.md)的 IP 地址的顺序编号。因此，端口 `8001` 将始终使用你列表中的第一个 IP 地址。你也可以通过将端口设置为 [代理 IP 轮换](/products/cn/proxies/datacenter-proxies/ip-control.md) 来启用 `8000`.

此外，你还可以指定 [地理位置](/products/cn/proxies/datacenter-proxies/select-country.md)，例如美国，方法是将 **代理用户名** 设置为 `user-USERNAME-country-US`.
{% endtab %}

{% tab title="按流量计费订阅" %}
该端口 `8001` 会随机选择一个 IP 地址，但在会话期间保持一致。或者，你可以通过使用端口 [轮换代理 IP](/products/cn/proxies/datacenter-proxies/ip-control.md) 来在每个请求中更换 IP `8000`.

如果你想使用特定的 [地理位置](/products/cn/proxies/datacenter-proxies/select-country.md)，例如美国，请将代理用户名设置为 `user-USERNAME-country-US`.
{% endtab %}
{% endtabs %}

#### 独享数据中心代理（企业版）

**可用协议：** `HTTP`, `SOCKS5`

**主机/IP：** `1.2.3.4` （来自你的 [代理列表](/products/cn/proxies/dedicated-datacenter-proxies/enterprise/proxy-lists.md))

**端口：** `60000` （HTTP）或 `1180` (SOCKS5)

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiwDdoZGfMbUe5cRL2417%2Fuploads%2Fj415y9XFS32RYS9BaV9H%2Fimage.png?alt=media&#x26;token=7d2e8572-e17e-484a-87ba-4d1022b7ad76" alt="Configuring proxy" width="563"><figcaption></figcaption></figure>

对于通过销售购买的企业独享数据中心代理，你必须从已获取的 [代理列表](/products/cn/proxies/dedicated-datacenter-proxies/enterprise/proxy-lists.md).

#### 独享数据中心代理（自助服务版）

**可用协议：** `HTTP`, `HTTPS`, `SOCKS5`

**主机/IP：** `ddc.oxylabs.io`

**端口：** `8001`

<figure><img src="https://1216392379-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU4lV7kLC2Df45W0aLQlX%2Fuploads%2Fgit-blob-fcd58251224742b48f4e7020eabcaaebfa9ec736%2Fubuntu-ddc-ss.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

对于通过 Oxylabs 控制面板购买的自助服务独享数据中心代理，端口表示来自已获取的某个 IP 地址的顺序编号 [代理列表](/products/cn/proxies/datacenter-proxies/proxy-list.md)。如果你希望每个请求都获取不同的 IP，请更改 **端口** 设置为 `8000` 以启用 [代理轮换](/products/cn/proxies/dedicated-datacenter-proxies/self-service/proxy-rotation.md).

#### ISP代理

**可用协议：** `HTTP`, `HTTPS`, `SOCKS5`

**主机/IP**: `isp.oxylabs.io`

**端口**: `8001`

<figure><img src="https://1216392379-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU4lV7kLC2Df45W0aLQlX%2Fuploads%2Fgit-blob-984b308f02db703a2cc2ed80d672211d5c8a6ab3%2Fubuntu-isp.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

ISP 代理会将每个端口分配给特定的 IP 地址和位置。端口 `8001` 始终使用你的 [代理列表](/products/cn/proxies/isp-proxies/proxy-list.md)中的第一个 IP。使用端口 `8000` 以启用 [代理轮换](/products/cn/proxies/isp-proxies/proxy-rotation.md).

若要从特定国家的代理池获取轮换 IP，请按以下格式设置用户名： `user-USERNAME-country-XX`，其中 `XX` 是国家代码（例如 `US` 表示美国）。

#### 独享ISP代理

**可用协议：** `HTTP`, `HTTPS`, `SOCKS5`

**主机/IP**: `disp.oxylabs.io`

**端口**: `8001`

<figure><img src="https://1216392379-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU4lV7kLC2Df45W0aLQlX%2Fuploads%2Fgit-blob-076c633a74dd716ca8ee93dc5580ba7243fd12a5%2Fubuntu-1.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

您需要选择分配给所购买的 IP 地址的端口 [代理列表](/products/cn/proxies/dedicated-isp-proxies/self-service/proxy-list.md)，你可以在 Oxylabs 控制面板中找到。 `8001` 端口将为所有请求选取列表中的第一个 IP 地址。使用端口 `8000` 可自动进行 [代理 IP 轮换](/products/cn/proxies/dedicated-isp-proxies/self-service/proxy-rotation.md).

### **步骤 5**

关闭“网络代理”窗口。更改会自动保存，系统范围的代理将被激活。

每次你通过浏览器或其他应用发起网页请求时， **弹出窗口都会提示你输入会话的凭据** ，即你的 Oxylabs 代理用户凭据。输入相应的代理凭据（通过 [Oxylabs 控制面板](https://dashboard.oxylabs.io)):

| 代理类型           | 示例                                                                                                           |
| -------------- | ------------------------------------------------------------------------------------------------------------ |
| 住宅代理和移动代理      | <p><strong>用户名：</strong> <code>customer-USERNAME</code></p><p><strong>密码：</strong> <code>PASSWORD</code></p> |
| 数据中心代理         | <p><strong>用户名：</strong> <code>user-USERNAME</code></p><p><strong>密码：</strong> <code>PASSWORD</code></p>     |
| 独享数据中心代理（企业版）  | <p><strong>用户名：</strong> <code>USERNAME</code></p><p><strong>密码：</strong> <code>PASSWORD</code></p>          |
| 独享数据中心代理（自助服务） | <p><strong>用户名：</strong> <code>user-USERNAME</code></p><p><strong>密码：</strong> <code>PASSWORD</code></p>     |
| ISP代理          | <p><strong>用户名：</strong> <code>user-USERNAME</code></p><p><strong>密码：</strong> <code>PASSWORD</code></p>     |
| 独享ISP代理        | <p><strong>用户名：</strong> <code>user-USERNAME</code></p><p><strong>密码：</strong> <code>PASSWORD</code></p>     |

{% hint style="warning" %}
请务必添加 `customer-` 或 `user-` 如果您的代理类型需要，请为您的用户名添加前缀。
{% endhint %}

## 方法 2：终端会话

要为所有终端会话设置网络代理，请按以下步骤操作：

### **步骤 1**

[**下载**](https://ubuntu.com/download/desktop) 并安装 Ubuntu Desktop。

### **步骤 2**

打开 **shell** 使用编辑器进行配置。对于 ZSH 终端，shell 配置文件默认位于主目录中。我们可以使用 `vim` 以及下面的命令来编辑该文件：

```sh
vim ~/.zshrc
```

而不是 `vim`，你也可以使用 `gedit`, `nano`，或任何你喜欢的其他文本编辑器。另外，如果你使用 Bash 而不是 ZSH，你需要编辑你的 bash shell 配置文件，即 `~/.bashrc` 而不是 `~/.zshrc`.

### **步骤 3**

创建新的环境变量。在此配置文件底部，你需要定义 `http_proxy,` `https_proxy`，或 `ALL_PROXY` （用于 SOCKS5）变量。

```sh
export http_proxy="username:password@host:port"
export https_proxy="username:password@host:port"
export ALL_PROXY="socks5://username:password@host:port"
```

然后为你所选代理类型调整详细信息：

* [住宅代理和移动代理](#residential-and-mobile-proxies-1)
* [数据中心代理](#datacenter-proxies-1)
* [独享数据中心代理（企业版）](#dedicated-datacenter-proxies-enterprise-1)
* [独享数据中心代理（自助服务版）](#dedicated-datacenter-proxies-self-service-1)
* [ISP代理](#isp-proxies)
* [独享ISP代理](#dedicated-isp-proxies-1)

#### 住宅代理和移动代理

**主机：** `pr.oxylabs.io`

**端口：** `7777`

**用户名：** `customer-username`

**密码：** `password`

{% hint style="warning" %}
不要忘记在您的用户名中添加 `customer-` 部分到你的用户名中。
{% endhint %}

你还可以使用 **附加参数** 搭配住宅代理和移动代理来设置地理位置（国家/地区、州、省、市等）并控制会话。查看 [住宅代理文档](/products/cn/proxies/residential-proxies.md) 以了解更多。

#### 数据中心代理

**主机：** `dc.oxylabs.io`

**端口：** `8001`

**用户名：** `user-username`

**密码：** `password`

{% hint style="warning" %}
不要忘记在您的用户名中添加 `user-` 部分到你的用户名中。
{% endhint %}

{% tabs %}
{% tab title="按 IP 计费订阅" %}
端口是分配给来自 [代理列表](/products/cn/proxies/datacenter-proxies/proxy-list.md)的 IP 地址的顺序编号。因此，端口 `8001` 将始终使用你列表中的第一个 IP 地址。你也可以通过将端口设置为 [代理 IP 轮换](/products/cn/proxies/datacenter-proxies/ip-control.md) 来启用 `8000`.

此外，你还可以指定 [地理位置](/products/cn/proxies/datacenter-proxies/select-country.md)，例如美国，方法是将 **代理用户名** 设置为 `user-USERNAME-country-US`.
{% endtab %}

{% tab title="按流量计费订阅" %}
该端口 `8001` 会随机选择一个 IP 地址，但在会话期间保持一致。或者，你可以通过使用端口 [轮换代理 IP](/products/cn/proxies/datacenter-proxies/ip-control.md) 来在每个请求中更换 IP `8000`.

如果你想使用特定的 [地理位置](/products/cn/proxies/datacenter-proxies/select-country.md)，例如美国，请将代理用户名设置为 `user-USERNAME-country-US`.
{% endtab %}
{% endtabs %}

#### 独享数据中心代理（企业版）

**主机：** `1.2.3.4` （来自你的 [代理列表](/products/cn/proxies/dedicated-datacenter-proxies/enterprise/proxy-lists.md))

**端口：** `60000` (HTTP), `1180` (SOCKS5)

**用户名：** `username`

**密码：** `password`

对于通过销售购买的企业独享数据中心代理，你必须从已获取的 [代理列表](/products/cn/proxies/dedicated-datacenter-proxies/enterprise/proxy-lists.md).

#### 独享数据中心代理（自助服务版）

**主机：** `ddc.oxylabs.io`

**端口：** `8001`

**用户名：** `user-username`

**密码：** `password`

{% hint style="warning" %}
不要忘记在您的用户名中添加 `user-` 部分到你的用户名中。
{% endhint %}

对于通过 Oxylabs 控制面板购买的自助服务独享数据中心代理，端口表示来自已获取的某个 IP 地址的顺序编号 [代理列表](/products/cn/proxies/datacenter-proxies/proxy-list.md)。如果你希望每个请求都获取不同的 IP，请更改 **端口** 设置为 `8000` 以启用 [代理轮换](/products/cn/proxies/dedicated-datacenter-proxies/self-service/proxy-rotation.md).

#### ISP代理

**主机：** `isp.oxylabs.io`

**端口：** `8001`

**用户名：** `user-username`

**密码：** `password`

{% hint style="warning" %}
不要忘记在您的用户名中添加 `user-` 部分到你的用户名中。
{% endhint %}

ISP 代理会将每个端口分配给特定的 IP 地址和位置。端口 `8001` 始终使用你的 [代理列表](/products/cn/proxies/isp-proxies/proxy-list.md)中的第一个 IP。使用端口 `8000` 以启用 [代理轮换](/products/cn/proxies/isp-proxies/proxy-rotation.md).

若要从特定国家的代理池获取轮换 IP，请按以下格式设置用户名： `user-USERNAME-country-XX`，其中 `XX` 是国家代码（例如 `US` 表示美国）。

#### 独享ISP代理

**主机：** `disp.oxylabs.io`

**端口：** `8001`

**用户名：** `user-username`

**密码：** `password`

{% hint style="warning" %}
不要忘记在您的用户名中添加 `user-` 部分到你的用户名中。
{% endhint %}

您需要选择分配给所购买的 IP 地址的端口 [代理列表](/products/cn/proxies/dedicated-isp-proxies/self-service/proxy-list.md)，你可以在 Oxylabs 控制面板中找到。 `8001` 端口将为所有请求选取列表中的第一个 IP 地址。使用端口 `8000` 可自动进行 [代理 IP 轮换](/products/cn/proxies/dedicated-isp-proxies/self-service/proxy-rotation.md).

### **步骤 4**

可以通过打开一个新的终端，或在当前终端中运行以下命令来重新加载配置文件：

```sh
source ~/.zshrc
```

该代理将始终对当前用户生效。每次你打开新终端时，shell 配置文件都会被加载。因此，即使你重启电脑，环境变量也会一直可用。

如果你想为所有用户启用它，那么你需要把上面两行追加到 `/etc/environment`.

就这样！你已经成功集成了你的 Oxylabs 代理。

你可以找到完整教程 [此处](https://oxylabs.io/resources/integrations/ubuntu).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/integrations/cn/proxy-integrations/ubuntu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
