> For the complete documentation index, see [llms.txt](https://darren.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://darren.gitbook.io/project/k8s-xi-tong-wan-zheng-bu-shu/curl-ming-ling-huo-qu-ben-ji-wai-wang-ip.md).

# cURL 命令获取本机外网 IP

1\. 查询本机外网 IP

#### 1.1 输出格式为 JSON <a href="#id-11-shu-chu-ge-shi-wei-json" id="id-11-shu-chu-ge-shi-wei-json"></a>

```
# curl api.dhcp.cn/?json

{
  "IP": "134.175.159.160",
  "Address": {
    "Country": "中国",
    "Province": "广东省",
    "City": "广州市"
  },
  "ISP": "电信"
}
```

#### 1.2 输出格式为 YAML (Defalut) <a href="#id-12-shu-chu-ge-shi-wei-yamldefalut" id="id-12-shu-chu-ge-shi-wei-yamldefalut"></a>

```
# curl api.dhcp.cn/?yaml

IP: 134.175.159.160
Address:
  Country: 中国
  Province: 广东省
  City: 广州市
ISP: 电信
```

#### 1.3 输出格式为 IP <a href="#id-13-shu-chu-ge-shi-wei-ip" id="id-13-shu-chu-ge-shi-wei-ip"></a>

```
# curl api.dhcp.cn/?ip

134.175.159.160
```

#### 1.4 输出格式为 CSV <a href="#id-14-shu-chu-ge-shi-wei-csv" id="id-14-shu-chu-ge-shi-wei-csv"></a>

```
# curl api.dhcp.cn/?csv

134.175.159.160,中国,广东省,广州市,电信
```

### 2. 查询指定 IP <a href="#id-2-cha-xun-zhi-ding-ip" id="id-2-cha-xun-zhi-ding-ip"></a>

```
# dhcp.cn/?ip=134.175.159.160

IP: 134.175.159.160
Address:
  Country: 中国
  Province: 广东省
  City: 广州市
ISP: 电信
```
