manuais-e-documentacao-itguys/documentacao linux/[Nível 2] Configuração de R...

130 lines
4.1 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# MANUAL TÉCNICO - CONFIGURAÇÃO DE REDE E FIREWALL
**Código:** ITGINF 0011/26 | **Classificação:** RESTRITO
**Responsável:** João Pedro Toledo Gonçalves | **Data:** {{DATA_ATUAL}}
## 1. HISTÓRICO DE REVISÃO
| Data | Versão | Descrição | Autor |
| :--- | :--- | :--- | :--- |
| {{DATA_ATUAL}} | 1.0 | Criação Inicial | João Pedro Toledo Gonçalves |
## 2. OBJETIVO
Definir procedimentos para configuração de Endereçamento IP estático, DNS e regras de Firewall em servidores Linux, respeitando as ferramentas nativas de cada distribuição.
## 3. PRÉ-REQUISITOS
* [ ] Acesso console (preferencial) ou SSH (Cuidado para não se bloquear ao alterar IP/Firewall).
* [ ] Dados da Rede: IP, Máscara (CIDR), Gateway e DNS definidos.
---
## 4. CONFIGURAÇÃO DE REDE (IP ESTÁTICO)
### Ubuntu 24.04 (Netplan)
O Ubuntu usa arquivos YAML no Netplan.
1. Edite o arquivo em `/etc/netplan/`. Ex: `00-installer-config.yaml`.
```bash
sudo nano /etc/netplan/00-installer-config.yaml
```
2. Modelo de Configuração:
```yaml
network:
version: 2
ethernets:
ens160: # Nome da interface (verifique com 'ip link')
dhcp4: no
addresses:
- 192.168.1.10/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
```
3. Aplique: `sudo netplan apply`
### Debian 11/12 (Interfaces)
Edição clássica do arquivo interfaces.
1. Arquivo: `/etc/network/interfaces`
```bash
auto ens192
iface ens192 inet static
address 192.168.1.10/24
gateway 192.168.1.1
dns-nameservers 8.8.8.8 1.1.1.1
```
2. Reinicie a rede: `sudo systemctl restart networking`
### RHEL / AlmaLinux / Rocky (NetworkManager)
Recomendado usar `nmcli` (Linha de Comando do Network Manager).
1. Listar conexões: `nmcli con show`
2. Definir IPv4 Manual:
```bash
sudo nmcli con mod "ens192" ipv4.addresses 192.168.1.10/24
sudo nmcli con mod "ens192" ipv4.gateway 192.168.1.1
sudo nmcli con mod "ens192" ipv4.dns "8.8.8.8,1.1.1.1"
sudo nmcli con mod "ens192" ipv4.method manual
```
3. Reiniciar interface: `sudo nmcli con up "ens192"`
### Alpine Linux (/etc/network/interfaces)
O Alpine usa o sistema clássico `ifupdown`.
1. Edite `/etc/network/interfaces`:
```bash
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
```
2. Configure o DNS em `/etc/resolv.conf`:
```
nameserver 8.8.8.8
```
3. Reinicie a rede: `rc-service networking restart`
---
## 5. CONFIGURAÇÃO DE FIREWALL
### Ubuntu / Debian / Alpine (UFW - Uncomplicated Firewall)
Mais simples e recomendado. No Alpine, instale com `apk add ufw`.
1. **Status:** `sudo ufw status`
2. **Habilitar:** `sudo ufw enable` (CUIDADO: Libere o SSH antes!).
3. **Liberar SSH:** `sudo ufw allow 22/tcp`
4. **Liberar Web:** `sudo ufw allow 80/tcp`
5. **Bloquear tudo (Default):** O UFW já bloqueia entrada por padrão.
6. **Remover regra:** `sudo ufw delete allow 80/tcp`
> **NOTA ALPINE:** Se preferir o firewall nativo, investigue o `awall` (Alpine Wall), mas o UFW funciona perfeitamente para regras básicas.
### RHEL / CentOS (Firewalld)
Gerenciador dinâmico padrão do mundo Red Hat.
1. **Status:** `sudo firewall-cmd --state`
2. **Listar regras (Zona Padrão):** `sudo firewall-cmd --list-all`
3. **Liberar Porta (Permanente):**
```bash
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
```
4. **Liberar Serviço:** `sudo firewall-cmd --permanent --add-service=http`
## 6. DADOS TÉCNICOS
| Ferramenta | Arquivo Config | Serviço |
| :--- | :--- | :--- |
| **Netplan** | `/etc/netplan/*.yaml` | `systemd-networkd` |
| **Ifupdown** | `/etc/network/interfaces` | `networking` |
| **NetworkManager** | `/etc/NetworkManager/` | `NetworkManager` |
## 7. VALIDAÇÃO FINAL
- [ ] O comando `ip addr` mostra o IP correto?
- [ ] O comando `ping 8.8.8.8` funciona (Gateway/Rota ok)?
- [ ] O comando `ping google.com` funciona (DNS ok)?
- [ ] O acesso SSH continua funcionando após ligar o firewall?