junos
ref
networking · juniper · referenz

JunOS CLI —
Kompakte Referenz auf Deutsch

Operational Mode, Configuration Mode, Routing-Protokolle, BGP, OSPF, IS-IS, RIPv2 und SRX Security — alles was man im Alltag braucht, ohne in der Juniper-Doku zu versinken. Kein Tutorial, keine Theorie — nur die Commands die man wirklich braucht, mit dem Kontext der den Unterschied macht.

JunOS 21+ SRX / MX / EX ✓ Deutsch ⚠ commit nicht vergessen
01 Modi 02 Grundlagen 03 Interfaces 04 Routing 05 OSPF 06 BGP 07 IS-IS 08 RIPv2 09 Policies 10 SRX Security 11 Debug
01 — Modi

Operational Mode vs. Configuration Mode

JunOS kennt zwei grundlegende Arbeitsmodi. Der wichtigste Unterschied zu anderen Herstellern: Konfigurationsänderungen werden erst mit commit aktiv — vorher ist nichts kaputt.

✓ Operational Mode — Prompt: >
  • Status anzeigen, troubleshooten
  • Ping, traceroute, show
  • Logs lesen
  • Konfiguration lesen (nicht schreiben)
  • Einstieg: direkt nach Login
⚙ Configuration Mode — Prompt: #
  • Konfiguration ändern
  • set, delete, edit
  • Änderungen erst nach commit aktiv
  • rollback macht alles rückgängig
  • Einstieg: configure oder edit
JunOSZwischen Modi wechseln
# Operational → Configuration
> configure
> configure exclusive   # andere Nutzer gesperrt
> configure private     # eigene Kandidaten-Config

# Configuration → Operational (ohne commit)
# exit
# run show interfaces   # show-Befehle direkt aus Config-Mode

# Commit-Optionen
# commit                # sofort aktiv
# commit confirmed 5    # aktiv, rollback nach 5 Min ohne confirm
# commit check          # Syntax prüfen ohne zu committen
# rollback 0            # letzte committed config wiederherstellen
# rollback 1            # vorletzte, bis rollback 49
commit confirmed — dein bester Freund

Bei Änderungen die den Zugriff unterbrechen könnten immer commit confirmed 5 verwenden. Wenn nach 5 Minuten kein commit folgt, macht JunOS automatisch rollback. Verhindert Aussperren bei Firewall-Policy-Änderungen.

02 — Grundlagen

Navigieren, anzeigen, suchen

CommandBeschreibungMode
show versionJunOS-Version, Hostname, ModellOP
show system uptimeUptime, letzte commit-ZeitOP
show configurationGesamte aktive KonfigurationOP
show configuration | display setConfig als set-Befehle — copy-paste-fähigOP
show configuration | match ospfConfig nach Begriff filternOP
show | compareUncommitted Änderungen anzeigen (diff)CF
edit protocols ospfIn Config-Hierarchie navigierenCF
up / topEine Ebene / ganz nach obenCF
show ?Alle verfügbaren Sub-Commands anzeigenOP
request system rebootNeustart (mit Bestätigung)OP
Pipe-Filter in JunOS

JunOS kennt mächtige Pipe-Filter: | match TEXT (grep), | except TEXT (grep -v), | find TEXT (ab erster Übereinstimmung), | count (Anzahl Zeilen), | display set (als set-Commands). Kombinierbar: show route | match 10.0 | count.

03 — Interfaces

Interfaces konfigurieren & prüfen

JunOS ConfigInterface konfigurieren
# Einfaches L3-Interface
# set interfaces ge-0/0/0 description "Uplink WAN"
# set interfaces ge-0/0/0 unit 0 family inet address 10.0.0.1/30

# Loopback (für Router-ID, BGP, OSPF)
# set interfaces lo0 unit 0 family inet address 192.0.2.1/32

# VLAN-Subinterface (Trunk)
# set interfaces ge-0/0/1 vlan-tagging
# set interfaces ge-0/0/1 unit 10 vlan-id 10
# set interfaces ge-0/0/1 unit 10 family inet address 10.10.10.1/24

# Interface deaktivieren
# set interfaces ge-0/0/2 disable
CommandBeschreibungMode
show interfaces terseAlle Interfaces — Status + IP, kompaktOP
show interfaces ge-0/0/0Detail: Fehler, Traffic, Duplex, SpeedOP
show interfaces ge-0/0/0 detailNoch mehr Detail inkl. QueuesOP
show interfaces descriptionsAlle Beschreibungen auf einen BlickOP
clear interfaces statistics ge-0/0/0Zähler zurücksetzenOP
04 — Routing

