zoukankan      html  css  js  c++  java
  • 03 ethtool、ifconfig

    网卡文件详解

    修改网卡名

    #修改网卡配置文件名称
    [root@egon~]# cd /etc/sysconfig/network-scripts/
    [root@egon~]# mv ifcfg-ens33 ifcfg-eth0
    
    #修改网卡配置文件设备名称
    [rootegon]# sed -i "s#ens33#eth0#g" ifcfg-eth0
    
    #GRUB添加kernel参数
    [root@egon ~]# vim /etc/sysconfig/grub
    GRUB_CMDLINE_LINUx="rhgb quiet 'net.ifnames=0 biosdevname=0'"
     
    #加载到引导分区
    [rootegon~]# grub2-mkconfig -o /boot/grub2/grub.cfg
    
    #重启系统生效
    reboot
    

    网卡配置文件

    TYPE=Ethernet	#网络类型英特网
    PROXY_METHOD=none
    BROWSER_ONLY=no
    BOOTPROTO=none	#static静态,dhcp动态
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    IPV6_ADDR_GEN_MODE=stable-privacy
    NAME=etho
    UUID=346b47af-447d-45eb-a447-3b63f1a69198
    DEVICE=eth0
    ONBOOT=yes	#网卡服务启动的时候yes表示激活
    IPADDR=192.168.15.100	#IP地址
    PREFIX=24	#子网掩码
    GATEWAY=192.168.15.2	#网关
    DNS1=114.114.114.114
    IPV6_PRIVACY=no
    

    基本网络配置

    查看网卡信息

    # 查看当前系统所连接的所有网卡
    [root@egon ~]# lspci lgrep -i eth
    
    确认网线已经连接好,以eth0 为例
    [rootegon ~]# mii-tool etho
     etho:negotiated 1000baseT-FD flow-control,link ok # link ok网卡能够被识别,并且接了有效的网线
    
    [root@egon ~]# mii-tool eth1
     SIOCGMIIPHY on 'eth' failed: Invalid argument
    网卡虽然能够被识别(网卡已经被驱动了,但不能用:网卡配置错误,网线没接等)
    

    ifconfig

    1、ifconfig-a 查看所有网卡信息(包括未激活的网卡)
    
    2、ifconfig eth0 查看单个网卡信息
    
    3、ifconfig eth0 192.168.1.122 netmask 255.255.255.0临时设定IP和掩码(重启服务或者系统都失效)
    
    4、ifconfig eth0 192.168.1.122/24
    
    5、ifconfig eth:1216802 netmask2552552550配置子接口# 删除:下述两种方式都可以
     ifconfig etho:0 down
     ifconfig eth0:1 de1 192.168.0.2# 删除,不必加掩码
    
    6、开启与关闭
     ifconfig eth0 down | up # 不加载网卡配置文件
     ifdown etho | ifup eth0 # 加载网卡配置文件
     
    7、设置网卡最大传输单元
     ifconfig etho mtu 1500
    
    8、开启关闭模式(了解)
     ifconfig eth0 promisc # 开启繁杂模式
     ifconfig eth0 -promisc 关闭繁杂模式
     ifconfig ens33 multicast 开启多播
     ifconfig ens33 -multicast # 关闭多播
    
     ifconfig eth0 allmulti # 开启 ifconfig etho -allmulti #关闭
    9、添加、删除ipv6地址
     ifconfig eth0 add 3ffe:3240:800:1005::2/64
     ifconfig eth0 del 3ffe:3240:800:1005::2/64
    

    ethtool解决网卡丢包问题

    问题排查

    #丢包排查
    网卡在数据链路层,数据链路层会做校验封装成帧,可以校验是否出错,然后从软件层面分析,是否因为缓冲区太小丢包。
    
    #查看工作模式是否正常
    [root@tecent_cloud ~]# ethtool eth0
    Settings for eth0:
    	Link detected: yes
    	
    #查看CRC检验是否正常
    [root@test1 ~]# ethtool -S eth0 | grep crc
         rx_crc_errors: 0
    
    #这两个没有问题,基本上可以排除物理层面的干扰
    
    #ifconfig查看overruns是否一直在增大,如果查看的结果是一直在增大
    while ture ;do ifconfig eth0 | grep RX | grep overruns ; sleep 1;done
    [root@test1 ~]# while true ;do ifconfig eth0 | grep RX | grep overruns ; sleep 1;done
            RX errors 0  dropped 0  overruns 0  frame 0
            RX errors 0  dropped 0  overruns 0  frame 0
            RX errors 0  dropped 0  overruns 0  frame 0
            RX errors 0  dropped 0  overruns 0  frame 0
    

    解决思路

    调整网卡缓冲区

    [root@tecent_cloud ~]# ethtool -g eth0
    # -g是查看
    Ring parameters for eth0:
    Pre-set maximums:
    RX:		1024
    RX Mini:	0
    RX Jumbo:	0
    TX:		1024
    Current hardware settings:
    RX:		1024
    RX Mini:	0
    RX Jumbo:	0
    TX:		1024
    
    [root@test1 ~]# ethtool -G eth0 rx 2048
    #调大
    [root@test1 ~]# ethtool -G eth0 tx 2048
    #调大
    [root@test1 ~]# ethtool -g eth0 #查看
    Ring parameters for eth0:
    Pre-set maximums:
    RX:		4096
    RX Mini:	0
    RX Jumbo:	0
    TX:		4096
    Current hardware settings:
    RX:		2048
    RX Mini:	0
    RX Jumbo:	0
    TX:		2048
    
  • 相关阅读:
    BlockingQueue(阻塞队列)详解
    异步远程调用线程池队列
    JVM中的五大内存区域划分详解及快速扫盲
    http链接管理器
    influxDB 增加
    ArcGIS的sde数据库连接
    arcgis server注册文件夹
    arcmap编辑oracle数据库
    create database connection
    发布gp服务失败
  • 原文地址:https://www.cnblogs.com/zhaokunhao/p/14629200.html
Copyright © 2011-2022 走看看