# Basis



# Wichtige Befehle

Befehl                        | Beschreibung                                           | Beispiel                            | Ergebniss      |
| ----------------------------- | ------------------------------------------------------ | ----------------------------------- | -------------- |
| `en`                          | Enable Modus                                           | `SW>en`                             | `SW#`          |
| `wr`                          | Schreibe Konfiguration                                 | `SW#wr`                             | -              |
| `show run`                    | Anzeigen der Aktuellen Konfiguration                   | `SW#show run`                       | -              |
| `conf t`                      | Konfigurations Modus                                   | `SW#conf t`                         | `SW(confing)#` |
| `do show run`                 | Anzeigen der Aktuellen Konfiguration im tieferen Modus | `sw(config)#do show run`            | -              |
| `do wr`                       | Schreibe Konfiguration im Konfigurations Modus         | `SW(config)#do wr`                  | -              |
| `hostname`                    | Hostename                                              | `SW(config)#hostname SW1`           | `SW1(config)#` |
| `enabel`                      | Enable Password                                        | `SW(config)#enabel secret Passwort` | -              |
| `ctrl+z`                      | Rückkehr in den Enable Modus                           | `SW(config-if)#^Z`                  | `SW#`          |
| `show run \| inc ip address ` | Anzeigen aller IP-Adressen                             | `SW#show run \| inc ip address`     |                |
| `show ip int brief`           | Anzeigen aller IP-Adressen bei Router                  | `SW#show ip int brief`              | -              |

# Interface

| Interface             | Bedeutung                           | Abkürzung |
| --------------------- | ----------------------------------- | --------- |
| FastEthernet 0/1      | erster Fastbit Anschluss ohne Modul | fa0/1     |
| FastEthernet 0/0/1    | erster Fastbit Anschluss mit Modul  | fa0/0/1   |
| GigabitEthernet 0/1   | erster Gigabit Anschluss ohne Modul | gi0/1     |
| GigabitEthernet 0/0/1 | erster Gigabit Anschluss mit Modul  | gi0/0/1   |
| port-channel l        | erster LACP                         | -         |

## Konfiguration IP-Adressen eines Router

```
R1#conf t
R1(config)#interface GigabitEthernet 0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
```

## Konfiguration Port ausschalten bei einem Range

```
SW1#conf
SW1(config)#interface range GigabitEthernet 0/1-12
SW1(config-if)#shutdown
```

## Konfiguration LACP

```
SW1#conf
SW1(config)#interface range FastEthernet 0/1-2
SW1(config-if)#channel-groupe 1 mode activ
SW1(config-if)#interface port-channel 1
SW1(config-if)#switchport mod trunk
```

## Konfiguration Portsecurity

```
SW1#conf
SW1(config)#interface GigabitEthernet 0/4
SW1(config-if)#switchport mode access
SW1(config-if)#switchport port-security
SW1(config-if)#switchport port-security mac-address 1234.5678.9ABC.EF12
SW1(config-if)#interface GigabitEthernet 0/5
SW1(config-if)#switchport mode access
SW1(config-if)#switchport port-security

```

## Konfiguration DHCP-Snooping

```
SW1#conf
SW1(config)#ip dhcp snooping
SW1(config)#interface GigabitEthernet 0/24
SW1(config-if)#ip dhcp snooping trust
```

## Troubelshooting

```
show arp
show ip interface
show ip route
show ip dhcp snooping
shwo etherchannel summary
show port-security interface gi0/4## Interface
```

| Interface             | Bedeutung                           | Abkürzung |
| --------------------- | ----------------------------------- | --------- |
| FastEthernet 0/1      | erster Fastbit Anschluss ohne Modul | fa0/1     |
| FastEthernet 0/0/1    | erster Fastbit Anschluss mit Modul  | fa0/0/1   |
| GigabitEthernet 0/1   | erster Gigabit Anschluss ohne Modul | gi0/1     |
| GigabitEthernet 0/0/1 | erster Gigabit Anschluss mit Modul  | gi0/0/1   |
| port-channel l        | erster LACP                         | -         |

