IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Toggle promisc mode of NICs on Linux

    Terry发表于 2014-06-16 04:00:00
    love 0

    简单说,网卡的 promisc 模式(硬要翻译成中文的话,是混杂模式?)会导致网络控制器将该网络上所有的数据包发送给 CPU 不开启的话网络控制器只接收以它为目的地的包。通常用于嗅探或虚拟化环境中。

    Promiscuous mode

    A mode for a wired network interface controller (NIC) or wireless network interface controller (WNIC) that causes the controller to pass all traffic it receives to the CPU rather than passing only the frames that the controller is intended to receive. This mode is normally used for packet sniffing that takes place on a router or on a computer connected to a hub (instead of a switch) or one being part of a WLAN. Interfaces are placed into promiscuous mode by software bridges often used with hardware virtualization.

    用 net-tools 工具集

    开关 promisc 模式

    # ON
    ifconfig promisc
    # OFF
    ifconfig -promisc

    查看网卡是否工作在 promisc 模式下

    方法1: ifconfig 输出中对应的 interface 会有 PROMISC 标记

    方法2: netstat -i 输出 kernel interface table 嫌输出不对齐的可以用 netstat -i | column -t ;-D

    常见的 flag 有

    • B – Broadcast
    • P – Promiscuous
    • M – Multicast
    • R – Running
    • U – Up

    注意: P 也有可能是 Point to Point 如果有看到 sit, gre, tunl 等 interface 就是了,因为用了 IP 隧道协议。

    注意:Arch Linux 早在2011年6月就将 net-tools 标记为 deprecated 了 -_-z

    用 iproute2 工具集

    开关 promisc 模式

    ip link set  promisc on
    ip link set  promisc off

    查看网卡是否运行在 promisc 模式下

    方法1: ip addr 或 ip addr show 输出中会有 PROMISC 标记

    方法2: ip link 或 ip link show 输出中也会有 PROMISC 标记

    另外,和 netstat -i 功能最接近的是 ip -s link

    有意思的是,感觉 ss -tuna / ss -tunap 比 netstat -tulp / netstat -nap 好记多了。

    iproute2 中还有流量控制命令 tc 常用的命令有 tc -s qdisc 要知道更多,就 RTFM 吧 ;-D

    Related posts:

    1. Change IP on-the-fly for Single NIC Linux host
    2. XenServer dom0 被黑案例分享
    3. Btrfs Updates in Linux 3.7 Kernel



沪ICP备19023445号-2号
友情链接