JunOS – wprowadzenie
Juniper - JunOS 1
dr inż. Łukasz Sturgulewski, [email protected], http://luk.kis.p.lodz.pl/
Plan prezentacji
•Junos CLI•Podstawy CLI•Tryb Operational•Tryb Configuration
Juniper - JunOS 2
Tekstowy interfejs użytkownika
• Junos CLI• Tekstowy interfejs użytkownika (linia poleceń)• Dostęp poprzez port konsolowy za pomocą programu
terminalowego używając RJ-45 RS-232 @ 9600 Bps, 8/1/N
• Dostęp także poprzez sieć za pomocą Telnet lub SSH• Wymagany prawidłowy interfejs sieciowy i uruchomiona usługa
• Dedykowany management Ethernet interface aby zapewnić dostęp out-of-band
• J-Web • Webowy, graficzny interfejs użytkownika • Dostępny poprzez HTTP lub HTTPS
Juniper - JunOS 3
Logowanie
• W trakcie logowania:• Użytkownicy nonroot są umieszczani bezpośrednio w CLI:
• Użytkownik root musi uruchomić ręcznie CLI z shell:• Podobnie przy wylogowywaniu, użytkownik root opuści CLI do shell
Juniper - JunOS 4
Shell Prompt
CLI Prompt
router (ttyu0)
login: user
Password:
--- JUNOS 12.1R1.9 built 2012-03-24 12:12:49 UTC
user@router>
router (ttyu0)
login: root
Password:
--- JUNOS 12.1R1.9 built 2012-03-24 12:12:49 UTC
root@router% cli
root@router>
Tryby CLI
• Tryb Operational :• Monitorowanie i rozwiązywanie problemów oprogramowania, usług,
połączeń sieciowych, sprzętu
• Tryb Configuration:• Konfiguracja urządzenia w tym interfejsów, protokołów, dostępu
użytkowników, właściwości sprzętu
Juniper - JunOS 5
user@router> The > character identifies
operational mode
user@router#[edit]
The # character identifies
configuration mode
Pomoc kontekstowa
• Wpisać ? gdziekolwiek w linii poleceń aby uzyskać pomoc:
Juniper - JunOS 6
user@router> ?
Possible completions:
clear Clear information in the system
configure Manipulate software configuration information
file Perform file operations
help Provide help information
. . .
user@router> clear ?
Possible completions:
amt Show AMT Protocol information
arp Clear address resolution information
auto-configuration Clear auto-configuration action
bfd Clear Bidirectional Forwarding Detection information
. . .
Pomoc tematyczna
• help topic dostarcza tematycznych informacji:
Juniper - JunOS 7
user@router> help topic interfaces ?
Possible completions:
accept-data Accept packets destined for virtual address
accept-source-mac Policers for specific source MAC addresses
access-profile-chap CHAP profile associated with physical interface
accounting Packet counting for transit traffic
accounting-profile Accounting profile
acfc Compression of Address and Control fields in PPP header
...
user@router> help topic interfaces address
Configuring the Interface Address
You assign an address to an interface by specifying the address when
configuring the protocol family. For the inet family, configure the
interface's IP address. For the iso family, configure one or more
addresses for the loopback interface. For the ccc, tcc, mpls, tnp, and
vpls families, you never configure an address.
...
Pomoc ze składnią konfiguracji
• help reference zapewnia pomoc dotyczącą składni poleceń konfiguracyjnych:
Juniper - JunOS 8
user@router> help reference interfaces address
address
Syntax
address address {
arp ip-address (mac | multicast-mac) mac-address <publish>;
broadcast address;
...
Hierarchy Level
[edit interfaces interface-name unit logical-unit-number family family],
[edit logical-routers logical-router-name interfaces interface-name unit
logical-unit-number family family]
...
Uzupełnianie poleceń i zmiennych
Juniper - JunOS 9
Użyj Spacji aby uzupełnić polecenie:
Użyj Tab uzupełnić polecenie lub zmienną:[edit policy-options]
user@router# show policy-statement t<tab>his-is-my-policy
then accept;
[edit policy-options]
user@router#
user@router> sh<space>ow i<space>
'i' is ambiguous.
Possible completions:
iccp Show Inter Chassis Control Protocol...
igmp Show Internet Group Management Protocol...
igmp-snooping Show IGMP snooping information
interfaces Show interface information
ipv6 Show IP version 6 information
isdn Show Integrated Services Digital
isis Show Intermediate System-to-Intermediate...
user@router> show i
Press Tab to complete
assigned variables
Press the
Spacebar to
complete a
command
Edycja linii poleceń
• Dostępna jest edycja zgodna z Emacs:
• Terminal typu VT100 wspiera także przyciski strzałek.
Juniper - JunOS 10
• user@router> show interfaces
• Ctrl+b
user@router> show interfaces
• Ctrl+a
user@router> show interfaces
• Ctrl+f
user@router> show interfaces
• Ctrl+e
user@router> show interfaces
Cursor Position
Keyboard
Sequence
I (Pipe)
• Użyj | (pipe) do filtrowania i manipulowania danymi wyjściowymi z dowolnego polecenia:
Juniper - JunOS 12
user@router> show route | ?
Possible completions:
count Count occurrences
display Show additional kinds of information
except Show only text that does not match a pattern
find Search for first occurrence of pattern
hold Hold text without exiting the --More-- prompt
last Display end of output only
match Show only text that matches a pattern
no-more Don't paginate output
request Make system-level requests
resolve Resolve IP addresses
save Save output text to file
trim Trim specified number of columns from start of line
Tryb Operational
Juniper - JunOS 14
Tryb Operational
• Uruchamianie poleceń pozwalających na monitorowanie i kontrolę działania urządzeń pracujących pod systemem Junos OS. • Hierarchia poleceń:
• przykład: user@router> show ospf interface
Juniper - JunOS 15
Less Specific
More Specific database neighbor
configuration
configure help monitor …
interface
arp
clear set
version
show
ospf …
…
Potencjał trybu Operational
Juniper - JunOS 16
user@router> ?
Possible completions:
clear Clear information in the system
configure Manipulate software configuration information
file Perform file operations
help Provide help information
load Load information from file
monitor Show real-time debugging information
mtrace Trace multicast path from source to receiver
op Invoke an operation script
ping Ping remote target
quit Exit the management session
request Make system-level requests
restart Restart software process
save Save information to file
set Set CLI properties, date/time, craft interface message
show Show system information
ssh Start secure shell on another host
start Start shell
telnet Telnet to another host
test Perform diagnostic debugging
traceroute Trace route to remote host
Tryb Configuration
Juniper - JunOS 17
Konfiguracja aktywna kontra konfiguracja kandydacka
• Zmiany muszą być zatwierdzane – commit
• Aktywna konfiguracja:• Obecnie działająca konfiguracja
• Konfiguracja, z której urządzenie się uruchamia
• Konfiguracja kandydacka:• Kopia, na której pracuje się nad zmianami konfiguracji
• Inicjalizuje się z konfiguracji aktywnej
• Stacje się aktywną po zatwierdzeniu – commit
Juniper - JunOS 18
Cykl życia plików konfiguracyjnych
Juniper - JunOS 19
commit
rollback n
Candidate
Configuration
Active
Configuration
1 2 ...
0
49
configure
Bit Bucket
Wejście do trybu Configuration (1 z 2)
• Wpisać configurew trybie operacyjnym aby wejść do trybu konfiguracyjnego:
• Użyć polecenia configure exclusive aby wykluczyć innych użytkowników z możliwości edycji.• Niezatwierdzone zmiany zostaną usunięte po wyjściu z tego trybu:
Juniper - JunOS 20
user@router> configure exclusive
warning: uncommitted changes will be discarded on exit
Entering configuration mode
[edit]
user@router#
user@router> configure
Entering configuration mode
[edit]
user@router#
Wejście do trybu Configuration (2 z 2)
• Użyć configure private aby pozwolić użytkownikom na edycję prywatnej kopii konfiguracji kandydackiej w tym samym czasie (jednocześnie)• Kiedy użytkownicy użyją commit, ich prywatne zmiany zostaną włączone do globalnej
konfiguracji.• Niezatwierdzone zmiany zostaną usunięte po wyjściu użytkowników z tego trybu • Kiedy dwóch użytkowników dokonuje konkurencyjnych zmian: gdy pierwszy
użytkowników wykona commit z powodzeniem to drugi otrzyma stosowane ostrzeżenie• Drugi użytkownik musi wykonać commit aby aktywować swój zmiany
Juniper - JunOS 21
walter@router> configure private
warning: uncommitted changes will be discarded on exit
Entering configuration mode
Users currently editing the configuration:
nancy terminal p0 (pid 9935) on since 2010-05-11 17:11:22 UTC
private [edit]
[edit]
walter@router#
Allows other
users to edit
private copies
of the
candidate
configuration
Hierarchiczny model konfiguracji
Juniper - JunOS 22
[edit]
user@router# edit protocols ospf area 51 stub
[edit protocols ospf area 0.0.0.51 stub]
user@router#
graceful-restart
isis mpls
interfaces
bgp
chassis
pim rip rsvp
services system
vrrp
overload traffic-engineering
area-range area_range interface nssa stub
protocols
ospf
area area_id
[edit]
Less Specific
More Specific
…
…
…
…
Plik konfiguracyjny jest hierarchiczny
•
Juniper - JunOS 23
Polecenia w CLI wprowadzane są bez klamr:
[edit system]
user@router# set services web-management http port 8080
•Rezultatem jest hierarchiczny plik konfiguracyjny
uzupełniony klamrami:
[edit system]
user@router# show services
web-management {
http {
port 8080;
}
}
[edit]
user@router# edit protocols ospf area 51 stub
[edit protocols ospf area 0.0.0.51 stub]
user@router#
Poruszanie się pomiędzy poziomami (1 z 6)
Juniper - JunOS 24
graceful-restart
isis mpls
interfaces
bgp
chassis
pim rip rsvp
services system
vrrp
overload traffic-engineering
area-range area_range interface nssa stub
protocols
ospf
area area_id
edit działa jak polecenie zmień katalog:
[edit]
…
…
…
…
[edit protocols ospf area 0.0.0.51 stub]
user@router# up
[edit protocols ospf area 0.0.0.51]
user@router#
Juniper - JunOS 25
area area_id graceful-restart
isis mpls
interfaces protocols
bgp
chassis
ospf pim rip rsvp
services system
vrrp
overload traffic-engineering
area-range area_range interface nssa stub
[edit]
up przenosi o jeden poziom w hierarchii do góry:
…
…
…
…
Poruszanie się pomiędzy poziomami (2 z 6)
Poruszanie się pomiędzy poziomami (3 z 6)
• up n przenosi o n poziomów w hierarchii do góry:
Juniper - JunOS 26
[edit protocols ospf area 0.0.0.51]
user@router# up 2
[edit protocols]
user@router#
area area_id graceful-restart
isis mpls
interfaces protocols
bgp
chassis
pim rip rsvp
services system
vrrp
overload traffic-engineering
area-range area_range interface nssa stub
[edit]
ospf
…
…
…
…
Poruszanie się pomiędzy poziomami (4 z 6)
• top przenosi na szczyt hierarchii:
Juniper - JunOS 27
[edit protocols ospf area 0.0.0.51 stub]
user@router# top
[edit]
user@router#
graceful-restart
isis mpls
interfaces
bgp
chassis
pim rip rsvp
services system
vrrp
overload traffic-engineering
area-range area_range interface nssa stub
[edit]
protocols
ospf
area area_id
…
…
…
…
Poruszanie się pomiędzy poziomami (5 z 6)
Juniper - JunOS 28
exit przenosi do poprzedniego, wyższego poziomu w hierarchii
[edit protocols ospf]
user@router# edit area 51 stub
[edit protocols ospf area 0.0.0.51 stub]
user@router# exit
[edit protocols ospf]
user@router#
graceful-restart
isis mpls
interfaces protocols
bgp
chassis
ospf pim rip rsvp
services system
vrrp
overload traffic-engineering
area-range area_range interface nssa stub
[edit]
area area_id
…
…
…
…
Poruszanie się pomiędzy poziomami (6 z 6)
Juniper - JunOS 29
Podsumowanie:•edit działa jak polecenie CD
•up przenosi o jeden poziom do góry
•up n przenosi o n poziomów do góry
•top przenosi na szczyt
•exit przenosi do poprzedniego, wyższego poziomu w hierarchii lub wychodzi z trybu konfiguracji jeśli jesteśmy na szczycie hierarchii[edit]
user@router# edit protocols ospf area 51 stub
[edit protocols ospf area 0.0.0.51 stub]
user@router# up
[edit protocols ospf area 0.0.0.51]
user@router# up 2
[edit protocols]
user@router# top
[edit]
user@router# exit
The configuration has been changed but not committed
Exit with uncommitted changes? [yes,no] (yes)
Dodanie konfiguracyjnego wpisu
Juniper - JunOS 30
Użyć set aby dodać nowy konfiguracyjny wpis:[edit system services]
user@router# show
ssh;
telnet;
[edit system services]
user@router# set ftp
[edit system services]
user@router# show
ftp;
ssh;
telnet;
FTP service added
Usunięcie konfiguracyjnego wpisu
Juniper - JunOS 31
Użyć polecenia delete aby usunąć wybrany wpis
•Usuwa wszystko co poniżej od określnej pozycji w
hierarchii.
[edit system services]
user@router# show
ftp;
ssh;
telnet;
[edit system services]
user@router# delete telnet
[edit system services]
user@router# show
ftp;
ssh;
Telnet service removed
TEST
• Interfejs został wyłączony za pomocą polecenia set interfaceinterface-name disable. Jak włączyć ten interfejs ponownie?
Juniper - JunOS 32
Pomocne polecenia w trybie konfiguracyjnym (1 z 2)
• rename[edit]
user@router# rename interfaces ge-0/0/10 to ge-0/0/11
• replace pattern[edit]
user@router# replace pattern ge-0/0/10 with ge-0/0/11
• copy[edit]
user@router# copy interfaces ge-0/0/10 to ge-0/0/11
Juniper - JunOS 33
Pomocne polecenia w trybie konfiguracyjnym (2 z 2)
• deactivate[edit]
user@router# deactivate interfaces ge-0/0/10
• insert[edit policy-options policy-statement test]
user@router# insert term three before term two
• annotate[edit system]
user@router# annotate name-server “adding new name servers”
Juniper - JunOS 35
Podgląd konfiguracji kandydackiej
Juniper - JunOS 37
[edit]
user@router# show system services
ssh;
web-management {
http {
port 8080;
}
}
[edit]
user@router# edit system services
[edit system services]
user@router# show
ssh;
web-management {
http {
port 8080;
}
}
Podgląd wybranego fragmentu
konfiguracji ze szczytu hierarchii
Aby podejrzeć polecenia set użyte do budowanej konfiguracji
należy użyć polecenia show | display set
Przejście do wybranego miejsca
w konfiguracji i jego podgląd
Zatwierdzanie konfiguracji (1 z 2)
Juniper - JunOS 38
Użyć commit aby uaktywnić zmiany w konfiguracji:
• Jeśli istnieje wiele uruchomionych RE, należy użyć commit synchronize
Użyć commit check aby sprawdzić poprawność:
Użyć commit confirmed aby czasowo aktywować:
[edit]
user@router# commit
commit complete
[edit]
user@router# commit check
[edit interfaces ge-0/0/10 unit 0]
'family'
When ethernet-switching family is configured on an interface, no
other family type can be configured on the same interface.
error: configuration check-out failed
[edit]
user@router# commit confirmed
commit confirmed will be automatically rolled back in 10 minutes unless
confirmed
commit complete
[edit]
user@router# commit and-
quit
commit complete
Exiting configuration mode
user@router>
Zatwierdzanie konfiguracji (2 z 2)
Juniper - JunOS 40
Użyć commit at aby zatwierdzić w wybranym czasie:
Użyć commit comment aby dodać komentarz:
Użyć commit and-quit aby oszczędzać czas:
[edit]
user@router# commit at 21:00:00
configuration check succeeds
commit at will be executed at 2010-05-11 21:00:00 UTC
Exiting configuration mode
[edit]
user@router# commit comment "Changed OSPF
configuration"
commit complete
user@router> show system commit
0 2010-05-11 15:32:42 UTC by user via cli
Changed OSPF configuration
…
Porównywanie różnic w plikach konfiguracyjnych
Juniper - JunOS 41
Porównywanie kandydackiej i aktywnej konfiguracji:
Porównywanie aktywnej i historycznej konfiguracji:
Porównywanie dwóch plików:
[edit system services]
user@router# show | compare
[edit system services]
+ ftp;
- telnet;
user@router> show configuration | compare rollback number
user@router> show configuration | compare filename
user@router> file compare files filename_1 filename_2
Wycofywanie zmian w konfiguracji
Juniper - JunOS 42
Użyć rollback aby powrócić do poprzedniej konfiguracji:
•rollback (lub rollback 0 ) reset konfiguracji kandydackiej do aktualnej konfiguracji aktywnej
•rollback 1 załadowanie poprzednio aktywnej konfiguracji•rollback n załadowanie wybranej wersji konfiguracji
Modyfikuje wyłączenie konfigurację kandydacką•Nie zapomnij użyć commit!
[edit]
user@router# rollback ?
Possible completions:
<[Enter]> Execute this command
0 2009-10-29 00:55:48 UTC by user via cli
1 2009-10-29 00:16:27 UTC by lab via cli
...
49 2009-02-05 03:11:00 UTC by lab via cli
Cykl życia pliku konfiguracyjnego
Juniper - JunOS 43
commit
rollback n
Candidate
Configuration
Active
Configuration
1 2 ...
0
49
configure
Bit Bucket
Zapisywanie plików konfiguracyjnych
Juniper - JunOS 44
Użyć save aby zapisać bieżącą konfigurację:
•Zapisuje w dół od aktualnej pozycji w hierarchii
•Zapisuje do katalogu roboczego użytkownika
• Można określić pełną ścieżkę i nazwę pliku lub URL (FTP / SCP)
[edit]
user@router# save filename
Wrote 101 lines of configuration to 'filename'
[edit]
user@router# save path/filename
[edit]
user@router# save
ftp://user:password@router/path/filename
[edit]
user@router# save scp://user@router/path/filename
Ładowanie plików konfiguracyjnych
• Użyć load aby załadować plik konfiguracyjny:
• Użyć terminal aby wprowadzić konfigurację z bufora terminala:
• Użyć relative aby załadować od obecnej pozycji w hierarchii:
• Użyć commit aby aktywować konfigurację kandydacką
Juniper - JunOS 45
[edit]
user@router# load ?
Possible completions:
factory-default Override existing configuration with factory default
merge Merge contents with existing configuration
override Override existing configuration
patch Load patch file into configuration
replace Replace configuration data
set Execute set of commands on existing configuration
update Update existing configuration
user@router# load (replace | merge | override) terminal
user@router# load (replace | merge) (filename | terminal) relative
Polecenie run
Juniper - JunOS 47
[edit interfaces ge-0/0/12]
user@router# set unit 0 family inet address 10.250.0.141/16
[edit interfaces ge-0/0/12]
user@router# commit
commit complete
[edit interfaces ge-0/0/12]
user@router# run ping 10.250.0.149 count 1
PING 10.250.0.149 (10.250.0.149): 56 data bytes
64 bytes from 10.250.0.149: icmp_seq=0 ttl=255 time=0.967
ms
--- 10.250.0.149 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.967/0.967/0.967/0.000 ms
Użyć run aby uruchomić polecenia trybu operacyjnego będąc w trybie konfiguracyjnym
Use run to test
configuration
changes without
leaving
configuration
mode
Top Related