NAME
ifconfig - 配置网络接口
总览
ifconfig [接口]
ifconfig 接口 [aftype] options | address ...
描述
ifconfig 用于配置常驻内核的网络接口。它用于在引导成功时设定网络接口。此后,只在需要调试及系统调整时才使用。
如没有给出参数, ifconfig 显示当前有效接口的状态。如给定单个 接口 作为参数,它只显示给出的那个接口的状态;如果给出一个 -a 参数,它会显示所有接口的状态,包括那些停用的接口。否则就对一个接口进行配置。
地址族
如果跟在接口名称后的第一个参数是它支持地址族的名称,那么这个地址族被用于翻译和显示所有的协议地址。当前支持的地址族包括 inet ( TCP/IP ,缺省), inet6 ( IPv6 ) , ax25 ( AMPR 无线分组 ), ddp ( Appletalk 2 代), ipx ( Novell IPX ) 和 netrom ( AMPR 无线分组)。
选项
接口 接口名称。通常是一个后跟单元号的驱动设备名,例如第一个以太接口 eth0 。
- up
- 此选项激活接口。如果给接口声明了地址,等于隐含声明了这个选项。
- down
- 此选项使接口驱动设备关闭。
- [-]arp
- 允许或禁止在接口上使用 ARP 协议。
- [-]promisc
- 允许或禁止接口置于混杂模式。如果选用,则接口可以接收网络上的所有分组。
- [-]allmulti
- 允许或禁止 组播模式(all-multicast) 。 如果选用,则接口可以接收网络上的所有组播分组。
- metric N
- 将接口度量值设置为整数 N。 (译注:度量值表示在这个路径上发送一个分组的成本,就是通过多少个路由)
- mtu N
- 此选项设定接口的最大传输单元 MTU。
- dstaddr addr
- 为点到点链路(如 PPP )设定一个远程 IP 地址。此选项现已废弃;用 pointopoint 选项替换。
- netmask addr
- 为接口设定 IP 网络掩码。缺省值通常是 A,B 或 C 类的网络掩码 (由接口的 IP 地址推出),但也可设为其它值。
- add addr/prefixlen
- 为接口加入一个 IPv6 地址。
- del addr/prefixlen
- 为接口删除一个 IPv6 地址。
- tunnel aa.bb.cc.dd
- 建立一个新的 SIT (在 IPv4 中的 IPv6 )设备,为给定的目的地址建立通道。
- irq addr
- 为接口设定所用的中断值。并不是所有的设备都能动态更改自己的中断值。
- io_addr addr
- 为接口设定起始输入/输出地址。
- mem_start addr
- 设定接口所用的共享内存起始地址。只有少数设备需要。
- media type
- 设定接口所用的物理端口或介质类型。并不是所有设备都会更改这项值,而且它们支持的类型可能并相同。典型的 type 是 10base2 (细缆以太网), 10baseT (双绞线 10Mbps 以太网), AUI (外部收发单元接口)等等。介质类型为 auto 则用于让设备自动判断介质。同样,并非所有设备都可以这样工作。
- [-]broadcast [addr]
- 如果给出了地址参数,则可以为接口设定该协议的广播地址。否则,为接口设置(或清除) IFF_BROADCAST 标志。
- [-]pointopoint [addr]
- 此选项允许接口置为 点到点 模式,这种模式在两台主机间建立一条无人可以监听的直接链路。
如果还给出了地址参数,则设定链路另一方的协议地址,正如废弃的 dstaddr 选项的功能。否则,为接口设置(或清除) IFF_POINTOPOINT 标志。 - hw class address
- 如接口驱动程序支持,则设定接口的硬件地址。此选项必须后跟硬件的类型名称和硬件地址等价的可打印 ASCII 字符。当前支持的硬件类型包括 ether (以太网), ax25 (AMPR AX.25), ARCnet 和 netrom (AMPR NET/ROM)。
- multicast
- 为接口设定组播标志。通常无须用此选项因为接口本身会正确设定此标志。
- address
- 为接口分配的 IP 地址。
- txqueuelen length
- 为接口设定传输队列的长度。可以为具有高时延的低速接口设定较小值以避免在象 telnet 这样烦人的交互通信时大量高速的传输。
注意
从内核版本 2.2 起不再有别名接口的显式接口统计信息了。打印出的源地址统计信息被同一接口的所有别名地址共享。打印出的源地址统计信息被同一接口的所有别名地址共享。如果你需要每个地址的统计信息,就应该用 ipchains(8) 命令为地址加入显式的记帐规则。
相关文件
/proc/net/socket
/proc/net/dev
/proc/net/if_inet6
BUGS
当显示 appletalk DDP 和 IPX 地址时不能用此命令进行更改,但可以用这条命令显示。
又见
route(8), netstat(8), arp(8), rarp(8), ipchains(8)
#p#
NAME
ifconfig - configure a network interface
SYNOPSIS
ifconfig [interface]
ifconfig 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.
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).
OPTIONS
- 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.
- up
- This flag causes the interface to be activated. It is implicitly specified if an address is assigned to the interface.
- 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.
- [-]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.
- metric N
- This parameter sets the interface metric.
- mtu N
- This parameter sets the Maximum Transfer Unit (MTU) of an interface.
- 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.
- 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.
- add addr/prefixlen
- Add an IPv6 address to an interface.
- del addr/prefixlen
- Remove an IPv6 address from an interface.
- tunnel aa.bb.cc.dd
- Create a new SIT (IPv6-in-IPv4) device, tunnelling to the given destination.
- irq addr
- Set the interrupt line used by this device. Not all devices can dynamically change their IRQ setting.
- io_addr addr
- Set the start address in I/O space for this device.
- 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.
- [-]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.
- [-]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. - 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).
- 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.
- 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.
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 ipchains(8) command.
Interrupt problems with Ethernet device drivers fail with EAGAIN. See http://www.scyld.com/expert/irq-conflict.html for more information.
FILES
/proc/net/socket
/proc/net/dev
/proc/net/if_inet6
BUGS
While appletalk DDP and IPX addresses will be displayed they cannot be altered by this command.
SEE ALSO
route(8), netstat(8), arp(8), rarp(8), ipchains(8)