Routing-Tabelle & statische Routen

JunOS ConfigStatische Routen
# Default Route
# set routing-options static route 0.0.0.0/0 next-hop 10.0.0.2

# Spezifische Route
# set routing-options static route 172.16.0.0/16 next-hop 10.0.1.1

# Route mit Präferenz (niedrig = bevorzugt, default 5)
# set routing-options static route 0.0.0.0/0 next-hop 10.0.0.2 preference 10

# Reject-Route (Black Hole)
# set routing-options static route 192.0.2.0/24 reject

# Router-ID und AS setzen
# set routing-options router-id 192.0.2.1
# set routing-options autonomous-system 65001
CommandBeschreibungMode
show routeGesamte Routing-TabelleOP
show route 10.0.0.0/8Routen für ein PrefixOP
show route protocol staticNur statische RoutenOP
show route protocol ospfNur OSPF-RoutenOP
show route detailMit Präferenz, Next-Hop, MetrikOP
show route forwarding-tableFIB — was wirklich weitergeleitet wirdOP
05 — OSPF

OSPF konfigurieren & verifizieren

JunOS ConfigOSPF Area 0 — Basis
# OSPF Area 0 mit Interfaces
# set protocols ospf area 0.0.0.0 interface ge-0/0/0.0
# set protocols ospf area 0.0.0.0 interface lo0.0 passive

# Stub Area
# set protocols ospf area 0.0.0.1 stub default-metric 10
# set protocols ospf area 0.0.0.1 interface ge-0/0/1.0

# Interface-Tuning
# set protocols ospf area 0.0.0.0 interface ge-0/0/0.0 hello-interval 5
# set protocols ospf area 0.0.0.0 interface ge-0/0/0.0 dead-interval 20
# set protocols ospf area 0.0.0.0 interface ge-0/0/0.0 metric 10

# Redistribute statische Routen in OSPF
# set protocols ospf export redistribute-static
# # (policy redistribute-static muss existieren)

# Authentication
# set protocols ospf area 0.0.0.0 interface ge-0/0/0.0 authentication md5 1 key "geheim"
CommandBeschreibungMode
show ospf neighborNachbarschaften + Status (Full = gut)OP
show ospf neighbor detailDead-Timer, DR/BDR, InterfaceOP
show ospf databaseLSDB — alle LSAsOP
show ospf database summaryLSA-Typen kompaktOP
show ospf routeOSPF-Routen in der Routing-TabelleOP
show ospf interfaceInterface-Status, Rolle (DR/BDR/DROther)OP
clear ospf neighbor allAlle Nachbarschaften zurücksetzenOP
Loopback immer als passive konfigurieren

Das Loopback-Interface (lo0.0) in OSPF als passive eintragen — so wird das Prefix angekündigt, aber kein Neighbor-Aufbau versucht. Die Loopback-IP als Router-ID verwenden sorgt für Stabilität auch wenn physische Interfaces flappen.

06 — BGP

eBGP & iBGP konfigurieren

JunOS ConfigeBGP Session zu einem Upstream
# Lokale AS-Nummer (einmalig unter routing-options)
# set routing-options autonomous-system 65001

# eBGP Peer
# set protocols bgp group UPSTREAM type external
# set protocols bgp group UPSTREAM peer-as 65002
# set protocols bgp group UPSTREAM neighbor 10.0.0.2

# Export-Policy (was wir ankündigen)
# set protocols bgp group UPSTREAM export bgp-export

# iBGP Peer (gleiche AS, Loopback als Source)
# set protocols bgp group IBGP type internal
# set protocols bgp group IBGP local-address 192.0.2.1
# set protocols bgp group IBGP neighbor 192.0.2.2

# Route Reflector (für iBGP Scale)
# set protocols bgp group IBGP cluster 192.0.2.1

# Authentication
# set protocols bgp group UPSTREAM neighbor 10.0.0.2 authentication-key "geheim"
CommandBeschreibungMode
show bgp summaryAlle Peers + Status (Established = gut)OP
show bgp neighbor 10.0.0.2Detail: Hold-Timer, Capabilities, ErrorsOP
show route receive-protocol bgp 10.0.0.2Empfangene Prefixe von diesem PeerOP
show route advertising-protocol bgp 10.0.0.2Was wir an diesen Peer sendenOP
show route protocol bgpAlle BGP-Routen in der Routing-TabelleOP
clear bgp neighbor 10.0.0.2Session zurücksetzen (hard reset)OP
clear bgp neighbor 10.0.0.2 softSoft reset — Policies neu anwendenOP
BGP kündigt ohne Export-Policy nichts an

