> For the complete documentation index, see [llms.txt](https://pshizhsysu.gitbook.io/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pshizhsysu.gitbook.io/linux/iptables/kuo-5c55-target/dnat.md).

# DNAT

## `-j DNAT [options]`

常用的`options`有

* `--to-destination [ipaddr[-ipaddr]][:port[-port]]`

这是一个`Terminating Target`

## 示例

* 只变IP

```
iptables -t nat -I OUTPUT -d 1.1.1.1 --to-destination 172.26.0.4
```

* 端口有变

由于只有部分协议（`TCP`、`UDP`、`DCCP`和`SCTP`）才有端口这个属性，所以在包含有端口时，必须指定协议类型；也就是说，这个包在匹配时，必须要匹配到上述四个扩展中的某一个

```
iptables -t nat -I OUTPUT -p tcp --to-destination 172.26.0.4:8080
```

上述的规则就会把从本机上所有进程发出去的TCP包，都转到`172.26.0.4:8080`去


---

# 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:

```
GET https://pshizhsysu.gitbook.io/linux/iptables/kuo-5c55-target/dnat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
