Linux中國

如何在 Ubuntu 22.04 中安裝和使用 Wireshark

技術兄弟們,大家好,在這篇文章中我們將介紹如何在 Ubuntu 22.04 中安裝和使用 Wireshark

Wireshark 是自由開源的、跨平台的、基於 GUI 的網路數據包分析器,可用於 Linux、Windows、MacOS、Solaris 等。它實時捕獲網路數據包並以人類可讀的格式呈現它們。它使我們能夠監控微觀層面的網路數據包。它還有一個名為 tshark 的命令行程序,它執行與 Wireshark 相同的功能,但通過終端而不是通過 GUI。

Wireshark 可用於網路故障排除、分析、軟體和通信協議開發,也可用於教育目的。Wireshark 使用名為 pcap 的庫來捕獲網路數據包。

Wireshark 的功能

  • 支持檢查數百種協議
  • 能夠實時捕獲數據包並保存它們以供以後離線分析
  • 一些用於分析數據的過濾器
  • 捕獲的數據可以動態壓縮和解壓縮
  • 支持多種數據分析文件格式,輸出也可以保存為 XML、CSV、純文本格式
  • 可以從乙太網、WiFi、藍牙、USB、幀中繼、令牌環等多種介面捕獲數據

先決條件

  • 預裝 Ubuntu 22.04
  • 具有 sudo 許可權的本地用戶
  • 互聯網連接

Wireshark 安裝步驟

從 Ubuntu 倉庫安裝

Wireshark 包可在默認的 Ubuntu 倉庫中找到,並且可以使用以下命令簡單地安裝。但你可能無法獲得最新版本的 wireshark。

$ sudo apt update
$ sudo apt install wireshark

Apt-Command-Install-Wireshark-Ubuntu

選擇 「Yes」 允許非超級用戶使用 Wireshark 捕獲數據包:

Allow-Non-SuperUsers-To-Capture-Packets-Wireshark-Ubuntu

安裝成功後,訪問 Wireshare UI。從「 活動 Activities 」中搜索 「wireshark」,然後單擊其圖標。

Wireshark-UI-Ubuntu-Linux-Desktop

以上確認你的 Wireshark 安裝已成功完成。

安裝最新的版本

如果要安裝最新版本的 Wireshark,我們必須使用以下 apt 命令啟用官方 Wireshark 倉庫:

$ sudo add-apt-repository ppa:wireshark-dev/stable
$ sudo apt update

現在,安裝最新版本的 Wireshark,運行:

$ sudo apt install wireshark -y

安裝 Wireshark 後,驗證其版本:

$ wireshark --version

Wireshark-Version-Check-Ubuntu-Linux

要允許普通用戶使用 Wireshark 使用和捕獲數據包,請運行以下命令:

$ sudo dpkg-reconfigure wireshark-common

選擇 「Yes」 並按回車鍵。

Allow-Regular-User-Use-Wireshark-Ubuntu

使用 usermod 命令將本地用戶添加到 wireshark 組:

$ sudo usermod -aG wireshark $USER
$ newgrp wireshark

要使上述更改生效,請重新啟動系統。

$ sudo reboot

使用 Wireshark 捕獲數據包

啟動 Wireshark,從「活動」->搜索 「wireshark」。

Access-Wireshark-Ubuntu-Desktop

單擊 Wireshark 圖標,

Choose-Interface-Wireshark-UI-Ubuntu

所有這些都是我們可以捕獲網路數據包的介面。根據你系統上的界面,此頁面可能會有所不同。

我們選擇 「enp0s3」 來捕獲該介面的網路流量。選擇介面後,我們網路上所有設備的網路數據包開始填充(請參閱下面的截圖):

Capturing-Packets-WireShark-UI-Ubuntu

第一次看到此頁面時,我們可能會被此屏幕中顯示的數據淹沒,並且可能會想到如何整理這些數據,但不用擔心,Wireshark 的最佳功能之一就是它的過濾器。

我們可以根據 IP 地址、埠號對數據進行排序/過濾,還可以使用源和目標過濾器、數據包大小等,還可以將 2 個或更多過濾器組合在一起以創建更全面的搜索。我們可以在「 應用顯示過濾器 Apply a Display Filter 」選項卡中編寫過濾器,也可以選擇已創建的規則之一。要選擇預建過濾器,請單擊「旗幟」圖標,然後點擊「應用顯示過濾器」選項卡。

IP-Based-Filtering-WireShark-UI-Ubuntu

我們還可以根據顏色代碼來過濾數據,默認情況下,淺紫色是 TCP 流量,淺藍色是 UDP 流量,黑色標識有錯誤的數據包,要查看這些代碼的含義,請單擊「 查看 View 」->「 顏色規則 Coloring Rules 」,我們也可以更改這些代碼。

Coloring-Rules-WireShark-Ubuntu

獲得所需的結果後,我們可以單擊任何捕獲的數據包以獲取有關該數據包的更多詳細信息,這將顯示有關該網路數據包的所有數據。

要停止捕獲數據包,請單擊紅色停止按鈕,然後將捕獲的數據包保存到文件中。

Save-Captured-Packets-Wireshark-Ubuntu

總結

Wireshark 是一款非常強大的工具,需要一些時間來適應和掌握它,這篇文章將幫助你開始使用。請隨時在下面的評論欄中提出你的疑問或建議。

(題圖:MJ/63c09e75-a3e7-4dbf-ac6f-0233bdd34ad8)

via: https://www.linuxtechi.com/install-use-wireshark-ubuntu/

作者:Pradeep Kumar 選題:lkxed 譯者:geekpi 校對:wxy

本文由 LCTT 原創編譯,Linux中國 榮譽推出


本文轉載來自 Linux 中國: https://github.com/Linux-CN/archive

對這篇文章感覺如何?

太棒了
0
不錯
0
愛死了
0
不太好
0
感覺很糟
0
雨落清風。心向陽

    You may also like

    5 Comments

    1. 350fairfax nordvpn
      I absolutely love your blog and find nearly all of your
      post’s to be just what I’m looking for. Do you
      offer guest writers to write content available for you?
      I wouldn’t mind producing a post or elaborating on a number of the subjects you write in relation to here.

      Again, awesome weblog!

    2. What’s Taking place i’m new to this, I stumbled upon this
      I have found It positively helpful and it has aided me
      out loads. I’m hoping to give a contribution & aid other customers like its aided me.

      Great job.

      My web site; nordvpn coupons inspiresensation (Easyurl.cc)

    3. I’m gone to say to my little brother, that he should also visit this web site on regular basis to obtain updated from
      newest gossip.

      my blog – nordvpn coupons inspiresensation

    4. Saved as a favorite, I really like your website!

      Here is my web blog nordvpn coupons inspiresensation

    5. Whoa! This blog looks just like my old one! It’s on a completely
      different subject but it has pretty much the same layout and design. Superb choice of colors!

      Check out my web blog :: nordvpn coupons inspiresensation (t.co)

    Leave a reply

    您的郵箱地址不會被公開。 必填項已用 * 標註

    這個站點使用 Akismet 來減少垃圾評論。了解你的評論數據如何被處理

    More in:Linux中國