20
MPLS Prática com Linux Edgard Jamhour

MPLS Prática com Linux

  • Upload
    wolfe

  • View
    43

  • Download
    0

Embed Size (px)

DESCRIPTION

MPLS Prática com Linux. Edgard Jamhour. Instalação. yum update yum install udev.i386 071-0.FC4.3 yum install hardlink yum install bridge-utils rpm -ivh kernel-2.6.15-1.1831_FC4mpls_1.950.i686.rpm rpm -ivh iproute-2.6.11-1_mpls_1.950d.i386.rpm - PowerPoint PPT Presentation

Citation preview

Page 1: MPLS Prática com Linux

MPLSPrática com Linux

Edgard Jamhour

Page 2: MPLS Prática com Linux

2015, Edgard Jamhour

ip1

mpls nhlfe add key 0 instructions push gen LABEL nexthop ETHO ipv4 NEXTHOP

Configuração LER de Ingresso

LER

LSR

LSR

eth0 label1

eth1 label2 ip2

ip route add SUBREDE via NEXTHOP mpls KEY

FTN =FEC X NHLFE

FEC (destino)

subrede1

subrede2

subrede1

subrede2

Chave

Ação NHLFE

0x2 push label1 e envia por eth0 para ip1

0x3 push label2 e envia por eth1 para ip2

Page 3: MPLS Prática com Linux

2015, Edgard Jamhour

Configuração LER de Egresso

LSR

LER

eth0label1

eth1label2

mpls labelspace set dev ETHI labelspace 0

mpls ilm add label gen LABEL labelspace 0

subrede1

labelspace Interface Label ILM

0 eth0 label1

1 eth1 label2

LSR

Page 4: MPLS Prática com Linux

2015, Edgard Jamhour

ip1

Configuração do LSR

LSR

LER

LSR

eth2 label11

eth3 label21 ip2

• mpls labelspace set dev ETHI labelspace 0• mpls ilm add label gen LABEL labelspace 0• mpls xc add ilm_label gen LABEL ilm_labelspace 0 nhlfe_key KEY

Chave

ação NHLFE

0x2 push label11 e enviar por eth2 para ip1

0x3 push label21 e enviar por eth3 para ip2

LER

LSReth0

eth1

label10

label20

ILM labelspace

If Label

0 eth0 label10

1 eth1 label20

XC

Page 5: MPLS Prática com Linux

2015, Edgard Jamhour

Exercício 1

a

LABEL 1000

LER1

LER2

Host A

Host Ba b

HOST A a eth1 192.168.0.2

LER 1 a eth1:1 192.168.0.1

b eth1 10.0.0.1/30

LER 2 a eth1 10.0.0.2/30

b eth1:1 192.168.1.1

HOST B a eth1 192.168.1.2

a b a

LABEL 2000

Page 6: MPLS Prática com Linux

2015, Edgard Jamhour

Configuração HOST A

ip route add 192.168.1.0/24 via 192.168.0.1 src 192.168.0.2

LER 1 mpls nhlfe add key 0 instructions push gen 1000

nexthop eth1 ipv4 10.0.0.2 ip route add 192.168.1.0/24 via 10.0.0.2 mpls 0x2 echo 1 > /proc/sys/net/ipv4/ip_forward

LER 2 mpls labelspace set dev eth1 labelspace 0 mpls ilm add label gen 1000 labelspace 0

Page 7: MPLS Prática com Linux

2015, Edgard Jamhour

Observações1. É necessário incluir a pasta /sbin antes dos comandos ifconfig e

mpls.

2. Para corrigir este problema edite o arquivo conforme indicado abaixo, e depois reinicie a máquina virtual;

1. cd /home/labredes

2. gedit .bash_profile

3. Altere PATH=$PATH:HOME/bin

4. Para PATH=$PATH:/sbin

5. <Ctrl+S><Ctrl+Q>

3. Repita o procedimento para o usuário root:1. su root (senha labredes)

2. cd /root

3. gedit .bash_profile

4. Altere PATH=$PATH:HOME/bin

5. Para PATH=$PATH:/sbin

6. <Ctrl+S><Ctrl+Q>

