Link

Linux commands

Vim:

O – insert "above"
ESC :wq – write (save) + quit
i – insert – insert at place where I am 
:q – quit – when no changes
h j k l – move pointer left down up right
arrow buttons - also moving of pointer

SSH:

     check public key:  cat ~/.ssh/id_rsa.pub
     .ssh/config - configure nicknames of ssh keys
     vi .ssh/config - edit config
     host <name>
            hostname 10.0.?.???
            user <user>
            

dd command

     dd if=/dev/zero/ of=/dev/sdb bs=1M count=100
     -rewrite (erase) usb stick with zeroes
     dd if=/home/nfs/drbohlav/Downloads/ubuntu-gnome-17.04-desktop-amd64.iso of=/dev/sdb bs=1M
     -move - create image on usb stick

dmesg command

     check how usb stick is mounted
     dmesg -T

wget command

     wget <path> → download requested file from http://... address

find command

    find <path> -name <name of searched file> -> looking for file by its name
    find <path> -ctime xx   → looking for files last edited xx days ago 
		-type x 	→ type x 
			d	→ directory
			f 	→ regular file
		-atime xx	→ accesed more then xx days ago
		-size x yy	→ size x-type yy- amount:
			c	→ bytes
			w	→ two bytes words
			k	→ Kilobytes
			M	→ Megabytes
			G 	→ Gigabytes

stat command %x →Time of last access, human-readable

	%y     		→Time of last modification, human-readable

%z →Time of last change, human-readable

tar xzf command

ctr leftmouse → option for CLI

alt leftmouse → move CLI window

alt rightmouse → resize CLI window

ping nebo host - zjisti server na kterem je dana adresa

FTP

jak se pripojit pres midnight commander F9 vyprat pripojit pres FTP a spravne okno pak napr. user@novyweb.starlab.cz

STP

stp protocol video - https://www.youtube.com/watch?v=japdEY1UKe4 notes from video:

  1. ccna exam big toppic
  2. stric set of rules

types of STP

STP / 802.1D Original STP
PVST+ Cisco improvement of STP adding a per VLAN feature
RSTP / 802.1w Improved STP with much faster convergence
Rapid PVST+ Cisco improvement of RSTP adding per VLAN  feature

vlan + STP can make more efficient network. 

What accually is STP?

Feature used to prevent loops with redundand switches. 

broadcast messeges are sented all the time, if there is a loop it can make “brodcast storm” > bigger and bigger until on of the swiches fail, or someone breaks the link by discconecting or or reloading the switch another problem is that the swich gets same broadcast messeges to different ports with same MAC adress, so its contiunously changes MAC adress tables. > unstable MAC adress tables

another problem are Duplicate frames -

solution? On of the connection is block, to broadcast messeges not goes multiple ways. It works, but how to chose which link to block? STP has a protocol for that - high level overview:

1. Elect a Root Bridge
2. Place root interfaces into Fowarding state
3. Each non-root switch seletcts its Root Port
4. Remaining links choose a Designated Port
5. All other ports are put in to a Blocking state

Roles – job of the ports

Root Ports – The best port to reach the Root Bridge
Designated Port – port with the best cost (route) to the Root Bridge on a link
Non-Designated Port – All other ports that are in a blocking state

States Disabled – A port that is shutdown

Blocking – A port that is blocking traffic
Listening – Not forwarding traffic and not learning MAC addresses
Learning – Not forwarding traffic but learning MAC addresses
Forwarding – Sending and receiving traffic like norma (FWD)

a) root bridge ellection

each bridge BPDU
Root cost
stp priority: 32768 + vlan number
example of BPDU:
Root cost: 0
My BID : 32769aaaa:aaaa:aaaa
Root BID : 32769aaaa:aaaa:aaaa

best BPDU wins ellections

b) then root bridge is changed to FWD state c) other switches choosing best path to the root bridge – these are called root ports (RP) -selection is based on port cost

Port Cost
      Port Speed        Orginal     New
      10 Mbps            100          2,000,000
      100 Mbps          19	        200,000
      1Gbps               4	        20,000
      10 Gbps            2	        2,000
      100 Gbps          N/A	        200
      1 Tbps              N/A	        20

- root cost is the collection of each outgoing port added together to the root

  1. root port chossing is logicaly based on lowest port cost

