常用linux 命令,linux命令


一 网络参数设置命令

 1.ifconfig :查询、设置网卡与IP网段等相关参数

    1.1 man手册定义

    

DESCRIPTION
       Ifconfig  is used to configure the kernel-resident network interfaces.  It is used at boot time to set up
       interfaces as necessary.  After that, it is usually only needed when debugging or when system  tuning  is
       needed.

       If  no arguments are given, ifconfig displays the status of the currently active interfaces.  If a single
       interface argument is given, it displays the status of the given interface only; if a single -a  argument
       is  given,  it displays the status of all interfaces, even those that are down.  Otherwise, it configures
       an interface.

简译: ifconfig 习惯用于配置kernel-resident 网络接口,一般在启动时设置必要的接口。也用于debug和系统调试。

如果没有参数 会列出当前激活(up status)的网络接口

如果接一个网络接口参数(ifconfig eth0),会输出该接口的配置

如果后面参数是-a, 会输出所有的网络接口(up 和down staus的网络接口)

 

1.2 命令输出简述

[root@test_1 net]# ifconfig
eth0      Link encap:Ethernet  HWaddr 84:2B:2B:94:F7:7D  
          inet addr:192.168.2.241  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::862b:2bff:fe94:f77d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1546524 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1652650 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:754067360 (719.1 MiB)  TX bytes:1474728958 (1.3 GiB)
          Interrupt:18 

eth0:1    Link encap:Ethernet  HWaddr 84:2B:2B:94:F7:7D  
          inet addr:192.168.2.242  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 

eth0:2    Link encap:Ethernet  HWaddr 84:2B:2B:94:F7:7D  
          inet addr:192.168.2.243  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:594 errors:0 dropped:0 overruns:0 frame:0
          TX packets:594 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:51885 (50.6 KiB)  TX bytes:51885 (50.6 KiB)

。eth0:网卡的代号,也有lo这个loopback。

· HWaddr:网卡的硬件地址,习惯称为MAC。

· inet addr:IPv4的IP地址,后续的Bcase、Mask分别代表的是Broadcast与Netmask。

· inet6 addr:是IPv6的版本的IP,我们没有使用,所以略过。

· RX:那一行代表的是网络由启动到目前为止的数据包接收情况,packets代表数据包数、errors代表数据包发生错误的数量、dropped代表数据包由于有问题而遭丢弃的数量等。

· TX:与RX相反,为网络由启动到目前为止的传送情况。

· collisions:代表数据包碰撞的情况,如果发生太多次,表示你的网络状况不太好。

· txqueuelen:代表用来传输数据的缓冲区的储存长度。

· RX Bytes、TX Bytes:总传送、接收的字节总量。

· Interrupt、Memory:网卡硬件的数据,IRQ岔断与内存地址。

通过观察上述的资料,大致上可以了解到你的网络情况,尤其是RX、TX内的error数量,以及是否发生严重的collision情况,都是需要注意的。

相关内容