Page 8: MPLS Prática com Linux

2015, Edgard Jamhour

Preparação do Script Por exemplo, para o Exercício1:

LER1: script exe1_ler1.sh LER2: script exe1_ler2.sh

Para criar o script exe1_ler1.sh1. entre em modo root:

2. su root (senha labredes)

3. gedit exe1_ler1.sh

4. ... digite o script conforme o próximo slide, não esqueça de alterar as variáveis que representam o endereço IP e a interface

5. <Ctrl+S><Ctrl+Q>

6. chmod +x exercicio1.sh Para executar o script:

bash -x exe1_ler1.sh

Page 9: MPLS Prática com Linux

2015, Edgard Jamhour

Script MPLS para LER 1

#!/bin/basheq=1 #altere o número da equipeif_b=eth1 #altere a interface If_a=eth1:1 #altere a interfaceip_b=10.$eq.0.1ip_a=192.$eq.0.1ip_ler2a=10.$eq.0.2feca=192.$eq.1.0/24

#atribuir endereços IPifconfig $if_a $ip_aIfconfig $if_b $ip_b

modprobe mpls4key_value=`mpls nhlfe add key 0 instructions push gen 1000 nexthop $if_b ipv4 $ip_ler2a `;key=`echo $key_value|awk '{print $4}'`;ip route add $feca via $ip_ler2a mpls $keysysctl -w net.ipv4.ip_forward=1

Page 10: MPLS Prática com Linux

2015, Edgard Jamhour

Script MPLS para LER 2

#!/bin/basheq=1 #altere o número da equipeif_b=eth1 #altere a interface If_a=eth1:1 #altere a interfaceip_a=10.$eq.0.2ip_b=192.$eq.1.1

#atribuir endereços IPifconfig $if_a $ip_aIfconfig $if_b $ip_b

modprobe mpls4mpls labelspace set dev $if_a labelspace 0mpls ilm add label gen 1000 labelspace 0

Page 11: MPLS Prática com Linux

2015, Edgard Jamhour

Comandos para Evitar Redirecionamento

#altere a interface conforme seu computadorsysctl net.ipv4.conf.eth1.send_redirects=0sysctl net.ipv4.conf.eth1.accept_redirects=0sysctl net.ipv4.conf.all.send_redirects=0sysctl net.ipv4.conf.all.accept_redirects=0

Page 12: MPLS Prática com Linux

2015, Edgard Jamhour

Cenário 2

Host A

Host Ba

192.168.0.0/24

L:2000 Host C

192.168.1.0/25

192.168.1.128/25

L:2001

b

c

da

a

LER 1 a eth1 192.168.0.1

b eth1:1 10.0.0.1/30

c eth1:2 10.1.0.1/30

LER 2 a eth1 10.2.0.2/30

b eth1:1 10.0.0.2/30

c eth1:2 192.168.0.129

d eth1:3 192.168.1.1

LSR a eth1 10.1.0.2/30

b eth1:1 10.2.0.1/30

HOST A a eth1 192.168.0.2

HOST B a eth1 192.168.1.2

HOST C a eth1 192.168.1.130

c

LER1

LER2

LSR

L:1000 b

aa b

Page 13: MPLS Prática com Linux

2015, Edgard Jamhour

Configuração LER 1 LER1 (Rota Vermelha)

mpls nhlfe add key 0 instructions push gen 1000 nexthop eth1:1 ipv4 10.0.0.2 ip route add 192.168.1.0/25 via 10.0.0.2 mpls 0x2

LER1 (Rota Azul) mpls nhlfe add key 0 instructions push gen 2000 nexthop eth1:2 ipv4 10.1.0.2 ip route add 192.168.1.128/24 via 10.1.0.2 mpls 0x3

Roteamento echo 1 > /proc/sys/net/ipv4/ip_forward

LER1

LER2

LSR

L:1000

L:2000

eth1:1

eth1:2

10.0.0.2

10.1.0.2

Page 14: MPLS Prática com Linux

2015, Edgard Jamhour

Configuração LSR # LSR (Rota Azul)

