将网卡设为混杂模式_混杂模式
混杂模式1、指一台机器的网卡能够接收所有经过它的数据包,而不论其目的地址是否是它。2、一般计算机网卡都工作在非混杂模式下,如果设置网卡为混杂模式需要root权限linux下设置1、设置混杂模式:ifconfig eth0 promisc2、取消混杂模式:ifconfig eth0 -promiscwindos下通过特定的软件实现通过程序设置网卡为非混杂模式:struct ifreq 结构体可...
混杂模式
1、指一台机器的网卡能够接收所有经过它的数据包,而不论其目的地址是否是它。
2、一般计算机网卡都工作在非混杂模式下,如果设置网卡为混杂模式需要root权限
linux下设置
1、设置混杂模式:ifconfig eth0 promisc
2、取消混杂模式:ifconfig eth0 -promisc
windos下通过特定的软件实现
通过程序设置网卡为非混杂模式:
struct ifreq 结构体可以保存网卡的所有信息:
struct ifreq { #define IFHWADDRLEN 6 union { char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ } ifr_ifrn; union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[IFNAMSIZ]; /* Just fits the size */ char ifru_newname[IFNAMSIZ]; void __user * ifru_data; struct if_settings ifru_settings; } ifr_ifru; }; #define ifr_name ifr_ifrn.ifrn_name /* interface name */ #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ #define ifr_addr ifr_ifru.ifru_addr /* address */ #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ #define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ #define ifr_flags ifr_ifru.ifru_flags /* flags */ #define ifr_metric ifr_ifru.ifru_ivalue /* metric */ #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ #define ifr_map ifr_ifru.ifru_map /* device map */ #define ifr_slave ifr_ifru.ifru_slave /* slave device */ #define ifr_data ifr_ifru.ifru_data /* for use by interface */ #define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */ #define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */ #define ifr_qlen ifr_ifru.ifru_ivalue /* Queue length */ #define ifr_newname ifr_ifru.ifru_newname /* New name */ #define ifr_settings ifr_ifru.ifru_settings /* Device/proto settings*/
struct ifreq ethref;
更多推荐
所有评论(0)