Skip to content

Experiência 4

Camões edited this page Dec 21, 2020 · 1 revision

Disclaimer: Tive de trocar tudo para y já que houve pessoal que usou 2 na configuração quando estava noutra bancada e estragou a configuração tanto para ele como para o da bancada 2..

Xanxos


Exp4

Steps

  1. Configure commercial router RC and connect it (no NAT) to the lab network (172.16.1.0/24)*
  2. Verify routes
    • tuxy4 as default router of tuxy3; Rc as default router for tuxy2 and tuxy4
    • Routes for 172.16.y0.0/24 in tuxy2 and Rc
  3. Using ping commands and wireshark, verify if tuxy3 can ping all the network interfaces of tuxy4, tuxy2 and Rc
  4. In tuxy2
    • Do: echo 0 > /proc/sys/net/ipv4/conf/eth0/accept_redirects and echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
    • remove the route to 172.16.y0.0/24 via tuxy4
    • In tuxy2, ping tuxy3
    • Using capture at tuxy2, try to understand the path followed by ICMP ECHO and ECHO-REPLY packets (look at MAC addresses)
    • In tuxy2, do traceroute tuxy3
    • In tuxy2, add again the route to 172.16.y0.0/24 via tuxy4 and do traceroute tuxy3
    • Activate the acceptance of ICMP redirect at tuxy2 when there is no route to 172.16.y0.0/24 via tuxy4 and try to understand what happens
  5. In tuxy3, ping the router of the lab I.321 (172.16.1.254)** and try to understand what happens
  6. Add NAT functionality to router Rc
  7. In tuxy3 ping 172.16.1.254**, verify if there is connectivity, and try to understand what happens

* In room I320 the lab network address is 172.16.2.0/24

** Router of lab I320 has IP address 172.16.2.254

Step 1

Ligar Cabos

Mesma configuração de exp3, com a adição do router a ligar ao switch e a ligar á lab network.

TUXy3E0    -> Switch Porta 1 
TUXy2E0    -> Switch Porta 2
TUXy4E0    -> Switch Porta 3
TUXy4E1    -> Switch Porta 4
ROUTERGE0  -> Switch Porta 5      (router-switch)
ROUTERGE1  -> Prateleira Porta 1  (router-lab network)
Ligações no switch
TUXy3E0 (1) TUXy4E0 (3) GE0 (5)
TUXy2E0 (2) TUXy4E1 (4) empty (6)

Configurar IP's

Os IP's do router têm de ser feitos a partir do GtkTerm. Para os tux's temos bash files que configuram os ip's e routes.

Configure commercial router RC and connect it (no NAT) to the lab network (172.16.1.0/24)

Deve ser preciso configurar o router, para isso temos no slide 45 (valores alterados):

»interface gigabitethernet 0/0                 (0/0 - deve ser bloco 0, porta 0 do router)
»ip address 172.16.y1.254    255.255.255.0     (deve ser endereço e máscara aka /24 )
»no shutdown 
»exit 
»show interface gigabitethernet 0/0     

Isto deve dar um Ip ao router para poder ligar ás no porta GE0, falta dar um ip para comunicação exterior a partir da porta GE1:

»interface gigabitethernet 0/1                 (0/0 - deve ser bloco 0, porta 0 do router)
»ip address 172.16.1.y9    255.255.255.0       (deve ser endereço e máscara aka /24 )
»no shutdown 
»exit 
»show interface gigabitethernet 0/1     

Aproveitar que se está na consola e adiciona umas routes que serão precisas no passo 2:

»ip route 0.0.0.0 0.0.0.0 172.16.1.254 
»ip route 172.16.y0.0 255.255.255.0 172.16.y1.253

Após ter o router configurado é necessário configurar tudo para trás como na experiência 3 a configuração é igual, excepto que se vai adicionar a porta GE0 do router á VLAN1. A próxima secção são os passos do link com a adição do router á vlan. Passos:

  • Configurar Ips
  • Criar Vlans e adicionar portas
  • ip forwarding e disable ICMP echo-ignore-broadcast no tux24
  • adicionar routes

