首页
首页 » 网络通讯 » ifconfig

ifconfig

ifconfig
功能说明:显示或设置网络设备。
语  法:ifconfig [网络设备][down up -allmulti -arp -promisc][add<地址>][del<地址>][<hw<网络设备类型><硬件地址>][io_addr<I/O地址>][irq<IRQ地址>][media<网络媒介类型>][mem_start<内存地址>][metric<数目>][mtu<字节>][netmask<子网掩码>][tunnel<地址>][-broadcast<地址>][-pointopoint<地址>][IP地址]
补充说明:ifconfig可设置网络设备的状态,或是显示目前的设置。
参  数:
  add<地址>   设置网络设备IPv6的IP地址。
  del<地址>   删除网络设备IPv6的IP地址。
  down   关闭指定的网络设备。
  <hw<网络设备类型><硬件地址>   设置网络设备的类型与硬件地址。
  io_addr<I/O地址>   设置网络设备的I/O地址。
  irq<IRQ地址>   设置网络设备的IRQ。
  media<网络媒介类型>   设置网络设备的媒介类型。
  mem_start<内存地址>   设置网络设备在主内存所占用的起始地址。
  metric<数目>   指定在计算数据包的转送次数时,所要加上的数目。
  mtu<字节>   设置网络设备的MTU。
  netmask<子网掩码>   设置网络设备的子网掩码。
  tunnel<地址>   建立IPv4与IPv6之间的隧道通信地址。
  up   启动指定的网络设备。
  -broadcast<地址>   将要送往指定地址的数据包当成广播数据包来处理。
  -pointopoint<地址>   与指定地址的网络设备建立直接连线,此模式具有保密功能。
  -promisc   关闭或启动指定网络设备的promiscuous模式。
  [IP地址]   指定网络设备的IP地址。
  [网络设备]   指定网络设备的名称。

ifconfig

ifconfig [interface] ifconfig [interface address_family parameters addresses]

TCP/IP command. Assign an address to a network interface and/or configure network interface parameters. ifconfig is typically used at boot time to define the network address of each interface on a machine. It may be used at a later time to redefine an interface's address or other parameters. Without arguments, ifconfig displays the current configuration for a network interface. Used with a single interface argument, ifconfig displays that particular interface's current configuration. Note that interfaces are numbered starting at zero: eth0, eth1, eth2, and so forth. In most cases, eth0 will be the primary PCI Ethernet interface, and wireless network interfaces will begin with ath0 or wlan0.

Arguments

interface

String of the form name unit: for example, en0.

address_family

Since an interface may receive transmissions in differing protocols, each of which may require separate naming schemes, you can specify the address_family to change the interpretation of the remaining parameters. You may specify inet (for TCP/IP, the default), ax25 (AX.25 Packet Radio), ddp (Appletalk Phase 2), or ipx (Novell).

parameters

The following parameters may be set with ifconfig:

add address/prefixlength

Add an IPv6 address and prefix length.

address address

Assign the specified IP address to the interface.

allmulti/-allmulti

Enable/disable sending of incoming frames to the kernel's network layer.

arp/-arp

Enable/disable use of the Address Resolution Protocol in mapping between network-level addresses and link-level addresses.

broadcast [address]

(inet only) Specify address to use to represent broadcasts to the network. Default is the address with a host part of all ones (i.e., x.y.z.255 for a class C network).

debug/-debug

Enable/disable driver-dependent debugging code.

del address/prefixlength

Delete an IPv6 address and prefix length.

down

Mark an interface "down" (unresponsive).

hw class address

Set the interface's hardware class and address. class may be ether (Ethernet), ax25 (AX.25 Packet Radio), or ARCnet.

io_addr addr

I/O memory start address for device.

irq addr

Set the device's interrupt line.

metric n

Set routing metric of the interface to n. Default is 0.

mem_start addr

Shared memory start address for device.

media type

Set media type. Common values are 10base2, 10baseT, and AUI. If auto is specified, ifconfig will attempt to autosense the media type.

mtu n

Set the interface's Maximum Transfer Unit (MTU).

multicast

Set the multicast flag.

netmask mask

(inet only) Specify how much of the address to reserve for subdividing networks into subnetworks. mask can be specified as a single hexadecimal number with a leading 0x, with a dot notation Internet address, or with a pseudo-network name listed in the network table /etc/networks.

pointopoint/-pointopoint [address]

Enable/disable point-to-point interfacing, so that the connection between the two machines is dedicated.

promisc/-promisc

Enable/disable promiscuous mode. Promiscuous mode allows the device to receive all packets on the network.

txqueuelen n

Specify the transmit queue length.

tunnel addr

Create an IPv6-in-IPv4 (SIT) device, tunneling to IPv4 address addr.

up

Mark an interface "up" (ready to send and receive).

addresses

Each address is either a hostname present in the hostname database (/etc/hosts), or an Internet address expressed in the Internet standard dot notation.

Examples

To list all interfaces:

ifconfig -a

To add a second IP address to wlan0:

ifconfig wlan0:1 192.168.2.41 netmask 255.255.255.0

To change the hardware address (MAC address) assigned to eth0 (useful when setting up a router for a DSL or cable modem):

ifconfig eth0 hw ether 01:02:03:04:05:06