NOTA: Devido a alterações no kernel Linux, esta página foi alterada em relação à antiga, disponível aqui.
Para aumentar a segurança relativamente a pacotes com endereço IP de
origem forjados (frequentes em ataques DDoS), o
kernel Linux permite, opcionalmente, filtrar pacotes recebidos por uma
interface que não é a que seria usada para enviar pacotes para o endereço IP de
origem do pacote recebido. Esta opção controla-se através da variável
rp_filter
(ver abaixo). Uma outra variável relacionada,
log_martians
, indica que deve registar-se nos logs do
sistema a chegada de pacotes nessas condições.
Pelo facto de esta filtragem causar problemas em situações em que é legítimo
existirem caminhos assimétricos, como é o caso do
trabalho 1, o valor-padrão da variável
rp_filter
é 0, desactivando a filtragem. No entanto, algumas distribuições de Linux
(como é o caso da versão do Fedora actualmente instalada nos laboratórios)
vêm configuradas de origem para activar essa filtragem.
Para evitar efeitos indesejados nos trabalhos em que se usam máquinas Linux
com mais que uma interface de rede activa, devem desactivar a filtragem de
caminho inverso nessas máquinas. Em particular, devem desactivá-la no
RLin e no Term2 do
trabalho 1.
Podem fazê-lo de forma permanente alterando no ficheiro
/etc/sysctl.conf
a linha
net.ipv4.conf.default.rp_filter = 1
,
para
net.ipv4.conf.default.rp_filter = 0
e reiniciando a máquina.
Para o fazerem de forma imediata sem necessidade de reboot podem usar
o seguinte código na shell:
for f in /proc/sys/net/ipv4/conf/*; do i=`basename $f` sysctl -w net.ipv4.conf.$i.rp_filter=0 doneEm alternativa, podem forçar a filtragem parcial (que não afecta o trabalho 1) usando o comando
sysctl -w net.ipv4.conf.all.rp_filter=2
rp_filter - INTEGER 0 - No source validation. 1 - Strict mode as defined in RFC3704 Strict Reverse Path Each incoming packet is tested against the FIB and if the interface is not the best reverse path the packet check will fail. By default failed packets are discarded. 2 - Loose mode as defined in RFC3704 Loose Reverse Path Each incoming packet's source address is also tested against the FIB and if the source address is not reachable via any interface the packet check will fail. Current recommended practice in RFC3704 is to enable strict mode to prevent IP spoofing from DDos attacks. If using asymmetric routing or other complicated routing, then loose mode is recommended. The max value from conf/{all,interface}/rp_filter is used when doing source validation on the {interface}. Default value is 0. Note that some distributions enable it in startup scripts. log_martians - BOOLEAN Log packets with impossible addresses to kernel log. log_martians for the interface will be enabled if at least one of conf/{all,interface}/log_martians is set to TRUE, it will be disabled otherwise |