JunOS BGP sendet standardmäßig keine Routen — anders als bei Cisco. Ohne explizite Export-Policy bleibt die Session zwar oben, aber es werden keine Prefixe angekündigt. Immer export [ policy-name ] am BGP-Group-Level setzen.

07 — IS-IS

IS-IS konfigurieren

JunOS ConfigIS-IS Level 2 — Basis
# NET-Adresse auf Loopback (System-ID = MAC-ähnlich, Area 49.0001)
# set interfaces lo0 unit 0 family iso address 49.0001.1920.0020.0001.00

# IS-IS aktivieren
# set protocols isis interface ge-0/0/0.0
# set protocols isis interface lo0.0 passive

# Nur Level 2 (empfohlen für einfache Setups)
# set protocols isis interface ge-0/0/0.0 level 1 disable

# Wide-Metrics aktivieren (für Traffic Engineering)
# set protocols isis level 2 wide-metrics-only

# IPv6 hinzufügen
# set interfaces lo0 unit 0 family inet6 address 2001:db8::1/128
# set protocols isis interface ge-0/0/0.0 family inet6 unicast
CommandBeschreibungMode
show isis adjacencyNachbarschaften + Level + StatusOP
show isis databaseLSP-DatenbankOP
show isis routeIS-IS-RoutenOP
show isis interfaceInterface-Status, Level, MetrikOP
08 — RIPv2

RIPv2 konfigurieren

JunOS ConfigRIPv2 — Basis
# RIPv2 aktivieren
# set protocols rip group RIP-GROUP neighbor ge-0/0/0.0

# Default Route über RIP senden
# set protocols rip group RIP-GROUP export send-default

# Routen importieren (was wir akzeptieren)
# set protocols rip group RIP-GROUP import rip-import

# Authentication
# set protocols rip group RIP-GROUP neighbor ge-0/0/0.0 authentication-type md5
# set protocols rip group RIP-GROUP neighbor ge-0/0/0.0 authentication-key "geheim"
CommandBeschreibungMode
show rip neighborRIP-Nachbarn + StatusOP
show rip statisticsGesendete/empfangene UpdatesOP
show route protocol ripÜber RIP gelernte RoutenOP
09 — Routing Policies

Import / Export Policies

Policies steuern welche Routen importiert oder exportiert werden. Sie bestehen aus Terms mit from-Bedingungen und then-Aktionen. Am Ende jeder Policy steht implizit ein reject — was nicht explizit akzeptiert wird, wird abgelehnt.

JunOS ConfigPolicy — Beispiele
# Statische Routen in BGP exportieren
# set policy-options policy-statement bgp-export term static from protocol static
# set policy-options policy-statement bgp-export term static then accept

# Spezifisches Prefix matchen
# set policy-options prefix-list MY-PREFIXES 10.0.0.0/8
# set policy-options policy-statement bgp-export term prefixes from prefix-list MY-PREFIXES
# set policy-options policy-statement bgp-export term prefixes then accept

# Default Term am Ende — alles andere ablehnen
# set policy-options policy-statement bgp-export term default then reject

# Community setzen
# set policy-options community MY-COMMUNITY members 65001:100
# set policy-options policy-statement bgp-export term static then community add MY-COMMUNITY

# Policy testen (ohne commit!)
> test policy bgp-export 10.0.0.0/8
test policy — immer zuerst

test policy POLICY-NAME PREFIX zeigt im Operational Mode was eine Policy mit einem bestimmten Prefix machen würde — ohne dass ein commit nötig ist. Unverzichtbar bevor eine neue Export-Policy live geht.

10 — SRX Security

Zones, Policies & NAT auf dem SRX

Der SRX ist ein stateful Firewall-Router. Traffic läuft durch Security Zones, Security Policies steuern was erlaubt ist, NAT übersetzt Adressen. Die Reihenfolge ist immer: Zone → Policy → NAT.

JunOS SRX ConfigZones + Policy — Basis
# Zonen definieren
# set security zones security-zone trust interfaces ge-0/0/1.0
# set security zones security-zone untrust interfaces ge-0/0/0.0

