ifconfig:配置或显示网络接口信息

一、语法

onlylove@ubuntu:~$ ifconfig -help
Usage:
  ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
  [add <address>[/<prefixlen>]]
  [del <address>[/<prefixlen>]]
  [[-]broadcast [<address>]]  [[-]pointopoint [<address>]]
  [netmask <address>]  [dstaddr <address>]  [tunnel <address>]
  [outfill <NN>] [keepalive <NN>]
  [hw <HW> <address>]  [mtu <NN>]
  [[-]trailers]  [[-]arp]  [[-]allmulti]
  [multicast]  [[-]promisc]
  [mem_start <NN>]  [io_addr <NN>]  [irq <NN>]  [media <type>]
  [txqueuelen <NN>]
  [[-]dynamic]
  [up|down] ...

  <HW>=Hardware Type.
  List of possible hardware types:
    loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP) 
    slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP) 
    ash (Ash) ether (Ethernet) ax25 (AMPR AX.25) 
    netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel) 
    ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB) 
    arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device) 
    sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI) 
    irda (IrLAP) ec (Econet) x25 (generic X.25) 
    eui64 (Generic EUI-64) 
  <AF>=Address family. Default: inet
  List of possible address families:
    unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6) 
    ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE) 
    ipx (Novell IPX) ddp (Appletalk DDP) ec (Econet) 
    ash (Ash) x25 (CCITT X.25) 
onlylove@ubuntu:~$

二、参数说明

参数说明
-a显示全部接口信息
-v
-s显示摘要信息
<interface> [[<AF>] <address>]设置 interface 网卡 IPv4 地址
<interface> [add <address>[/<prefixlen>]]设置 interface 网卡 IPv6 地址
<interface> [del <address>[/<prefixlen>]]删除 interface 网卡 IPv6 地址
<interface> [[-]broadcast [<address>]]为 interface 网卡设置广播地址
<interface> [[-]pointopoint [<address>]]与指定地址的网络设备建立直接连线
<interface> [netmask <address>]设置 interface 网卡子网掩码
<interface> [dstaddr <address>]设定一个远端地址,建立点对点通信
<interface> [tunnel <address>]建立隧道
<interface> [outfill <NN>]
<interface> [keepalive <NN>]
<interface> [hw <HW> <address>]修改MAC地址
<interface> [ mtu <NN>]设置最大传输单元
<interface> [[-]trailers]
<interface> [[-]arp]指定网卡是否支持arp协议
<interface> [[-]allmulti]设置网卡多播模式
<interface> [multicast]设置网卡组播标志
<interface> [[-]promisc]设置网卡的promiscuous模式
<interface> [mem_start <NN>]设置网络设备在主内存所占用的起始地址
<interface> [io_addr <NN>]设置网络设备的I/O地址
<interface> [irq <NN>]设置网络设备的IRQ
<interface> [media <type>]设置网络设备的媒介类型
<interface> [txqueuelen <NN>]设置网卡传输队列长度
<interface> [[-]dynamic]
<interface> [up|down]up:启动网卡。down:关闭网卡。

三、网卡字段说明