Configurar IP's

tuxy3:

> ifconfig eth0 up
> ifconfig eth0 172.16.y0.1/24
> ifconfig eth0 

tuxy4:

> ifconfig eth0 up
> ifconfig eth0 172.16.y0.254/24
> ifconfig eth0 

> ifconfig eth1 up
> ifconfig eth1 172.16.y1.253/24
> ifconfig eth1 

tuxy2:

> ifconfig eth0 up
> ifconfig eth0 172.16.y1.1/24
> ifconfig eth0 
IP MAC tux/ether
172.16.y1.1 ? tuxy2 eth0
172.16.y0.1 ? tuxy3 eth0
172.16.y0.254 ? tuxy4 eth0
172.16.y1.253 ? tuxy4 eth1

Configurar VLAN's

TUXy3S0  -> T3
T4 -> Switch Console

Ligas um Cabo S0, like TUXy3S0, á porta 23 da prateleira de cima (T3) e um cabo da porta T4 a switch console e fazes como em exp2

Esta secção é para ser feita apenas uma vez, num tux á escolha, a partir do terminal GtkTerm, sem necessidade de alterar cabos.

VLAN y0:

  • tuxy3 eth0 -> port 1
  • tuxy4 eth0 -> port 3

VLAN y1:

  • tuxy2 eth0 -> port 2
  • tuxy4 eth1 -> port 4
  • router eth0 -> port 5

Intruções Detalhadas:

Dar login no switch (slide 48):

»enable
»password: ****** (deve ser 8nortel, olha para a prateleira e confirma)

Criar VLAN (vlany0) (Slide 44):

»configure terminal
»vlan y0
»end
»show vlan id y0

Add port 1 to vlan y0 (Slide 44):

»configure terminal
»interface fastethernet 0/1             (x/y ;  x é o bloco, como só há um , o bloco é 0; y é o port mostrado no switch)
»switchport mode access
»switchport access vlan y0
»end

Add port 3 to vlan y0 (Slide 44):

»configure terminal
»interface fastethernet 0/3             
»switchport mode access
»switchport access vlan y0
»end

Criar VLAN (vlany1) (Slide 44):

»configure terminal
»vlan y1
»end
»show vlan id y1

Add port 2 to vlan y1 (Slide 44):

»configure terminal
»interface fastethernet 0/2             
»switchport mode access
»switchport access vlan y1
»end

Add port 4 to vlan y1 (Slide 44):

»configure terminal
»interface fastethernet 0/4             
»switchport mode access
»switchport access vlan y1
»end

Add port 5 to vlan y1 (Slide 44):

»configure terminal
»interface fastethernet 0/5             
»switchport mode access
»switchport access vlan y1
»end

No final verificar se está tudo correto com:

»show vlan

Também podes verificar com:

»show running-config interface fastethernet 0/1
»show interfaces fastethernet 0/1 switchport

testar com números de portas diferentes

Enable IP forwarding & Disable ICMP echo-ignore-broadcast

Passa para o tuxy4 e faz os seguintes comando no terminal

echo 1 > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

Adicionar Routes

No tuxy3 adiciona-se uma rota para dizer que para aceder á vlan com endereços 172.16.y1.0/24 usa-se como gateway o IP 172.16.y0.254. Este comando é para ser feito na consola:

route add -net 172.16.y1.0/24 gw 172.16.y0.254

Da mesma forma, no tuxy2 faz-se:

route add -net 172.16.y0.0/24 gw 172.16.y1.253

Testa pingar o tuxy2 a partir do tuxy3 e o oposto para ver se chegam um ao outro.

Em tuxy3:
ping 172.16.y1.1

Em tuxy2:
ping 172.16.y0.1

Caso haja erros:

  • verifica as routes em cada tux com route -n para ficarem desta forma.
  • verifica os ips de cada tux para ter a certeza que estão corretos
  • liga-te á consola do switch e verifica se as vlans estão corretamente configuradas

Se as rotas de cima estiverem corretas, é necessário adicionar mais umas routes para o passo 2: tuxy2:

# definir RC como default router
route add default gw 172.16.y1.254

tuxy3:

# definir tuxy4 como default router
route add default gw 172.16.y0.254

tuxy4:

# definir RC como default router
route add default gw 172.16.y1.254

Step 2

Usar nos tuxys para verificar as tabelas resultantes:

> route -n

As tabelas devem ficar na seguinte forma: tuxy2:

Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.y0.0 172.16.y1.253 255.255.255.0 UG 0 0 0 eth0
172.16.y1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.16.1.0 172.16.y1.254 255.255.255.0 UG 0 0 0 eth0

tuxy3:

Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.y0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.16.y1.0 172.16.y1.254 255.255.255.0 UG 0 0 0 eth0

tuxy4:

Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.y0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.16.y1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
172.16.1.0 172.16.y1.254 255.255.255.0 UG 0 0 0 eth1

Router, não sei qual é o comando para ver a tabela, mas se fizeste os passos de definição de rotas na configuração do router, deve ser algo deste genero:

Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.y0.0 172.16.y1.253 255.255.255.0 U 0 0 0 eth0
0.0.0.0 172.16.1.254 0.0.0.0 U 0 0 0 eth1

Para verificar:

  • tuxy4 as default router of tuxy3
  • Rc as default router for tuxy2 and tuxy4
  • Routes for 172.16.y0.0/24 in tuxy2 and Rc

Step 3

Parecido com Step 6 de exp3.

No tuxy3, começar o wireshark e a capturar pacotes, pingar tuxy2, eth0 de tuxy4, eth1 de tuxy4 e Rc:

ping 172.16.y0.254  #eth0 tuxy4
ping 172.16.y1.253  #eth1 tuxy4
ping 172.16.y1.1    #eth0 tuxy2
ping 172.16.y1.254  #eth0 Router
ping 172.16.1.y9    #eth1 Router

10 pings para cada e guardar o ficheiro como exp4_step3.pcapng

Step 4

Passar para tuxy2. Alguns pontos têm comentários, outros são self-explanatory:

  • Do: echo 0 > /proc/sys/net/ipv4/conf/eth0/accept_redirects and echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects

No terminal do tuxy2:

echo 0 > /proc/sys/net/ipv4/conf/eth0/accept_redirects
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
  • remove the route to 172.16.y0.0/24 via tuxy4

No tuxy2 usar comandos de baixo para apagar a entrada que usa como gateway o ip 172.16.y1.253

# Para ver tabela
> route -n
# deve dar tabela de baixo
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.y0.0 172.16.y1.253 255.255.255.0 UG 0 0 0 eth0
172.16.y1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.16.1.0 172.16.y1.254 255.255.255.0 UG 0 0 0 eth0

Aqui é preciso apagar a primeira entrada:

# Para apagar entrada
> route del -net 172.16.y0.0/24 gw 172.16.y1.253 
  • In tuxy2, ping tuxy3

No tux22 fazer um ping:

ping 172.16.y0.1    #eth0 tuxy3

A rota para o tuxy3 foi removida no tuxy4, será que chega? Aponta a resposta

  • Using capture at tuxy2, try to understand the path followed by ICMP ECHO and ECHO-REPLY packets (look at MAC addresses)

No tuxy2, liga o wireshark e começa a capturar no eth0. Faz 10 pings:

ping 172.16.y0.1    #eth0 tuxy3

No final dos 10 pings dá CTRL+C, deixa passar uns segundos e faz:

traceroute 172.16.y0.1    #eth0 tuxy3

se o comando acima funcionar faz o proximo, se não funcionar, faz CTRL+C e faz o proximo

traceroute -l 172.16.y0.1    #eth0 tuxy3
# -I	Use ICMP ECHO instead of UDP datagrams.

deixar até acabar ou se não funcionar (não sei se funciona), CTRL+C. Para a captura e guarda os logs como exp4_step4.pcapng.

  • In tuxy2, do traceroute tuxy3

