# Comandos Packet tracer
###### tags: `REDES`
## Subnet Masks
|/|Mask|Wild Card|
|---|---|---|
|/8|255.0.0.0|0.255.255.255|
|/9|255.128.0.0|0.127.255.255|
|/10|255.192.0.0|0.63.255.255|
|/11|255.224.0.0|0.31.255.255|
|/12|255.240.0.0|0.15.255.255|
|/13|255.248.0.0|0.7.255.255|
|/14|255.252.0.0|0.3.255.255|
|/15|255.254.0.0|0.1.255.255|
|/16|255.255.0.0|0.0.255.255|
|/17|255.255.128.0|0.0.127.255|
|/18|255.255.192.0|0.0.63.255|
|/19|255.255.224.0|0.0.31.255|
|/20|255.255.240.0|0.0.15.255|
|/21|255.255.248.0|0.0.7.255|
|/22|255.255.252.0|0.0.3.255|
|/23|255.255.254.0|0.0.1.255|
|/24|255.255.255.0|0.0.0.255|
|/25|255.255.255.128|0.0.0.127|
|/26|255.255.255.192|0.0.0.63|
|/27|255.255.255.224|0.0.0.31|
|/28|255.255.255.240|0.0.0.15|
|/29|255.255.255.248|0.0.0.7|
|/30|255.255.255.252|0.0.0.3|
## IP Address Breakdown