# Host-Zugriff auf Zone erlauben (z.B. SSH von LAN)
# set security zones security-zone trust host-inbound-traffic system-services ssh
# set security zones security-zone trust host-inbound-traffic system-services ping

# Security Policy: trust → untrust erlauben
# set security policies from-zone trust to-zone untrust policy ALLOW-OUT \
#     match source-address any destination-address any application any
# set security policies from-zone trust to-zone untrust policy ALLOW-OUT then permit

# Source NAT (Masquerading) für ausgehenden Traffic
# set security nat source rule-set SNAT from zone trust
# set security nat source rule-set SNAT to zone untrust
# set security nat source rule-set SNAT rule RULE1 match source-address 0.0.0.0/0
# set security nat source rule-set SNAT rule RULE1 then source-nat interface

# Destination NAT (Port-Forwarding)
# set security nat destination rule-set DNAT from zone untrust
# set security nat destination rule-set DNAT rule HTTP-IN match destination-port 80
# set security nat destination rule-set DNAT rule HTTP-IN then destination-nat ip 10.0.1.10 port 80
CommandBeschreibungMode
show security zonesAlle Zonen + zugehörige InterfacesOP
show security policiesAlle Security PoliciesOP
show security flow sessionAktive Sessions in der Flow-TabelleOP
show security nat source summarySource-NAT-Regeln + TrefferOP
show security nat destination summaryDestination-NAT-Regeln + TrefferOP
show security alg statusApplication Layer Gateways (FTP, SIP etc.)OP
clear security flow session allAlle Sessions löschen (Vorsicht!)OP
11 — Debug & Troubleshooting

Wenn nichts funktioniert

JunOSConnectivity testen
# Ping mit Source-Interface
> ping 10.0.0.2 routing-instance default source 10.0.0.1 count 5

# Traceroute
> traceroute 8.8.8.8

# DNS auflösen
> request system dns lookup example.com
JunOSTraceoptions — Protokoll-Debugging
# BGP Debugging aktivieren
# set protocols bgp traceoptions file bgp.log
# set protocols bgp traceoptions flag open
# set protocols bgp traceoptions flag update
# commit

# Log live verfolgen
> monitor start bgp.log
> monitor stop

# OSPF Debugging
# set protocols ospf traceoptions file ospf.log
# set protocols ospf traceoptions flag hello
# set protocols ospf traceoptions flag error

# Nach dem Debugging immer aufräumen!
# delete protocols bgp traceoptions
# commit
BGP Session kommt nicht hoch — Notification ohne klare Meldung
show bgp neighbor X.X.X.X zeigt den letzten Error-Code. Häufigste Ursachen: falsche AS-Nummer beim Peer (peer-as), fehlende Route zum Peer (keine Adjacency möglich), oder Authentication-Key stimmt nicht überein. Traceoptions mit flag open zeigt den OPEN-Message-Austausch.
OSPF Nachbarschaft bleibt bei ExStart / Exchange stecken
MTU-Mismatch zwischen den Interfaces. JunOS sendet standardmäßig die Interface-MTU im DBD-Paket. Fix: set protocols ospf interface ge-0/0/0.0 ignore-mtu-mismatch oder MTU auf beiden Seiten angleichen.
Policy funktioniert nicht — Routen werden trotzdem abgelehnt
test policy POLICYNAME PREFIX zeigt was die Policy tatsächlich macht. Häufig fehlt ein explizites then accept im letzten Term, oder die Policy ist am BGP-Group-Level nicht eingetragen (export fehlt). Nach Policy-Änderung immer clear bgp neighbor X soft um neu zu evaluieren.
SRX lässt Traffic durch obwohl Policy "deny" sagt
Die Session existiert noch in der Flow-Tabelle aus der Zeit bevor die Policy geändert wurde. Stateful Firewall: bestehende Sessions werden nicht unterbrochen. Fix: clear security flow session destination-prefix X.X.X.X/32 oder clear security flow session all (Vorsicht — unterbricht alle Verbindungen).
commit schlägt fehl ohne klare Fehlermeldung
commit check zeigt Syntax-Fehler ohne zu committen. show | compare zeigt was sich geändert hat. Bei referenzierten Objekten (Policy-Namen, Prefix-Listen) die noch nicht existieren schlägt commit ab. Alle referenzierten Objekte müssen vor dem commit vorhanden sein.