1、linux下网卡常用的几种模式说明:
广播方式:该模式下的网卡能够接收网络中的广播信息。
组播方式:设置在该模式下的网卡能够接收组播数据。
直接方式:在这种模式下,只有目的网卡才能接收该数据。
混杂模式:在这种模式下的网卡能够接收一切通过它的数据,而不管该数据是否
2、查看、添加和取消混杂模式
a、查看网卡模式
[[email protected] ~]# ifconfig -a
ens32: flags=4163<UP,broADCAST,RUNNING,MulTICAST> mtu 1500
inet 10.203.12.88 netmask 255.255.255.0 broadcast 10.203.12.255
inet6 fe80::250:56ff:feb3:2253 prefixlen 64 scopeID 0x20
ether 00:50:56:b3:22:53 txqueuelen 1000 (Ethernet)
RX packets 2800921171 bytes 2087772292594 (1.8 TiB)
RX errors 0 dropped 61583 overruns 0 frame 0
TX packets 2328391024 bytes 1651122431491 (1.5 TiB)
TX errors 0 dropped 0 overruns 0 carrIEr 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeID 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 287928092 bytes 25694088025 (23.9 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 287928092 bytes 25694088025 (23.9 GiB)
TX errors 0 dropped 0 overruns 0 carrIEr 0 collisions 0
b、添加ens32网卡的混杂模式
[[email protected] ~]# ifconfig ens32 promisc
[[email protected] ~]# ifconfig -a
ens32: flags=4419<UP,PROMISC,MulTICAST> mtu 1500
inet 10.203.12.88 netmask 255.255.255.0 broadcast 10.203.12.255
inet6 fe80::250:56ff:feb3:2253 prefixlen 64 scopeID 0x20
ether 00:50:56:b3:22:53 txqueuelen 1000 (Ethernet)
RX packets 2800927421 bytes 2087779226027 (1.8 TiB)
RX errors 0 dropped 61585 overruns 0 frame 0
TX packets 2328394266 bytes 1651123460792 (1.5 TiB)
TX errors 0 dropped 0 overruns 0 carrIEr 0 collisions 0
lo: flags=73<UP,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeID 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 287929365 bytes 25694221536 (23.9 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 287929365 bytes 25694221536 (23.9 GiB)
TX errors 0 dropped 0 overruns 0 carrIEr 0 collisions 0
c、除去ens32网卡的混杂模式
[[email protected] ~]# ifconfig ens32 -promisc
[[email protected] ~]# ifconfig -a
ens32: flags=4163<UP,MulTICAST> mtu 1500
inet 10.203.12.88 netmask 255.255.255.0 broadcast 10.203.12.255
inet6 fe80::250:56ff:feb3:2253 prefixlen 64 scopeID 0x20
ether 00:50:56:b3:22:53 txqueuelen 1000 (Ethernet)
RX packets 2800929338 bytes 2087779370583 (1.8 TiB)
RX errors 0 dropped 61607 overruns 0 frame 0
TX packets 2328396280 bytes 1651123608090 (1.5 TiB)
TX errors 0 dropped 0 overruns 0 carrIEr 0 collisions 0
lo: flags=73<UP,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeID 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 287931015 bytes 25694392926 (23.9 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 287931015 bytes 25694392926 (23.9 GiB)
TX errors 0 dropped 0 overruns 0 carrIEr 0 collisions 0
实际案例问题?--------------------------------------------------
容器上不了网,容器Ping不通网关
宿主机上有bond0 网卡
将 真实网卡设置成混杂模式
ifconfig bond0 promisc
ifconfig br0 promisc
ifconfig enp2s0f0 promisc
ifconfig enp2s0f1 promisc
稍等2分钟,就可以拼通网关
永久生效: 追加到/etc/profile
# add promiscfor i in `ifconfig|egrep "^en|^b"|awk -F ":" '{print }'`do ifconfig $i promisc ifconfig $idone总结
以上是内存溢出为你收集整理的linux 网卡的混杂模式的取消全部内容,希望文章能够帮你解决linux 网卡的混杂模式的取消所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)