onlylove@ubuntu:~$ ifconfig ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.6.129  netmask 255.255.255.0  broadcast 192.168.6.255
        inet6 fe80::20c:29ff:feb8:de3b  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b8:de:3b  txqueuelen 1000  (Ethernet)
        RX packets 174082  bytes 252913878 (252.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16368  bytes 1171849 (1.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

onlylove@ubuntu:~$
说明参数
UP网卡已启用
BROADCAST网卡支持广播
RUNNING网卡工作中
MULTICAST网卡支持多播
mtu 1500最大传输单元 1500 字节
inet网卡的IP地址
netmask网络掩码
broadcast广播地址
inet6网卡的IPv6地址
etherMAC地址
txqueuelen网卡设置的传送队列长度
Ethernet以太网
RX packets接收时,正确的数据包数
RX bytes接收的数据量
RX errors接收时,产生错误的数据包数
RX dropped接收时,丢弃的数据包数
RX overruns接收时,由于速度过快而丢失的数据包数
RX frame接收时,发生frame错误而丢失的数据包数
TX packets发送时,正确的数据包数
TX bytes发送的数据量
TX errors发送时,产生错误的数据包数
TX dropped发送时,丢弃的数据包数
TX overruns发送时,由于速度过快而丢失的数据包数
TX carrier发送时,发生carrier错误而丢失的数据包数
TX collisions冲突信息包的数目

四、man ifconfig

IFCONFIG(8)                                Linux System Administrator's Manual                               IFCONFIG(8)

NAME
       ifconfig - configure a network interface 配置网络接口

SYNOPSIS
       ifconfig [-v] [-a] [-s] [interface]
       ifconfig [-v] interface [aftype] options | address ...

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用于配置内核驻留的网络接口。它在启动时用于必要时设置接口。在此之后,通常只有在调试或需要系统调优时才需要它。

       如果未给出任何参数,ifconfig 将显示当前活动接口的状态。如果给出单个接口参数,则仅显示给定接口的状态;如果给定单个 -a 参数,则它显示所有接口的状态,甚至包括那些已关闭的接口。否则,它将配置接口。

Address Families
       If the first argument after the interface name is recognized as the name of a supported address family, that  address  family  is  used for decoding and displaying all protocol addresses.  Currently supported address families include inet (TCP/IP, default), inet6 (IPv6), ax25 (AMPR Packet Radio), ddp (Appletalk Phase 2), ipx (Novell IPX) and  netrom  (AMPR  Packet radio).  All numbers supplied as parts in IPv4 dotted decimal notation may be decimal,octal, or hexadecimal, as specified in the ISO C standard (that is, a leading 0x or 0X implies hexadecimal;  otherwise, a leading '0' implies octal; otherwise, the number is interpreted as decimal). Use of hexadecimal and octal numbers is not RFC-compliant and therefore its use is discouraged.

       如果接口名后面的第一个参数被识别为支持的地址族名称,则该地址族将用于解码和显示所有协议地址。目前支持的地址族包括inet (TCPIP,默认),inet6 (IPv6), ax25 (AMPR Packet Radio), ddp (Appletalk Phase 2), ipx (Novell ipx)和netrom (AMPR Packet Radio)。按照 ISO C 标准中的规定,在 IPv4 点分十进制表示法中作为部分提供的所有数字可以是十进制、八进制或十六进制(即,前导 0x 或 0X 表示十六进制);否则,前导"0"表示八进制;否则,该数字将被解释为十进制)。使用十六进制和八进制数不符合 RFC,因此不鼓励使用它。

OPTIONS
       -a     display all interfaces which are currently available, even if down 显示当前可用的所有接口,即使关闭

       -s     display a short list (like netstat -i) 显示一个简短的列表(如 netstat -i)

       -v     be more verbose for some error conditions 对于某些错误条件,请更详细

       interface
              The name of the interface.  This is usually a driver name followed by a unit number, for example eth0  for the  first  Ethernet interface. If your kernel supports alias interfaces, you can specify them with syntax like eth0:0 for the first alias of eth0. You can use them to assign more addresses. To delete an alias interface  use ifconfig eth0:0 down.

              Note: for every scope (i.e. same net with address/netmask combination) all aliases are deleted, if you delete the first (primary).

              接口的名称。这通常是一个驱动程序名称,后跟一个单元号,例如,第一个以太网接口的 eth0。如果内核支持别名接口,可以使用类似于eth0:0的语法为eth0的第一个别名指定它们。您可以使用它们来分配更多地址。使用ifconfig eth0:0 down命令删除别名接口。

              注意:对于每个作用域(即具有地址/网络掩码组合的同一网络),如果删除第一个别名(主),则将删除所有别名。

       up     
              This flag causes the interface to be activated.  It is implicitly specified if an address is  assigned  to the interface; you can suppress this behavior when using an alias interface by appending an - to the alias (e.g.  eth0:0-).  It is also suppressed when using the IPv4 0.0.0.0 address as the kernel will use this toimplicitly delete alias interfaces.

              该标志导致接口被激活。如果一个地址被分配给接口,它是隐式指定的;当使用别名接口时,可以通过在别名后面附加一个-来抑制这种行为(例如:eth0:0-)。使用 IPv4 0.0.0.0 地址时,它也被抑制,因为内核将使用此地址来直接删除别名接口。

       down   This flag causes the driver for this interface to be shut down. 此标志导致该接口的驱动程序被关闭。

       [-]arp Enable or disable the use of the ARP protocol on this interface. 使能/禁止该接口使用ARP协议。

       [-]promisc
              Enable  or disable the promiscuous mode of the interface.  If selected, all packets on the network will be received by the interface.

              启用或禁用接口的混杂模式。 如果选定该属性,接口将接收网络上的所有数据包。

       [-]allmulti
              Enable or disable all-multicast mode.  If selected, all multicast packets on the network will be  received by the interface.

              启用或禁用全多播模式。 如果选定该属性,接口将接收网络上的所有多播数据包。

       mtu N  This parameter sets the Maximum Transfer Unit (MTU) of an interface. 

              此参数设置接口的最大传输单位 (MTU)。

       dstaddr addr
              Set  the remote IP address for a point-to-point link (such as PPP).  This keyword is now obsolete; use the pointopoint keyword instead.

              设置点对点链路(如 PPP)的远程 IP 地址。 此关键字现已过时;请改用 pointopoint 关键字。

       netmask addr
              Set the IP network mask for this interface.  This value defaults to the usual class A, B or C network mask (as derived from the interface IP address), but it can be set to any value.

              为此接口设置 IP 网络掩码。此值默认为通常的 A、B 或 C 类网络掩码(派生自接口 IP 地址),但可以设置为任何值。

       add addr/prefixlen
              Add an IPv6 address to an interface. 将 IPv6 地址添加到接口。

       del addr/prefixlen
              Remove an IPv6 address from an interface. 从接口中删除 IPv6 地址。

       tunnel ::aa.bb.cc.dd
              Create a new SIT (IPv6-in-IPv4) device, tunnelling to the given destination.

              创建一个新的SIT (IPv6-in-IPv4)设备,通过隧道到达给定的目的地。

       irq addr
              Set the interrupt line used by this device.  Not all devices can dynamically change their IRQ setting.

              设置此设备使用的中断线。并不是所有的设备都能动态地改变他们的IRQ设置。

       io_addr addr
              Set the start address in I/O space for this device.

              在 I/O 空间中设置此设备的起始地址。

       mem_start addr
              Set the start address for shared memory used by this device.  Only a few devices need this.

              设置此设备使用的共享内存的起始地址。 只有少数设备需要此设备。

       media type
              Set  the  physical port or medium type to be used by the device.  Not all devices can change this setting, and those that can vary in what values they support.  Typical values for type are 10base2 (thin Ethernet), 10baseT  (twisted-pair 10Mbps Ethernet), AUI (external transceiver) and so on.  The special medium type of auto can be used to tell the driver to auto-sense the media.  Again, not all drivers can do this.

              设置设备要使用的物理端口或介质类型。并非所有设备都可以更改此设置,而这些设备支持的值可能会有所不同。该类型的典型值为10base2 (thin Ethernet)、10baseT(双绞线10Mbps以太网)、AUI(外部收发器)等。特殊的介质类型的auto可用于告诉驱动程序自动感应媒体。 同样,并非所有驱动程序都可以执行此操作。

       [-]broadcast [addr]
              If the address argument is given, set the protocol broadcast address for this interface.   Otherwise,  set (or clear) the IFF_BROADCAST flag for the interface.

              如果给出了地址参数,请设置此接口的协议广播地址。否则,请设置(或清除)接口的IFF_BROADCAST标志。

       [-]pointopoint [addr]
              This keyword enables the point-to-point mode of an interface, meaning that it is a direct link between two machines with nobody else listening on it. If the address argument is also given, set the protocol address of the other side of the link,  just  like the obsolete dstaddr keyword does.  Otherwise, set or clear the IFF_POINTOPOINT flag for the interface.

              此关键字启用接口的点对点模式,这意味着它是两台计算机之间的直接链接,没有其他人在侦听它。如果还给出了地址参数,请设置链接另一端的协议地址,就像过时的 dstaddr 关键字一样。否则,请设置或清除接口的IFF_POINTOPOINT标志。

       hw class address
              Set  the  hardware  address  of this interface, if the device driver supports this operation.  The keyword must be followed by the name of the hardware class and the printable ASCII equivalent of the hardware  address.   Hardware  classes  currently  supported  include  ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom (AMPR NET/ROM).

              如果设备驱动程序支持此操作,请设置此接口的硬件地址。关键字后必须跟硬件类的名称和硬件地址的可打印 ASCII 等效项。目前支持的硬件类别包括以太网(以太网)、ax25(AMPR AX.25)、ARCnet 和 netrom (AMPR NET/ROM)。

       multicast
              Set the multicast flag on the interface. This should not normally be needed as the drivers  set  the  flag correctly themselves.

              在接口上设置多播标志。这通常不需要,因为驱动程序自己正确设置了标志。

       address
              The IP address to be assigned to this interface. 要分配给此接口的 IP 地址。

       txqueuelen length
              Set  the  length  of the transmit queue of the device. It is useful to set this to small values for slower devices with a high latency (modem links, ISDN) to prevent fast bulk transfers from disturbing interactive traffic like telnet too much.

              设置设备的传输队列的长度。对于具有高延迟的较慢设备(调制解调器链路,ISDN),将其设置为小值很有用,以防止快速批量传输过多地干扰交互式流量(如 telnet)。

NOTES
       Since  kernel release 2.2 there are no explicit interface statistics for alias interfaces anymore. The statistics printed for the original address are shared with all alias addresses on the same device. If you want  per-address statistics you should add explicit accounting rules for the address using the iptables(8) command.

       Interrupt problems with Ethernet device drivers fail with EAGAIN (SIOCSIIFLAGS: Resource temporarily unavailable) it is most likely a interrupt conflict. See http://www.scyld.com/expert/irq-conflict.html for more information.

       从内核 2.2 版开始,别名接口不再有显式的接口统计信息。为原始地址打印的统计信息将与同一设备上的所有别名地址共享。如果你想要每个地址的统计信息,你应该使用iptables命令为地址添加显式的计算规则。

       以太网设备驱动程序的中断问题失败,EAGAIN(SIOCSIIFLAGS:资源暂时不可用),这很可能是中断冲突。更多信息见 http://www.scyld.com/expert/irq-conflict.html。

FILES
       /proc/net/dev
       /proc/net/if_inet6

BUGS
       Ifconfig uses the ioctl access method to get the full address information, which limits hardware addresses  to  8 bytes.  Because Infiniband hardware address has 20 bytes, only the first 8 bytes are displayed correctly.  Please use ip link command from iproute2 package to display link layer informations including the hardware address.

       While appletalk DDP and IPX addresses will be displayed they cannot be altered by this command.

       Ifconfig 使用 ioctl 访问方法来获取完整的地址信息,这会将硬件地址限制为 8 个字节。由于 Infiniband 硬件地址有 20 个字节,因此只有前 8 个字节才能正确显示。请使用 iproute2 包中的 ip 链接命令来显示链接层信息,包括硬件地址。

       虽然appletalk的DDP和IPX地址将被显示,但它们不能被这个命令改变。

SEE ALSO
       route(8), netstat(8), arp(8), rarp(8), iptables(8), ifup(8), interfaces(5).
       http://physics.nist.gov/cuu/Units/binary.html - Prefixes for binary multiples

AUTHORS
       Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
       Alan Cox, <Alan.Cox@linux.org>
       Phil Blundell, <Philip.Blundell@pobox.com>
       Andi Kleen
       Bernd Eckenfels, <net-tools@lina.inka.de>

net-tools                                              2008-10-03                                            IFCONFIG(8)

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值