## Konfiguration IP-Adressen eines Router

```
R1#conf t
R1(config)#interface GigabitEthernet 0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
```

## Konfiguration Port ausschalten bei einem Range

```
SW1#conf
SW1(config)#interface range GigabitEthernet 0/1-12
SW1(config-if)#shutdown
```

## Konfiguration LACP

```
SW1#conf
SW1(config)#interface range FastEthernet 0/1-2
SW1(config-if)#channel-groupe 1 mode activ
SW1(config-if)#interface port-channel 1
SW1(config-if)#switchport mod trunk
```

## Konfiguration Portsecurity

```
SW1#conf
SW1(config)#interface GigabitEthernet 0/4
SW1(config-if)#switchport mode access   
SW1(config-if)#switchport port-security   
SW1(config-if)#switchport port-security mac-address 1234.5678.9ABC.EF12
SW1(config-if)#interface GigabitEthernet 0/5
SW1(config-if)#switchport mode access   
SW1(config-if)#switchport port-security   
SW1(config-if)#switchport port-security maximum 3
```

## Konfiguration DHCP-Snooping

SW1#conf SW1(config)#ip dhcp snooping SW1(config)#interface GigabitEthernet 0/24 SW1(config-if)#ip dhcp snooping trust

## Troubelshooting

```
show arp
show ip interface
show ip route
show ip dhcp snooping
shwo etherchannel summary
show port-security interface gi0/4
```

# VLAN

## Trunktype

| Wert         | 802.1Q  | ISL      |
| ------------ | ------- | -------- |
| Header Size  | 4 bytes | 26 bytes |
| Trailer Size | -       | 4 bytes  |
| Standard     | IEEE    | Cisco    |
| Max. VLANs   | 4094    | 1000     |

## VLAN Nummer nach Cisco

| ID        | Bedeutung    |
| --------- | ------------ |
| 0         | Reseviert    |
| 1         | Default      |
| 1002      | fddi-default |
| 1003      | tr           |
| 1004      | fdnet        |
| 1005      | trnet        |
| 1006-4094 | Erweiterte   |
| 4095      | Reseviert    |

## Konfiguration

```
SW1#conf t
SW1(config)#vlan 100
SW1(config-vlan)#name Server
SW1(config-vlan)#vlan 101
SW1(config-vlan)#name Client
SW1(config-vlan)#exit
SW1(config)#interface range fast 0/1-20
SW1(config-if)#switchport mode access
SW1(config-if)#switchport nonegotiate
SW1(config-if)#switchport access vlan 101
SW1(config-if)#interface range fast 0/21-24
SW1(config-if)#switchport mode trunk
SW1(config-if)#switchport trunk encapsulation dot1q
SW1(config-if)#switchport trunk allowed vlan 101
SW1(config-if)#switchport trunk native vlan 100
SW1(config-if)#interface vlan100
SW1(config-if)#ip address 192.168.100.2 255.255.255.0
```

## VTP

```
SW1#conf t
SW1(config)#
SW1(config)#vtp mode {server | client | transparent}
SW1(config)#vtp domain <name>
SW1(config)#vtp password <passsword>
SW1(config)#vtp version {1 | 2}
SW1(config)#vtp pruning
```

{% hint style="danger" %}
Für die Verwendung von VLAN ab 1005 muss folgender Befehl eingetragen werden: `SW1(config)#vtp mode transparent`
{% endhint %}

## Troubelshooting

```
show vlan
show interface [status | switchport]
show interface trunk
show vtp status
show vtp password
```

# Spanning Tree

| Attribut    | STP         | PVST       | PVST+       | RSTP                | RPVST+      | MST                 |
| ----------- | ----------- | ---------- | ----------- | ------------------- | ----------- | ------------------- |
| Algorithmus | Legacy ST   | Legacy ST  | Legac ST    | Rapid ST            | Rapid ST    | Rapid ST            |
| Standard    | 802.1D-1998 | Cisco      | Cisco       | 802.1w, 802.1D-2004 | Cisco       | 802.1s, 802.1Q-2003 |
| Instanzen   | 1           | 1 pro VLAN | 1 pro VLAN  | 1                   | 1 pro VLAN  | 1-mehre             |
| Trunk       | -           | ISL        | 802.1Q, ISL | -                   | 802.1Q, ISL | 802.1Q, ISL         |

