# NAT in VyOS

> NAT in VyOS: Source NAT, Destination NAT, port forwarding, 1:1 NAT, hairpin NAT and NAT exclusions for VPN tunnels in Yandex Cloud and VK Cloud

Source: https://opennix.org/en/docs/vyos/nat/


Network Address Translation (NAT) lets you rewrite the IP addresses in packets as they pass through the router.

## Section contents

### [NAT Configuration](vyos-nat)
A complete guide to configuring NAT in VyOS.

**NAT types:**
- **Source NAT (SNAT)** - rewrites the source address (for internet access)
- **Destination NAT (DNAT)** - rewrites the destination address (port forwarding)
- **Masquerade** - SNAT with automatic detection of the external IP
- **1:1 NAT** - a static mapping between an internal and an external IP

---

## Common scenarios

### SNAT/Masquerade
Providing internet access for an internal network.

### Port Forwarding
Forwarding external ports to internal servers (DNAT).

### 1:1 NAT
Publishing an internal server behind an external static IP.

---

## Quick example

### Source NAT (Masquerade)
```bash
set nat source rule 100 outbound-interface name eth0
set nat source rule 100 source address 192.168.1.0/24
set nat source rule 100 translation address masquerade
```

### Port Forwarding (DNAT)
```bash
set nat destination rule 100 destination port 80
set nat destination rule 100 inbound-interface name eth0
set nat destination rule 100 protocol tcp
set nat destination rule 100 translation address 192.168.1.10
```

---

## Additional resources

- [VyOS NAT Documentation](https://docs.vyos.io/en/latest/configuration/nat/)