mpls labelspace set dev eth1 labelspace 0 mpls ilm add label gen 2000 labelspace 0 mpls nhlfe add key 0 instructions push gen 2001 nexthop

eth1:1 ipv4 10.2.0.2 mpls xc add ilm_label gen 2000 ilm_labelspace 0 nhlfe_key 0x2 echo 1 > /proc/sys/net/ipv4/ip_forward

L:2000 L:2001

LER1

LER2

LSR

eth1 eth1:1

10.2.0.2

Page 15: MPLS Prática com Linux

2015, Edgard Jamhour

Configuração LER 2 LER2 (Rota Vermelha)

mpls labelspace set dev eth1 labelspace 0 mpls ilm add label gen 1000 labelspace 0

LER2 (Rota Azul) mpls labelspace set dev eth1:1 labelspace 0 mpls ilm add label gen 2001 labelspace 0

LER2

LER1

LSR

L:1000

L:2001

eth1

eth1.1

Page 16: MPLS Prática com Linux

2015, Edgard Jamhour

Configuração Hosts HOST A

ip route add 192.168.1.0/24 via 192.168.0.2 src 192.168.0.1

HOST B ip route add 192.168.0.0/24 via 192.168.1.2 src

192.168.1.2 HOST C

ip route add 192.168.0.0/24 via 192.168.1.129 src 192.168.1.130

Page 17: MPLS Prática com Linux

2015, Edgard Jamhour

Exemplo: Script para o LSR

#!/bin/bash -xeq=1 #altere o número da equipeif_b=eth1:1 #altere a interface If_a=eth1 #altere a interfaceip_b=10.1.$eq.2ip_a=10.2.$eq.1ip_ler2a=10.2.$eq.2feca=192.$eq.1.128/25

#atribuir endereços IPifconfig $if_a $ip_aIfconfig $if_b $ip_b

mpls labelspace set dev $if_a labelspace 0mpls ilm add label gen 2000 labelspace 0

key_value=`mpls nhlfe add key 0 instructions push 2001 nexthop $if_b ipv4 $ip_ler2a `;key=`echo $key_value|awk '{print $4}'`;mpls xc add ilm_label gen 2000 ilm_labelspace 0 nhlfe_key $key

sysctl -w net.ipv4.ip_forward=1

Page 18: MPLS Prática com Linux

2015, Edgard Jamhour

Exercício 2 Implemente o cenário 2 de forma que os

pacotes enviados pelo host A para a subrede: 192.168.0.0/25 sigam o caminho vermelho 192.168.0.128/25 sigam o caminho vermelho

Escreva o script de configuração de um dos caminhos

Capture os quadros mpls em LSR1 ou LER2, conforme o caminho.

Page 19: MPLS Prática com Linux

2015, Edgard Jamhour

Cenário 3

LER 1 a eth1 66.0.0.1/24

b eth1:1 10.0.0.1/30

LER 2 a eth1 77.0.0.1/24

b eth1:1 10.0.0.13/30

LER 3 a eth1 10.0.0.10/30

b eth1:1 10.0.0.22/30

c eth1:2 88.0.0.1/24

FEC A

FEC C

a

L:2000

L:1000L:1001

LSR 1 a eth1 10.0.0.2/30

b eth1:1 10.0.0.5/30

c eth1:2 10.0.0.14/30

d eth1:3 10.0.0.17/30

LSR 2 a eth1 10.0.0.6/30

b eth1:1 10.0.0.9/30

LSR 3 a eth1 10.0.0.18/30

b eth1:1 10.0.0.21/30

FEC B

192.168.0.0/24

LSR1LSR1

LSR2LSR2

LSR3LSR3

LER3LER3

LER2LER2

LER1LER1b

L:1002

L:2001 L:2002

a b

a b

c d

a b

a b

a

bc

Page 20: MPLS Prática com Linux

2015, Edgard Jamhour

Exercício 3 Implemente o cenário 3 de forma que os

pacotes enviados: Pela FEC A: sigam o caminho vermelho Pela FEC B: sigam o caminho azul

Os caminhos de volta a partir da FEC C devem ser simétricos e utilizar os mesmos Labels.