## Link-Kosten

| Speed    | Kosten |
| -------- | ------ |
| 4 Mbps   | 250    |
| 10 Mbps  | 100    |
| 16 Mbps  | 62     |
| 45 Mbps  | 39     |
| 100 Mbps | 19     |
| 155 Mbps | 14     |
| 622 Mbps | 6      |
| 1 Gbps   | 4      |
| 10 Gbps  | 2      |
| 20+ Gbps | 1      |

## Priorität

1. 0 (Notfall Wert für neu Root-Bridge)
2. 4096 (tiefester Wert bei Normaler Konfiguration)
3. 8192
4. 12288
5. 20480
6. 24576
7. 28672
8. 32768 (Standard Wert)
9. 36864
10. 40960
11. 45056
12. 49152
13. 53248
14. 57344
15. 61440 (Maximal Wert)

## Bridge-ID

Die Bridge-ID ist wie folgt Zusammengesetz: 4 Bit Priorität + 12 System ID (VLAN) + 48 Bit MAC-Adresse

## Pfadentscheidung

1. Bridge mit der tiefesten ID wird Root-Bridge.
2. Switche mit den tieferen Pfadkosten zur Root-Bridge.
3. Switche mit der tieferen ID.
4. Tiefste Portnummer.

## Konfiguration RSTP, RPVST+

![Beispiel SpanningTree](<../.gitbook/assets/stp (1).svg>)

### Switch 1

```
SW1#conf t
SW1(config)spanning-tree mode rapid-pvst
SW1(config)spanning-tree vlan 1 priority 4096
SW1(config)interface range FastEthernet0/1-24
SW1(config-if)spanning-tree portfast
SW1(config-if)spanning-tree guard loop
SW1(config-if)spanning-tree guard root
SW1(config-if)spanning-tree bpduguard enable
SW1(config-if)spanning-tree bpdufilter enable
SW1(config-if)description Client
SW1(config-if)interface range GigabitEthernet0/1-2
SW1(config-if)no spanning-tree portfast
SW1(config-if)spanning-tree guard root
SW1(config-if)description Uplink
SW1(config-if)do wr
```

### Switch 2

```
SW2#conf t
SW2(config)spanning-tree mode rapid-pvst
SW2(config)spanning-tree vlan 1 priority 32768
SW2(config)interface range FastEthernet0/1-24
SW2(config-if)spanning-tree portfast
SW2(config-if)spanning-tree guard loop
SW2(config-if)spanning-tree guard root
SW2(config-if)spanning-tree bpduguard enable
SW2(config-if)spanning-tree bpdufilter enable
SW2(config-if)description Client
SW2(config-if)interface range GigabitEthernet0/1-2
SW2(config-if)no spanning-tree portfast
SW2(config-if)description Uplink
SW2(config-if)do wr
```

### Switch 3

```
SW3#conf t
SW3(config)spanning-tree mode rapid-pvst
SW3(config)spanning-tree vlan 1 priority 32768
SW3(config)interface range FastEthernet0/1-24
SW3(config-if)spanning-tree portfast
SW3(config-if)spanning-tree guard loop
SW3(config-if)spanning-tree guard root
SW3(config-if)spanning-tree bpduguard enable
SW3(config-if)spanning-tree bpdufilter enable
SW3(config-if)description Client
SW3(config-if)interface range GigabitEthernet0/1-2
SW3(config-if)no spanning-tree portfast
SW3(config-if)description Uplink
SW3(config-if)do wr
```

## Troubelshooting

```
show spanning-tree [summary | detail | root]
show spanning-tree [interface | vlan]
show spanning-tree mst [...]
```