I. root cost to the bridge II. root cost coud be the same on more ports

  1. lowes neigbour BID wins

- if they ties > III. Lowest neighbour port priority

IV. Lowest neighbour port number d) designated ports (DP) ports that are not root ports, choosing designated ports Cisco packet tracer I. lowest root cost to the bridge

if that ties> 

II. lowest bid > III. Lowest neigbour port priority IV. Lowest neighbour port number

e) blocking last step – every port, that is not a root port, or a designated port, is put to blocking state

Timers – Default

Hello 2 Seconds
Max Age 10 x Hello (20 seconds)
Forward Delay 15 Seconds

STP States

forwarding State – Moves straight to blocking
Blocking State Moves straight to Listening
Listenning – Foward Delay timer (Default 15 Seconds)
Learning – Foward Delay timer (Default 15 Seconds)

switches

? <enter> → kontext help switch> → user mode enable (to enable mode) → switch# → priviliged mode disable (to go back to user mode)

ping ???.???.???.??? → ping IP adress

configure terminal → global configure mode

show running-config

show ip interface brief = sh ip int brief

show vlan brief

write → save settings

copy run start → save settings

Switch(config)#interface fa 0/2

switchport access vlan 4

two config files - running-config and startup if I do write command both are the same copy running-config tftp → backup configuration on server adress

change vlan ip adress

   interface vlan 50
   ip adress ???.???.???.???. 255.255.255.???
   

add port to vlan

   (config)# interface fastEthernet 0/2
   (config-if)# switchport mode access
   (config-if)# switchport access vlan 50
   (config-if)# no shutdown
   

vypnout trunk na portu:

   (config-if)#no switchport trunk native vlan 4
    

how to enable and disable bpdu guard

   spanning-tree bpduguard → enable
   no spanning-tree bpduguard → disable

Python Django

create virtuale environment

   virtualenv - p python3 <name>
   
   source bin/activate
   pip install django  -> To install Django  into virtual evironment
   
   django-admin startproject <name> -> to create django project
   
   ./manage.py runserver -> show information - ip adress
   migration - makemigrations
   ./manage.py migrate
   
   create superuser for database - ./manage.py createsuperuser

urls.py → pridani stranky k souboru

   Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home') 

from . import views

    urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^prehled/', views.prehled, name='prehled'),


     
    urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^prehled/', views.prehled, name='prehled'),

views.py →

from django.http import HttpResponse

def prehled(request):
        return HttpResponse("Zde bude prehled nahravek jiz v databazi")

python manage.py shell → run django python shell

Pycharm

/srv/pycharm-2016.2.3/bin/pycharm.sh → run pycharm

Telefonovani, presmerovani, linky

jak presmerovat hovor

   zvednu sluchatko - muzu mluvit s volajicim
   pro presmerovani zmacknu xfer 
   zdam cislo xx nebo zkratku napr 28 zmacknu dial 
   mohu mluvit s tim na koho presmerovavam pokud to zvedne
   pak znovu xfer 
   
   28 - KM
   21 - VS
   22 - DS
   25 - MaDr

Jak zkopirovat databazy ze stareho serveru na novy

informace o starych databazich v http://212.20.98.92/ispconfig/ heslo v ratticu. sites> databasis (nalevo) > nahore filtrovat napr pomoci vybrani klienta

STAHNOUT -jit na http://webhost.panelnet.cz/phpmyadmin/ - prihlasit se jako root - obvykle heslo > vybrat databazy vlevo > pak kliknout na export > zpravidla nechat tak jak je (Quick, SQL) > a pak kliknout na GO -stahne se soubor s databazi

NAHRAT -jit na https://webhosting.starlab.cz/ > login > prihlasit se jako uziv > kliknout na users v pravo dole > vybrat uzivatele pro ktereho chci databazi nahrat a login as user > site list (v levo nahore) > website name - vybrat > pak kliknout na databases (v levo dole) > add database > napsat jmeno stejneho formatu jako stazena databaze a zakliknout MySQL

pak prihlasit na https://webhosting.starlab.cz/phpmyadmin jako root - obvykle heslo > vybrat nove vytvorenou databazy vlevo > nahore import > chose file - vybrat stazenou databazi > click GO databaze by se mela nahrat bez chyb.

 
people/drbohlav.txt · Last modified: 2018/04/18 12:04 by drbohlav