Bartosz Wojciechowski
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Open vSwitch Demo ## Prosta sieć z domyślnym kontrolerem Sieć symuluje sytuację, w której mamy **2 fizyczne maszyny** i na każdej z nich po **2 maszyny wirtualne**. Dla uproszczenia maszyny fizyczne nie są zawarte w symulacji. Na początku chcemy mieć połączenia pomiędzy wszystkimi maszynami wirtualnymi. Usuwamy poprzednią konfigurację `sudo mn -c` Tworzymy sieć jak na schemacie -- 4 hosty, 3 switche `sudo mn --topo=tree,depth=2,fanout=2 --controller ovsc` Sprawdźmy czy sieć jest zgodna ze schematem ``` > nodes > net ``` Możemy zobaczyć, że działa sterownik OpenFlow `ps -ax | grep controller` Jak sieć wygląda z perspektywy Open vSwitch? `sudo ovs-vsctl show` > Utworzone zostały 3 switche, zgodnie z topologią. Są podłączone do kontrolera. Brak informacji o VLAN. > `fail_mode` dotyczy sytuacji, gdy brak połączenia z kontrolerem. `secure` -- switch nie będzie obsługiwał ruchu po utracie połączenia z kontrolerem. `standalone` -- po 3 nieudanych próbach switch zacznie działać jako zwykły MAC-learning switch. Sprawdźmy połączenia między wybranymi hostami ```sh > h1 ping -c 2 h2 > h1 ping -c 2 h3 > h1 ping -c 2 h4 ``` > Połączenia działają ## Konfiguracja VLAN Nowa konfiguracja. Chcemy wprowadzić ograniczenie, który pozwolu na komnikację jedynie między **h1-h3** oraz **h2-h4**. Dodajemy tagi do portów na switchu s2 ```sh sudo ovs-vsctl list-ports s2 sudo ovs-vsctl del-port s2 s2-eth1 sudo ovs-vsctl del-port s2 s2-eth2 sudo ovs-vsctl list-ports s2 sudo ovs-vsctl add-port s2 s2-eth1 tag=100 # h1-s2 sudo ovs-vsctl add-port s2 s2-eth2 tag=200 # h2-s2 ``` Podgląd nowej konfiguracji `sudo ovs-vsctl show` To samo co wyżej dla drugiego switcha ```sh sudo ovs-vsctl del-port s3 s3-eth1 sudo ovs-vsctl del-port s3 s3-eth2 sudo ovs-vsctl add-port s3 s3-eth1 tag=100 # h3-s3 sudo ovs-vsctl add-port s3 s3-eth2 tag=200 # h4-s3 ``` Sprawdźmy `> h1 ping h2` Nadal działa, ponieważ nie ma polecenia od kontrolera, które nakazywałoby wykorzystanie VLAN do kontroli ruchu w sieci. ## Wykorzystanie sterownika Faucet #### Przygotowanie maszyny na której uruchomiony będzie sterownik Sterownik uruchamiamy na Ubuntu 18.04, adres IP ... Na początek - instalacja pythona i faucet ```sh apt install python3-dev python3-pip pip3 install setuptools pip3 install wheel pip3 install faucet ``` Konfigurujemy sterownik `/etc/faucet/faucet.yaml` Uruchamiamy `faucet --verbose` W razie problemów pomocny jest log `/var/log/faucet/faucet.log` #### Wracamy do Open vSwitcha Nadajemy identyfikatory switchom -- zgodnie z `dp_id` z pliku konfiguracyjnego sterownika ```sh sudo ovs-vsctl set bridge s1 other-config:datapath-id=0000000000000001 sudo ovs-vsctl set bridge s2 other-config:datapath-id=0000000000000002 sudo ovs-vsctl set bridge s3 other-config:datapath-id=0000000000000003 ``` Ustalamy numerację portów według kolejności z pliku konfiguracyjnego sterownika ```sh sudo ovs-vsctl set interface "s2-eth1" ofport_request=1 # h1 sudo ovs-vsctl set interface "s2-eth2" ofport_request=2 # h2 sudo ovs-vsctl set interface "s2-eth3" ofport_request=3 # s1 sudo ovs-vsctl set interface "s3-eth1" ofport_request=1 # h3 sudo ovs-vsctl set interface "s3-eth2" ofport_request=2 # h4 sudo ovs-vsctl set interface "s3-eth3" ofport_request=3 # s1 sudo ovs-vsctl set interface "s1-eth1" ofport_request=1 # s2 sudo ovs-vsctl set interface "s1-eth2" ofport_request=2 # s4 ``` Podłączamy switche do sterownika ```sh controler_address=192.168.1.196 sudo ovs-vsctl set-controller s1 tcp:$controler_address:6653 tcp:$controler_address:6654 sudo ovs-vsctl set-controller s2 tcp:$controler_address:6653 tcp:$controler_address:6654 sudo ovs-vsctl set-controller s3 tcp:$controler_address:6653 tcp:$controler_address:6654 ``` Uruchamiamy Wireshark na s1-eth1, żeby widzieć efekty Sprawdźmy pingi ``` > h1 ping h3 > h1 ping h2 ``` Działa! ## ACL z wykorzystaniem Open vSwitch i sterownika Faucet Cel: vlan100 -- ping zabroniony vlan200 -- brak restrykcji Sprawdźmy pingi przed zmianami ``` > h1 ping h3 > h2 ping h4 ``` W pliku `/etc/faucet/acls.yaml` definiujemy reguły ACL W pliku konfiguracyjnym sterownika ładujemy reguły oraz stosujemy je do poszczególny VLANów `/etc/faucet/faucet.yaml` Restartujemy sterownik ```sh ctrl+c faucet --verbose ``` Sprawdźmy pingi po zmianach ``` > h1 ping h3 > h2 ping h4 ``` #### Dodatkowy przykład Ustawmy ACL dla vlan100 tak, żeby pakiety **wysyłane na port 3000** były **kierowane na port 4000** Trzeba dodać 2 reguły w `acls.yaml` oraz podpiąć je pod VLAN w `faucet.yaml` Sprawdźmy zwykły zachowanie z netcat ``` # netcat server: nc -l OWN_ADRESS PORT # netcat client: nc SERVER_ADDRESS PORT > h1 nc -vl 10.0.0.1 3000 & > h3 nc -v 10.0.0.1 3000 ``` A teraz nasłuchujemy na porcie 3000, ale próbujemy łączyć się na porcie 4000 ``` > h1 nc -vl 10.0.0.1 3000 & > h3 nc -v 10.0.0.1 4000 ``` ## QoS -- limitowanie ruchu Odczyt bieżących wartości ```sh sudo ovs-vsctl list interface s2-eth1 |grep ingress_ # h1-s2 sudo ovs-vsctl list interface s3-eth1 |grep ingress_ # h3-s3 ``` Uruchamiamy test ``` > h1 iperf -s & > h3 iperf -c h1 -i 2 -t 180 # -c HOST -i INTERVAL -t TIME ``` ingress_policing_rate -- the maximum rate (in Kbps) that this VM should be allowed to send ingress_policing_burst -- a parameter to the policing algorithm to indicate the maximum amount of data (in Kb) that this interface can send beyond the policing rate. Ograniczamy przepustowość ```sh sudo ovs-vsctl set interface s2-eth1 ingress_policing_rate=10000 sudo ovs-vsctl set interface s2-eth1 ingress_policing_burst=100 sudo ovs-vsctl set interface s3-eth1 ingress_policing_rate=10000 sudo ovs-vsctl set interface s3-eth1 ingress_policing_burst=100 ``` Usuwamy ograniczenie ```sh sudo ovs-vsctl set interface s2-eth1 ingress_policing_rate=0 sudo ovs-vsctl set interface s3-eth1 ingress_policing_rate=0 ``` ---- #### Opcjonalnie -- przed podłączeniem Faucet Wyłączamy sterownik ```sh ps -ax | grep controller kill PID ``` Ręcznie usuwamy flowy, żeby nie czekać aż wygasną `sudo ovs-ofctl del-flows s3` Zmieniamy tryb działania switchy na `standalone` (żeby switch działał bez kontrolera) ```sh sudo ovs-vsctl set-fail-mode s1 standalone sudo ovs-vsctl set-fail-mode s2 standalone sudo ovs-vsctl set-fail-mode s3 standalone ``` Sprawdźmy ``` > h1 ping h3 > h1 ping h2 ``` Udało się uzyskać podział z wykorzystaniem VLANów bez kontrolera ## Dodatkowe informacje (draft, nie do prezentacji) ### Opis narzędzi **ovs-vsctl** -- Utility for querying and configuring Open vSwitch daemon. Na przykład dodawanie/usuwanie switchy, dodawanie/usuwanie portów, podłączanie/odłączanie kontrolerów do switchy http://www.openvswitch.org/support/dist-docs/ovs-vsctl.8.pdf **ovs-ofctl** -- tool for monitoring and administering OpenFlow switches. It can also show the current state of an OpenFlow switch, including features, configuration, and table entries. It should work with any OpenFlow switch, not just Open vSwitch. http://www.openvswitch.org/support/dist-docs/ovs-ofctl.8.pdf Komunikuje się ze switchem za pomocą protokołu OpenFlow, ale niezależnie od kontrolera. Na przykład chcąc odpytać s2 możemy użyć skrótu sudo ovs-ofctl dump-ports s2 który jest rozwijany jako sudo ovs-ofctl dump-ports unix:/var/run/openvswitch/s2.mgmt **ovs-dpctl** -- Open vSwitch kernal datapahs manipulation **ovs-appctl** -- Utility for managing Open vSwitch daemons `sudo ovs-appctl list-commands` ---- **Mininet** - `--controller=` - ref = Controller (binarka: controller) + można uruchomić coś innego - ovsc = OVSController (binarka: ovs-testcontroller/ovs-controller) "ovs-controller manages any number of remote switches over OpenFlow protocol, causing them to function as L2 MAC-learning switches or hub." - remote = RemoteController (poza mininet) - default = DefaultController - `--switch=ovs` ### Przydatne linki Wizualizacja sieci mininet (na podstawie `> net`) https://achille.github.io/mininet-dump-visualizer/ ### Źródła Faucet https://docs.faucet.nz/en/latest/tutorials/acls.html https://docs.faucet.nz/en/latest/configuration.html Faucet + Open vSwitch https://docs.openvswitch.org/en/latest/tutorials/faucet/ Open vSwitch http://docs.openvswitch.org/en/latest/howto/vlan/ ! http://docs.openvswitch.org/en/latest/faq/vlan/ http://docs.openvswitch.org/en/latest/ref/ (linki na dole) http://docs.openvswitch.org/en/latest/tutorials/ovs-advanced/ http://networkstatic.net/openflow-proactive-vs-reactive-flows/ https://superuser.openstack.org/articles/openvswitch-openstack-sdn/ Mininet http://mininet.org/sample-workflow/ http://mininet.org/blog/page/2/ https://github.com/mininet/mininet/wiki/Introduction-to-Mininet Secure vs standalone https://network-insight.net/2015/11/open-vswitch-ovs-basics/ Cheat sheet, tools within ovs http://therandomsecurityguy.com/openvswitch-cheat-sheet/ QoS w ovs http://docs.openvswitch.org/en/latest/howto/qos/

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully