218 lines
6.9 KiB
HTML
218 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; font-src 'self' data:; img-src 'self' data:; connect-src 'self'; base-uri 'self'; form-action 'self' https://defcon.social https://bsky.app;">
|
|
<meta http-equiv="X-Content-Type-Options" content="nosniff">
|
|
<link rel="stylesheet" href="../assets/css/style.css">
|
|
<link rel="icon" type="image/x-icon" href="../favicon.ico">
|
|
<script>
|
|
// Apply theme immediately to prevent flash
|
|
(function() {
|
|
const theme = localStorage.getItem('theme') ||
|
|
(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
})();
|
|
</script>
|
|
<title>iftop Cheatsheet - Cheatsheets - Launch Pad</title>
|
|
</head>
|
|
<body>
|
|
<button class="theme-toggle" id="themeToggle" aria-label="Toggle dark mode">
|
|
<svg class="theme-icon theme-icon-moon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
|
|
<svg class="theme-icon theme-icon-sun" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: none;"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>
|
|
</button>
|
|
<br/><br/>
|
|
<div class="name">
|
|
__ _______________________ _________._________________________
|
|
\_ _____/ \______ \ / _ \ / _____/ / _____/ | | \_ _____/
|
|
| __) | _/ / /_\ \ / \ ___ / \ ___ | | | __)_
|
|
| \ | | \ / | \ \ \_\ \ \ \_\ \ | |___ | \
|
|
\___ / |____|_ / \____|__ / \______ / \______ / |_______ \ /_______ /
|
|
\/ \/ \/ \/ \/ \/ \/
|
|
</div>
|
|
<div class="blog-page-header">
|
|
<div class="blog-header-content">
|
|
<a href="/cheatsheets" class="back-link" title="Back to Cheatsheets">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="42" height="42" viewBox="0 0 24 24" class="home-icon"><path fill="currentColor" d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>
|
|
</a>
|
|
<h1 class="blog-page-title">iftop Cheatsheet</h1>
|
|
</div>
|
|
</div>
|
|
<div class="blog-post-container">
|
|
<div class="blog-posts-container" style="max-width: 900px; margin: 0 auto;">
|
|
<div class="blog-post">
|
|
<div class="blog-post-content">
|
|
<p><a href="index.html">← Back to cheatsheets</a></p>
|
|
<p><a href="../index.html">← Home</a></p>
|
|
<hr>
|
|
<p>iftop displays bandwidth usage on an interface by host connection.</p>
|
|
<hr>
|
|
<h2>Basic Usage</h2>
|
|
<ul>
|
|
<li>sudo iftop - Start on default interface</li>
|
|
</ul>
|
|
<ul>
|
|
<li>sudo iftop -i <interface> - Monitor specific interface</li>
|
|
</ul>
|
|
<ul>
|
|
<li>sudo iftop -i eth0 - Monitor eth0 interface</li>
|
|
</ul>
|
|
<ul>
|
|
<li>sudo iftop -i wlan0 - Monitor wlan0 interface</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Command Line Options</h2>
|
|
<ul>
|
|
<li>-i <interface> - Specify interface</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-n - Disable hostname lookup (show IPs)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-N - Don't convert port numbers to service names</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-b - Display in bytes/sec (default is bits/sec)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-B - Display in bytes/sec (alternative)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-t - Text-only mode (no bar graph)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-L <num> - Print length of screen</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-p - Promiscuous mode</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-P - Show ports</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-f <filter> - Apply BPF filter</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-F <net/mask> - Show traffic flows to/from network</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Interactive Commands</h2>
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li>j or ↓ - Scroll down</li>
|
|
</ul>
|
|
<ul>
|
|
<li>k or ↑ - Scroll up</li>
|
|
</ul>
|
|
<ul>
|
|
<li>h or ? - Show help</li>
|
|
</ul>
|
|
<ul>
|
|
<li>q - Quit</li>
|
|
</ul>
|
|
<h3>Display Toggles</h3>
|
|
<ul>
|
|
<li>n - Toggle DNS name resolution</li>
|
|
</ul>
|
|
<ul>
|
|
<li>N - Toggle service name vs port number</li>
|
|
</ul>
|
|
<ul>
|
|
<li>p - Toggle port display</li>
|
|
</ul>
|
|
<ul>
|
|
<li>s - Toggle source host display</li>
|
|
</ul>
|
|
<ul>
|
|
<li>d - Toggle destination host display</li>
|
|
</ul>
|
|
<ul>
|
|
<li>t - Cycle display modes (2s, 10s, 40s averages)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>b - Toggle bar graph mode</li>
|
|
</ul>
|
|
<h3>Sorting</h3>
|
|
<ul>
|
|
<li>< - Sort by source</li>
|
|
</ul>
|
|
<ul>
|
|
<li>> - Sort by destination</li>
|
|
</ul>
|
|
<ul>
|
|
<li>o - Order by current sort method</li>
|
|
</ul>
|
|
<h3>Filtering</h3>
|
|
<ul>
|
|
<li>l - Set screen filter</li>
|
|
</ul>
|
|
<ul>
|
|
<li>L - Set and lock screen filter</li>
|
|
</ul>
|
|
<ul>
|
|
<li>! - Run shell command in filter line</li>
|
|
</ul>
|
|
<ul>
|
|
<li>1-9 - Filter by protocol type</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Configuration</h2>
|
|
<h3>Config File Location</h3>
|
|
<ul>
|
|
<li>No main config file (runs interactively)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Options passed via command line or aliases</li>
|
|
</ul>
|
|
<h3>Example Aliases</h3>
|
|
<p>Add to your shell config:</p>
|
|
<pre><code># Quick interface monitoring
|
|
alias iftop-eth0='sudo iftop -i eth0 -n -N'
|
|
alias iftop-wlan0='sudo iftop -i wlan0 -n -N'
|
|
|
|
# Bytes per second display
|
|
alias iftop-b='sudo iftop -b -n -N'</code></pre>
|
|
<hr>
|
|
<h2>Tips</h2>
|
|
<ul>
|
|
<li>Run with root privileges (sudo) to capture on interfaces</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use -n and -N flags for less distraction in noisy networks</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Exit with q, use filters in combination with command options to reduce data</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Useful for spotting sudden spikes or bandwidth hogs in real time</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Turn off DNS and service name lookups (-n -N) for quicker, clearer output</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Press h while running to see a key reference screen</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use filters (-f) to focus on specific traffic</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Watch the averages (2s, 10s, 40s) to see both momentary and sustained usage patterns</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use -b flag to display in bytes/sec if that's more intuitive</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Text-only mode (-t) useful for logging or screenshots</li>
|
|
</ul>
|
|
<hr>
|
|
<p><a href="index.html">← Back to cheatsheets</a></p>
|
|
<p><a href="../index.html">← Home</a></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script async type="text/javascript" src="../blog/analytics.js"></script>
|
|
<script src="../theme.js"></script>
|
|
</body>
|
|
</html> |