Skip to content

Instantly share code, notes, and snippets.

@vanics
Forked from mefellows/tools.md
Created November 23, 2019 21:17
Show Gist options
  • Save vanics/feb98b7584cf9a2d710e72feaebb9fa2 to your computer and use it in GitHub Desktop.
Save vanics/feb98b7584cf9a2d710e72feaebb9fa2 to your computer and use it in GitHub Desktop.

Revisions

  1. @mefellows mefellows revised this gist Aug 26, 2015. 1 changed file with 29 additions and 14 deletions.
    43 changes: 29 additions & 14 deletions tools.md
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,6 @@
    # *nix Networking Tools Cheat Sheet

    <!-- MarkdownTOC -->

    - Network Performance
    - iperf (all)
    - a name="firewall"> Packet and Firewall filtering
    - a name="pfctl"> pfctl + dnctl (MacOSX Yosemite+)
    - a name="ipfw"> ipfw (FreeBSD/OpenBSD)
    - a name="iptables"> iptables (Linux)
    - a name="links"> Links

    <!-- /MarkdownTOC -->


    ## <a name="perf"></a> Network Performance
    ##<a name="perf"></a> Network Performance

    ### <a name="iperf"></a> iperf (all)

    @@ -35,6 +22,13 @@ You should get a throughput in (GMk)bits/sec

    ###<a name="pfctl"></a> pfctl + dnctl (MacOSX Yosemite+)

    #### List Rules

    ```
    sudo dnctl list
    sudo pfctl -sa -v -v
    ```

    ####<a name="shape"></a> Shape traffic
    ```
    (cat /etc/pf.conf && echo "dummynet-anchor \"mop\"" && echo "anchor \"mop\"") | sudo pfctl -f -
    @@ -58,8 +52,29 @@ iperf -c localhost -t 5
    ####<a name="delay"></a> Delay

    Delays packet transmission by 20ms:

    ```
    sudo dnctl pipe 1 config delay 20
    ```

    ####<a name="packet"></a> Simulate Packet Loss

    Drop 35% of packets on the pipe:

    ```
    sudo dnctl pipe 1 config plr 0.35
    ```

    #### No error

    ```
    sudo dnctl pipe 1 config plr .35
    sudo dnctl pipe 1 config noerror
    ```

    Don't report the error back to the sender - simulate loss at a remote router

    ####<a name="undo"></a> Undo

    To undo whatever mess you've created back to the default...
  2. @mefellows mefellows revised this gist Aug 26, 2015. 1 changed file with 47 additions and 29 deletions.
    76 changes: 47 additions & 29 deletions tools.md
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,45 @@
    # *nix Networking Tools Cheat Sheet

    ## Packet and Firewall filtering
    <!-- MarkdownTOC -->

    ### pfctl + dnctl (MacOSX Yosemite+)
    - Network Performance
    - iperf (all)
    - a name="firewall"> Packet and Firewall filtering
    - a name="pfctl"> pfctl + dnctl (MacOSX Yosemite+)
    - a name="ipfw"> ipfw (FreeBSD/OpenBSD)
    - a name="iptables"> iptables (Linux)
    - a name="links"> Links

    <!-- /MarkdownTOC -->


    ## <a name="perf"></a> Network Performance

    ### <a name="iperf"></a> iperf (all)

    Setup the server:

    ```
    (cat /etc/pf.conf && echo "dummynet-anchor \"mop\"" && echo "anchor \"mop\"") | sudo pfctl -f -
    echo "dummynet in quick proto tcp from any to any port 5001 pipe 1" | sudo pfctl -a mop -f -
    sudo dnctl pipe 1 config bw 1Mbit/s
    iperf -s
    ```

    To undo...
    Run the client against the server for 7 seconds:

    ```
    sudo dnctl -q flush
    sudo pfctl -f /etc/pf.conf
    iperf -c localhost -t 7
    ```

    You should get a throughput in (GMk)bits/sec

    ##<a name="firewall"></a> Packet and Firewall filtering

    ###<a name="pfctl"></a> pfctl + dnctl (MacOSX Yosemite+)

    ####<a name="shape"></a> Shape traffic
    ```
    (cat /etc/pf.conf && echo "dummynet-anchor \"mop\"" && echo "anchor \"mop\"") | sudo pfctl -f -
    echo "dummynet in quick proto tcp from any to any port 5001 pipe 1" | sudo pfctl -a mop -f -
    sudo dnctl pipe 1 config bw 1Mbit/s
    ```

    Observe traffic is now shaped to 100Mbit/s:
    @@ -23,41 +48,34 @@ Observe traffic is now shaped to 100Mbit/s:
    iperf -s -D # Run as Daemon (-D)
    iperf -c localhost -t 5
    ```

    > ------------------------------------------------------------
    > Client connecting to localhost, TCP port 5001
    > TCP window size: 144 KByte (default)
    > ------------------------------------------------------------
    > [ 5] local 127.0.0.1 port 59573 connected with 127.0.0.1 port 5001
    > ------------------------------------------------------------
    > Client connecting to localhost, TCP port 5001
    > TCP window size: 144 KByte (default)
    > ------------------------------------------------------------
    > [ 5] local 127.0.0.1 port 59573 connected with 127.0.0.1 port 5001
    > [ ID] Interval Transfer Bandwidth
    > [ 5] 0.0- 5.0 sec 60.5 MBytes 101 Mbits/sec
    ### ipfw (FreeBSD/OpenBSD)

    ### iptables (Linux)

    ## Network Performance
    ####<a name="delay"></a> Delay

    ### iperf (all)
    ####<a name="packet"></a> Simulate Packet Loss

    I perf
    ####<a name="undo"></a> Undo

    Setup the server:
    To undo whatever mess you've created back to the default...

    ```
    iperf -s
    sudo dnctl -q flush
    sudo pfctl -f /etc/pf.conf
    ```

    Run the client against the server for 7 seconds:

    ```
    iperf -c localhost -t 7
    ```
    ###<a name="ipfw"></a> ipfw (FreeBSD/OpenBSD)

    You should get a throughput in (GMk)bits/sec
    ###<a name="iptables"></a> iptables (Linux)


    ## Links
    ##<a name="links"></a> Links

    * https://gist.github.com/tracphil/4353170
    *
  3. @mefellows mefellows revised this gist Aug 26, 2015. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions tools.md
    Original file line number Diff line number Diff line change
    @@ -23,11 +23,12 @@ Observe traffic is now shaped to 100Mbit/s:
    iperf -s -D # Run as Daemon (-D)
    iperf -c localhost -t 5
    ```
    > ------------------------------------------------------------
    > Client connecting to localhost, TCP port 5001
    > TCP window size: 144 KByte (default)
    > ------------------------------------------------------------
    > [ 5] local 127.0.0.1 port 59573 connected with 127.0.0.1 port 5001

    > ------------------------------------------------------------
    > Client connecting to localhost, TCP port 5001
    > TCP window size: 144 KByte (default)
    > ------------------------------------------------------------
    > [ 5] local 127.0.0.1 port 59573 connected with 127.0.0.1 port 5001
    > [ ID] Interval Transfer Bandwidth
    > [ 5] 0.0- 5.0 sec 60.5 MBytes 101 Mbits/sec
  4. @mefellows mefellows revised this gist Aug 26, 2015. 1 changed file with 50 additions and 1 deletion.
    51 changes: 50 additions & 1 deletion tools.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,34 @@

    ## Packet and Firewall filtering

    ### pfctl (MacOSX Yosemite+)
    ### pfctl + dnctl (MacOSX Yosemite+)


    ```
    (cat /etc/pf.conf && echo "dummynet-anchor \"mop\"" && echo "anchor \"mop\"") | sudo pfctl -f -
    echo "dummynet in quick proto tcp from any to any port 5001 pipe 1" | sudo pfctl -a mop -f -
    sudo dnctl pipe 1 config bw 1Mbit/s
    ```

    To undo...
    ```
    sudo dnctl -q flush
    sudo pfctl -f /etc/pf.conf
    ```

    Observe traffic is now shaped to 100Mbit/s:

    ```
    iperf -s -D # Run as Daemon (-D)
    iperf -c localhost -t 5
    ```
    > ------------------------------------------------------------
    > Client connecting to localhost, TCP port 5001
    > TCP window size: 144 KByte (default)
    > ------------------------------------------------------------
    > [ 5] local 127.0.0.1 port 59573 connected with 127.0.0.1 port 5001
    > [ ID] Interval Transfer Bandwidth
    > [ 5] 0.0- 5.0 sec 60.5 MBytes 101 Mbits/sec
    ### ipfw (FreeBSD/OpenBSD)

    @@ -11,3 +38,25 @@
    ## Network Performance

    ### iperf (all)

    I perf

    Setup the server:

    ```
    iperf -s
    ```

    Run the client against the server for 7 seconds:

    ```
    iperf -c localhost -t 7
    ```

    You should get a throughput in (GMk)bits/sec


    ## Links

    * https://gist.github.com/tracphil/4353170
    *
  5. @mefellows mefellows created this gist Aug 26, 2015.
    13 changes: 13 additions & 0 deletions tools.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    # *nix Networking Tools Cheat Sheet

    ## Packet and Firewall filtering

    ### pfctl (MacOSX Yosemite+)

    ### ipfw (FreeBSD/OpenBSD)

    ### iptables (Linux)

    ## Network Performance

    ### iperf (all)