2. Palestrante
Hélio Loureiro
http://helio.loureiro.eng.br
<helio@loureiro.eng.br>
http://listas.cipsga.org.br/cgi-bin/mailman/listinfo/linux-br
Debian desde 2.0 (Hamm)
Moderador da lista linuxbr
Instrutor Conectiva
Soluções baseadas em *NIX
Atualmente em telecomunicações
Desenvolvimento de sistemas em C/Python/Java
Instalação e integração de redes GSM/GPRS, FEA e xDSL
3. Conteúdo
➢
Descrição do problema
➢
Possíveis soluções
➢
Seleção
➢
Explicação técnica
➢
Finalização
➢
Conclusão
NOTA: todos os endereços IP usados aqui
são fictícios.
7. Opções
"policy routing" linux
"policy routing" linux
Linux iptables/ipchains/iproute2 8.030 links
➢
FreeBSD ipfw/ipfw2/ipfilter 2.290 links
➢
OpenBSD ipfilter/pf 1.430 links
➢
Solaris ipfilter 2.048 links
➢
NetBSD ipfilter 1.320 links
➢
SCO (Unixware) ? 1.440 links
➢
Windows ? 5.200 links
➢
Linux ou OpenBSD?
8. Comparação
Linux
➢
iptables sintaxe muito flexível (complexa)
➢
iptables difícil padronização para criação script
➢
iproute2 fácil configuração para roteamento
➢
iproute2 estável!
OpenBSD
pf sintaxe simples (BSD)
➢
pf roteamento através dele
➢
pf recém lançado na versão 3.0
➢
Qual?
9. Informações da rede
Saída Embratel: Saída ADSL:
GW=200.2.1.1 GW=200.100.10.1
MASK=255.255.255.192 MASK=255.255.255.192
Interface eth0: Interface eth1:
IP=192.168.0.254 IP=10.0.0.254
MASK=255.255.255.0 MASK=255.255.255.0
Interface eth2: Interface eth3:
IP=200.1.2.10 IP=200.100.10.56
MASK=255.255.255.192 MASK=255.255.255.192
route add default gw 200.2.11
Servidor de mail/pop3/imap/webmail
acessível pelos dois links
10. Solução de rede
NAT eth2 NAT
eth3
10/24
eth1 eth0
PAT
Migração da DMZ por partes (máquina a máquina)
11. TCPPORTS="{20, 21}"
UDPPORTS="{20, 1024, 4000}"
INT="{xl0, xl1}"
EXT="{xl2, xl3}"
FW="{200.100.10.56, 200.1.2.20, 192.168.0.254, 10.0.0.254}"
HELIO="{200.207.129.199, 200.10.20.30}"
block in log all
scrub in all
pass out all keep state
pass out inet proto tcp from any to any keep state
pass in quick on $EXT proto tcp from $HELIO to $FW port 22 flags S/SA keep state
pass in quick on $EXT proto tcp from $HELIO to $FW port 22 flags A/SA keep state
pass in quick proto udp from any to any port 53 keep state
pass in on $EXT inet proto tcp from any to $MAILSERVER port 25 flags S/SA modulate state
pass in on $EXT inet proto tcp from any to $MAILSERVER port 80 flags S/SA modulate state
pass in on $EXT proto udp from any port 53 to $FW keep state
pass in on xl0 fastroute from 192.168.0.0/24 to $DMZ keep state
pass in on xl0 fastroute from 192.168.0.0/24 to $EXTERNAL keep state
pass in on xl0 route-to xl3:200.100.10.1 from 192.168.0.0/24 to any keep state
Sistema travava!!!
14. Referências sobre roteamento
Ethernet, Frame Relay e ATM
RIP, OSPF, BGP e
ISIS
Linux Networking HOWTO.
Redes de Computadores; Andrew Tanenbaum.
Redes de computadores: das Lans, Mans e Wans às redes ATM; Soares, Lemos e Colcher.
http://www.cisco.com
http://www.zebra.com
15. Preparando o kernel
[*] Prompt for development and/or incomplete
code/drivers
---
[*] TCP/IP Networking
[*] Networking packet filtering (replaces ipchains)
[*] Networking packet filtering debugging
[*] Socket Filtering
---
[*] IP: advanced router
[*] IP: policy routing
[*] IP: use netfilter MARK value as routing key
[*] IP: fast network address translation
[*] IP: equal cost multipath
[*] IP: use TOS value as routing key
[*] IP: verbose route monitoring
[*] IP: large routing tables
Use kernel-package
17. ip link
Usado para verificar e/ou configurar o endereço físico (MAC) das
interfaces de rede. Aceita as opções show e set.
router:~# ip link show
1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:04:75:7a:73:63 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:04:75:7a:73:8e brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:04:75:7a:73:31 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:04:75:7a:73:a4 brd ff:ff:ff:ff:ff:ff
18. ip addr
Usado para interagir com as interfaces de rede. Aceita as opções list,
add e del entre outras.
router~# ip addr list
1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:10:5a:9b:1e:fd brd ff:ff:ff:ff:ff:ff
inet 192.168.254.200/24 brd 192.168.254.255 scope global eth0
144: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP> mtu 1492 qdisc pfifo_fast qlen 3
link/ppp
inet 200.158.236.157 peer 200.207.246.240/32 scope global ppp0
19. ip route
Usado para verificar e/ou configurar as rotas estáticas da rede.
Aceita as opções list, flush, add, e del entre outros.
router:~# ip route list
200.1.2.0/26 dev eth2 proto kernel scope link src 200.1.2.20
200.100.10.0/26 dev eth3 proto kernel scope link src 200.100.10.56
10.0.0.0/24 dev eth1 proto kernel scope link src 10.0.0.254
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.254
default via 200.1.2.1 dev eth2
22. /etc/init.d/iproute
#! /bin/sh
ip route add default via 200.100.10.1 table dmznet
ip rule add from 192.168.0.0/24 table dmznet
ip route add 192.168.0.0/24 via 192.168.0.254 table dmznet
ip rule add from 200.100.10.0/26 table dmznet
ip addr add 200.1.2.3/26 dev eth2
ip addr add 200.1.2.4/26 dev eth2
ip addr add 200.1.2.5/26 dev eth2
ip addr add 200.1.2.7/26 dev eth2
ip addr add 200.1.2.14/26 dev eth2
ip addr add 200.1.2.15/26 dev eth2
ip addr add 200.1.2.27/26 dev eth2
ip addr add 200.1.2.62/26 dev eth2
ip rule add from 192.168.0.0/24 to 200.1.2.0/26 table dmznet
ip route add 200.1.2.0/26 via 200.1.2.20 table dmznet
ip route add 10.0.0.0/24 via 10.0.0.254 table dmznet
ip rule add from 10.0.0.11/32 table dmznet
23. table dmznet
rota default
gw: 200.100.10.1
from 200.100.10/26
from 192.168/24 eth2 eth3 from 192.168/24
to 200.1.2.0/26
eth1 eth0
from 10.0.0.11/32
24. Alterando rotas
#! /bin/sh
case $1 in
start|speedy)
echo "Roteando Intranet pelo link Speedy"
ip route del default via 200.1.2.1 table dmznet
ip route add default via 200.100.10.1 table dmznet
echo "Iniciando regras de firewall"
/etc/init.d/firewall start
;;
stop|embratel)
echo "Roteando Intranet pelo link Embratel"
ip route del default via 200.100.10.1 table dmznet
ip route add default via 200.1.2.1 table dmznet
echo "Desligando regras de firewall"
/etc/init.d/firewall stop
;;
restart)
$0 stop
$0 start
;;
*)
echo "Use: $0 {start|speedy|stop|embratel|restart}"
esac
27. Conclusão
Fechar requisitos já na proposta com o cliente.
Deixar claros os "testes de aceitação".
Não utilizar partes "móveis" no firewall.
Evitar apache, bind e mail.
Linux tem implementação mais facilitada
para roteamento e substitui com vantagens
um roteador (Cisco, Cyclades, IBM, etc).
Fazer ACL no firewall/router.
Opções avançadas de roteamento melhor
suportadas no Linux.
Projeto iniciado em novembro de 2002.
Finalizado em julho de 2003.
Tempo inicialmente previsto para implementação: 2 meses.