é o que já fizeste em cima, assim já fica guardado nos logs, se quiseres saber mais tens aqui um link

A partir deste comando sabemos por onde passam os pacotes para chegar a um sitio, acho que o suposto é passar pelo tuxy4 eth1 (172.16.y1.253) e eth0 (172.16.y0.254). Mas como a entrada na tabela de routes foi apagada não deve passar. Aponta o resultado.

  • In tuxy2, add again the route to 172.16.y0.0/24 via tuxy4 and do traceroute tuxy3
route add -net 172.16.y0.0/24 gw 172.16.y1.253
# seguido de
traceroute 172.16.y0.1    #eth0 tuxy3

Again, o que acontecerá? Aponta.

  • Activate the acceptance of ICMP redirect at tuxy2 when there is no route to 172.16.y0.0/24 via tuxy4 and try to understand what happens
# Apagar a entrada 172.16.y0.0/24 outra vez no tuxy2
route -n
route del -net 172.16.y0.0/24 gw 172.16.y1.253
# ativar estas coisas
echo 1 > /proc/sys/net/ipv4/conf/eth0/accept_redirects 
echo 1 > /proc/sys/net/ipv4/conf/all/accept_redirects

Começa uma captura e faz os mesmos comandos que fizeste na outra captura:

# dá um tempo entre cada comando para não ficar tudo junto nos logs e dá apenas 10 pings, CTRL+C para parar
ping 172.16.y0.1            #eth0 
traceroute 172.16.y0.1      #eth0 tuxy3
traceroute -l 172.16.y0.1   #eth0 tuxy3

Acaba a captura e guarda os logs exp4_step4_lastpoint.pcapng

Step 5

Passar para tuxy3 e fazer

ping 172.16.1.254

É suposto não funcionar porque precisa de NAT

Maybe dá para fazer um log com isto, fica ao teu critério : exp4_step5_.pcapng

Step 6

Add NAT functionality to router Rc

^ Not sure como fazer isto, secalhar também é na configuração do router. Temos também o slide 46 com informação:

https://www.cisco.com/c/en/us/support/docs/ip/network-address-translation-nat/13772-12.html

# Defines Ethernet 0 with an IP address and as a NAT inside interface.
conf t               # [<- pode ser "conf terminal", mas está assim nos slides]
interface gigabitethernet 0/0 *     
ip address 172.16.y1.254 255.255.255.0 
no shutdown 
ip nat inside        
exit 

# como deu exit em cima pode ser preciso escrever outra vez "conf t"
# Defines Ethernet 1 with an IP address and as a NAT outside interface.
# 172.16.2.29 para i320
interface gigabitethernet 0/1 * 
ip address 172.16.1.y9 255.255.255.0 
no shutdown 
ip nat outside       
exit 

# Defines a NAT pool named ovrld with a range of a single IP  address, 172.16.1.y9.
ip nat pool ovrld 172.16.1.y9 172.16.1.y9 prefix 24 
# Indicates that any packets received on the inside interface that are permitted by access-list 1 has the source address translated to an address out of the NAT pool named ovrld. Translations are overloaded, which allows multiple inside devices to be translated to the same valid IP address.
ip nat inside source list 1 pool ovrld overload 

# Access-list 1 permits packets with source addresses ranging from 172.16.y0.0 through 172.16.y0.7 and 172.16.y1.0 through 172.16.y1.7.
access-list 1 permit 172.16.y0.0 0.0.0.7 
access-list 1 permit 172.16.y1.0 0.0.0.7 

# estas rotas já foram adicionadas em passos acima, não deve ser preciso adicionar outra vez, estão aqui para apontar que este pedaço de código foi retirado do slide 46
# 172.16.2.254 para sala i320
ip route 0.0.0.0 0.0.0.0 172.16.1.254 
ip route 172.16.y0.0 255.255.255.0 172.16.y1.253 
end

* In room I320 use interface fastethernet

nat inside:

image

access-list:

image image

ip route:

image image image image

Step 7

Mesmo que o Step 5. Deve ser para fazer um log com isto também : exp4_step7_.pcapng