zoukankan      html  css  js  c++  java
  • linux网络查看及配置相关命令

    1、查看网卡配置情况ifconfig

    Ifconfig |more                                 查看所有网卡的配置情况

    ifconfig enp6s0 192.168.5.160 netmask 255.255.255.0 临时修改enp6s0的ip和掩码

    watch ifconfig enp6s0                            查看网卡enp6s0的网络数据包情况

    2、开启/关闭某个网卡

    ifup 网卡名

    ifdown 网卡名 都是根据找到对应ifcfg-xx文件来设置,找不到就会设置失败

    如果用ifconfig修改过网络参数,则通过ifconfig eth0 down关闭网卡

    3、网卡文件配置

    进入目录 cd /etc/sysconfig/network-scripts

    找到需配置的网卡ifcfg-enoxxx文件,按以下说明配置:

    vi ifcfg-enoxxx

    HWADDR=00:0c:29:8f:99:4b                        //网卡MAC地址

    TYPE=Ethernet                                   //以太网

    BOOTPROTO=static                                //默认会应该是dhcp,static表示静态IP

    DEFROUTE=yes

    PEERDNS=yes

    PEERROUTES=yes

    IPV4_FAILURE_FATAL=yes

    NAME=eno16777736                                 //网卡名称

    UUID=94271989-6217-457d-a88f-40fb635af64c        //UUID号,没事不要动它,否则你会后悔的。。

    # DEVICE=eno16777736

    ONBOOT=yes                                       //开机自动启动

    IPADDR=192.168.5. 150                             //IP地址

    NETNASK=255.255.255.0                            //子网掩码

    GATEWAY=192.168.66.1                             //网关

    DNS1=61.139.2.69                                    //DNS

    # DEVICE=eth0

    配置完成后

    service network restart 重启网络

    网络问题解决

    多个网卡时,检查网卡ip和dns是否有冲突,屏蔽造成冲突的网卡ip和dns

    配置 vim /etc/resolv.conf

    配置dns服务器及备用服务器8.8.8.8 重启网卡

    nameserver 61.139.2.69

    nameserver 8.8.8.8

    4、查看网络流量vnstat

    yum install epel-release

    yum install -y vnstat                  安装vnstat工具

    vnstat --create –i enp7s0              安装所查看网卡的数据库

    vnstat -i enp7s0 -l                    #查看实时流量情况

    5、抓包工具tcpdump

    安装:yum install tcpdump

    使用:tcpdump -i eth0 查看指定接口的数据包

    tcpdump host ip查看指定ip的数据包

          tcpdump -i enp6s0 host 192.168.5.160 -w /home/wangjing/baotest.cap抓IP地址为160,网卡为enp6s0的包

         tcpdump -i enp6s0 host 192.168.1.160 and port 80 -w /tmp/xxx.cap 抓IP地址为160,端口为80,网卡为enp6s0的包

  • 相关阅读:
    Java基础——clone()方法浅析
    Unity shader error: “Too many texture interpolators would be used for ForwardBase pass”
    ar 解压一个.a文件报错: xxx.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
    How to set up "lldb_codesign" certificate!
    Unity-iPhone has Conflicting Provisioning Settings
    ETC1/DXT1 compressed textures are not supported when publishing to iPhone
    Xcode 提交APP时遇到 “has one iOS Distribution certificate but its private key is not installed”
    XCode iOS之应用程序标题本地化
    苹果电脑(Mac mini或Macbook或iMac)恢复出厂设置
    Unity 4.7 导出工程在XCode10.1上编译报错
  • 原文地址:https://www.cnblogs.com/yjiajia/p/13378306.html
Copyright © 2011-2022 走看看