# Ajudas
|Descrição | Link |
| --- | --- |
| Tabelas de Subnets | [Subnet Calculator](http://wintelguy.com/subnetcalc.pl) |
| IP Calculator | [Ip Calculator](http://jodies.de/ipcalc) |
## Housekeeping
en
conf t
hostname "nome do equipamento"
enable sec "password"
line con 0
password "password"
login
exi
line vty "0 4" / "5 15"
pass "password"
login
exi
ban motd "Aviso aqui"
service pa
do w
## DHCP pelo Router
en
conf t
ip dhcp pool "nome"
network "ip" "subnetmask"
default-router "ip saida"
exit
ip dhcp excluded-address "ip minimo excluido" "ip maximo excluido"
## Port-Security no switch:
en
conf t
int "port"
sw port-security
## No router para receber dhcp do servidor:
ip helper-address (ip)
## Router Rip
router rip
version 2
no auto-summary
network "ip"
## Criar Sub-interfaces
conf t
int f0/0
no sh
exit
int f0/0.1
encapsulation dot1Q 2
ip add "ip"
no sh
exit
int f0/0.2
encapsulation dot1Q 3
ip add "ip"
no sh
exit
ip dhcp excluded-address "ip minimo excluido" "ip máximo excluido"
ip dhcp excluded-address "ip minimo excluido" "ip máximo excluido"
ip dhcp pool Vlan1
network "ip rede" "subnetmask"
default-router "ip saída router"
exit
## Fechar portas Inutilizadas
en
conf t
int range fa0/3-23(portas inutilizadas)
shutdown
### Deixar portas abertas e em modo access e a do router em modo trunk
#### Modo access:
inf range fa0/1-2(portas ligadas dos pc ao switch)
no shutdown
switchport mode access
#### Modo trunk:
int fa0/24(porta ligada do switch ao router)
no shutdown
switchport mode trunk
### Port-Security - Portas de Switch
en
conf t
int "port"
sw port-security mac-address sticky
sw port-security maximum 1
sw port-security violation restrict
### Transportar portas para outras Vlans - *Switch e Router*
int "porta"
sw acc vlan "nº da vlan"
## SWITCH LAYER 3
en
conf t
ip routing (transformar switch em router para permitir comandos de router)
int "porta"
no switch (para mudar uma porta de switch para uma porta terminal)
*******************
## **Protocolos**
### **SSH - *Router e Switch***
acesso remoto - por default-gateway
acesso local - nao introduzir default-gateway
ip domain name "site"
user "user" sec "password"
cry k gen rsa
"bits"
ip ssh v 2
ip ssh t "tempo em segundos"
ip ssh au "numero de retries"
line vty 0 4
login local
tran in ssh
access-list (para por os computadores que se quer a utilizar o ssh)
#### Testar o serviço a partir do PC
ssh -l admin "ip"
ssh -l "user" "ip"
### **Router Rip**
en
conf t
router rip
v 2
no au
pa "portas(reais ou encapsulation)"
net "ip(só ip sem subnet)"
### **Redistribute Rip - EIGRP**
en
conf t
router eigrp
red rip metric 1000 100 255 255 2
### **Router EIGRP**
en
conf t
router eigrp "nº"
no au
pass "introduzir a interface que não vai receber dados"
net "ip" "wildcard"
### **Redistribute Eigrp - RIP**
en
conf t
router rip
red eigrp 2 metric 1
### **Router OSPF**
en
conf t
router ospf "nº"
net "ip" "wildcard" area "nº"
area x stub
area x stub no-summary
# **Serviços**
## Syslog
logging (ip do server syslog)
logging trap debugging
-necessário criar user-
## NTP
ntp server x.x.x.x
ntp authenticate
ntp update-calendar
do show clock (fast forward 20X)
## VTP
### Ligação entre SW em trunk
vtp domain X
vtp mode server/client/transparent
#### cliente = vtp mode client
## AAA
### Server
abrir o AAA nos serviços, colocar o client name do router em questão. secret é a password e o client IP colocar o IP de chegada do server.
### Router
aaa new-model
aaa authentication login default local none
aaa authentication login "nome" group radius
radius server host "ip do server" auth-port 1645 key "secret do AAA"
line con 0
login authentication "nome"
### NAT
int "X" interface que vai para os end users.
ip nat inside
exit
acc 100 permit ip "X" - IP de dentro
ip nat inside source list 100 interface "X" overload - interface de fora.
## **Rotas Estáticas**
ip route "ip da rede que se pretende conhecer" "subnet" "ip do dispositivo que reconhece a rede"
## **Tuneis**
en
conf t
int tunnel "nº"
tun mode gre ip
tun source "X" *porta de chegada*
tun dest "ip" *que se quer fazer o tunel*
### No ip domain lookup (Caso haja engano no comando ele não vai procurá-lo)
## VOIP
#### Router 2911 - Enable VOIP
en
conf t
license boot module c2900 technology-package UCK9
[yes]
### Protocolos Encaminhamento
|EGP|IGP|
|---|---|
|BGP |RIP V1
|"" |RIP V2|
|"" |IGRP/EIRGP |
#### **Loopback**
en
conf t
int loopback "x"
ip address "x.x.x.x" "x.x.x.x"
## **Access-List**

en
conf t
access-list 1 permit "ip" "wildcard"
ip inside source list "x" interface "(interface exterior que comunica com a net)" overload
int "interface"
ip nat inside "parte de dentro da rede"
exit
int "interface saída da rede "
ip nat outside
#### Exemplo:
Router(config)#access-list 100 permit tcp host 192.168.99.10 any eq 22
Router(config)#access-list 100 deny icmp any any
Router(config)#access-list 100 deny ip any any
### "ACL STANDARD É PARA SER COLOCADA SEMPRE MAIS PRÓXIMO DO DESTINO !!"
### "ACL EXTENDED É PARA SER COLOCADA O MAIS PRÓXIMO DA ORIGEM !!"
---
### Spanning-Tree
spanning-tree portfast - disable ao spanning-tree
spanning-tree bpduguard enable - protege a porta para ligarmos equipamentos terminais.
### Portas
speed 1000
duplex full
sw nonegotiate
#### Port-Channel
int port-channel 1
int "porta"
channel-group 1 mode auto
# IPV6
ipv6 add [ip/x]
ipv6 add [ip] link-local
ipv6 unicast-routing
----------------------
IPV6
-------------------
ipv6 unicast-routing
ipv6 dhcp pool pool1
address prefix <ip> lifetime infinite infinite
dns-server <ip>
domain-name "site"
ex
int s0/0/0
ipv6 add <ip>
ipv6 dhcp server <nome>
ipv6 nd managed-config-flag
ipv6 dhcp pool DHCPV6
prefix-delegation pool address_pool
dns-server 2001:4860:4860::8888
domain-name netspace.com
ipv6 local pool address_pool 2001:c1c0:34:3:3::/64 64
int gigabitEthernet 0/0
ipv6 dhcp server DHCPV6
### Mostrar Ligações dhcp ativas
sh ipv6 dhcp pool
sh ipv6 dhcp binding
## Certificados Cisco
1º - mudar o Hostname
2º - colocar o dominio "atec.pt" (exemplo)
3º - crypto key generate rsa
4º - 1024
5º - ip ssh version 2
#### Onde usar o certificado
1º- user "ola" sec "ola"
2º- ena sec "ola"
3º- line vty 0 4
[Backup](https://hackmd.io/CYZlFYFMDYE4FoDsyBM8AsAOdbMpJkgAwCMIJ4iAZgEY3jBA?both)
[Quinzereis Teórica](https://hackmd.io/d07WM-PKTbKbLRCfOPugPg)
[PDF Access Lists](http://docdro.id/xIY31ki)