首页 > 其他分享 >ifconfig命令的使用

ifconfig命令的使用

时间:2022-11-20 18:55:05浏览次数:33  
标签:addr IP address ifconfig 网卡 命令 使用 interface

ifconfig命令
用途:配置或显示TCP/IP网络的网络接口参数。
*1、通过--help学习ifconfig的使用

点击查看代码
[root@rocky8 ~]# 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) x25 (generic X.25) infiniband (InfiniBand) 
    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) ash (Ash) 
    x25 (CCITT X.25) 
* 2、通过man学习ifconfig的使用
点击查看代码
[root@rocky8 ~]# 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 ...

NOTE
       This program is obsolete!  For replacement check ip addr and ip link.  For statistics use ip -s link.

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 dis
       plays 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).   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;  other
       wise,  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.

OPTIONS
       -a     display all interfaces which are currently available, even if down

       -s     display a short list (like 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).

       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 to  implic
              itly delete alias interfaces.

       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.

       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 cor
              rectly 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 iptables(8) command.

       Since  net-tools 1.60-4 ifconfig is printing byte counters and human readable counters with IEC 60027-2 units. So 1
       KiB are 2^10 byte. Note, the numbers are truncated to one decimal (which can by quite a large error if you consider
       0.1 PiB is 112.589.990.684.262 bytes :)

       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.

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.

SEE ALSO
       ip(8), iptables(8)
       http://physics.nist.gov/cuu/Units/binary.html - Prefixes for binary multiples

AUTHORS
       Fred N. van Kempen, <[email protected]>
       Alan Cox, <[email protected]>
       Phil Blundell, <[email protected]>
       Andi Kleen
       Bernd Eckenfels, <[email protected]>

net-tools                                               2008-10-03                                             IFCONFIG(8)
* 3、参数解释
点击查看代码
-a        显示全部接口信息
-s        显示摘要信息(类似于 netstat -i)
-v        对某些错误条件更加详细
interface 接口名称。这通常是一个驱动程序名称后面跟着一个单元号,例如eth0表示第一个以太网接口。如果您的内核支持别名接口,您可以使
          用类似eth0:0这样的语法来指定eth0的第一个别名。您可以使用它们分配更多的地址。使用ifconfig eth0:0 down命令删除别名
          接口。注意:对于每个作用域(即地址/掩码组合相同的网络),如果你删除了第一个(主),所有的别名都会被删除。
up        该标志使接口被激活。如果将地址分配给接口,则隐式指定;在使用别名接口时,可以通过向别名追加-(例如eth0:0-)来抑制这种行
          为。当使用IPv4 0.0.0.0地址时,它也会被抑制,因为内核将使用该地址隐式删除别名接口。
down      关闭指定网络设备/网卡。该参数可以有效地阻止通过指定接口的IP信息流,如果想永久地关闭一个接口,我们还需要从核心路由表中
          将该接口的路由信息全部删除。
[-]arp   设置指定网卡是否支持ARP协议。
[-]promisc 设置是否支持网卡的promiscuous模式,如果选择此参数,网卡将接收网络中发给它所有的数据包
[-]allmulti  设置是否支持多播模式,如果选择此参数,网卡将接收网络中所有的多播数据包
mtu<字节数>    设置网卡的最大传输单元 (bytes)
dstaddr addr    设定一个远端地址,建立点对点通信
netmask addr      设置接口的IP网络掩码。该值默认为通常的A、B或C类网络掩码(源自接口IP地址),但可以设置为任何值。
add addr/prefixlen  给指定网卡配置IPv6地址
del addr/prefixlen  删除指定网卡的IPv6地址
tunnel<地址>     建立IPv4与IPv6之间的隧道通信地址。
irq<IRQ地址>   设置网络设备的IRQ。
io_addr<I/O地址>  设置网络设备的I/O地址。
netmask <子网掩码>  设置网卡的子网掩码。掩码可以是有前缀0x的32位十六进制数,也可以是用点分开的4个十进制数。如果不打算将网络分
                   成子网,可以不管这一选项;如果要使用子网,那么请记住,网络中每一个系统必须有相同子网掩码。
mem_start addr  设置此设备使用的共享内存的起始地址。只有少数设备需要这个功能。
media type     设置设备使用的物理端口或介质类型。并不是所有的设备都可以更改这个设置,而且那些设备支持的值也会有所不同。类型的
               典型值是10base2(薄以太网)、10baseT(双绞线10Mbps以太网)、AUI(外部收发器)等等。驱动的特殊媒体类型可以用来告诉
               驱动自动感知 媒体。同样,不是所有的驱动都能做到这一点。
-broadcast<地址>  为指定网卡设置广播协议
-pointtopoint<地址>  为网卡设置点对点通讯协议
hw class address   如果设备驱动支持此操作,请设置该接口的硬件地址。关键字后面必须跟硬件类的名称和硬件地址的可打印的等价ASCII
                  码。目前支持的硬件类包括ether (Ethernet)、ax25 (AMPR AX.25)、ARCnet和netrom (AMPR NET/ROM)。
multicast     为网卡设置组播标志
address    为网卡设置IPv4地址
txqueuelen<长度>  为网卡设置传输列队的长度
* 4、常用的参数 - a 显示当前可用的所有接口,即使是关闭的
点击查看代码
[root@rocky8 ~]# ifconfig -a
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.130  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::20c:29ff:fee6:9baa  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:e6:9b:aa  txqueuelen 1000  (Ethernet)
        RX packets 9900  bytes 12885285 (12.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2713  bytes 261793 (255.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 86  bytes 11920 (11.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 86  bytes 11920 (11.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:a2:67:02  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
- s 显示一个简短的列表(如netstat -i),查看网卡收发包和MTU值等
点击查看代码
[root@rocky8 ~]# ifconfig -s
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
ens33            1500     9927      0      0 0          2730      0      0      0 BMRU
lo              65536       86      0      0 0            86      0      0      0 LRU
virbr0           1500        0      0      0 0             0      0      0      0 BMU
* 5、启动关闭指定网卡
点击查看代码
ifconfig ens33 up          # 启动ens33端口
ifconfig ens33 down        # 关闭ens33端口

标签:addr,IP,address,ifconfig,网卡,命令,使用,interface
From: https://www.cnblogs.com/2ncifang/p/16907619.html

相关文章

  • 需要授权的 API ,必须在请求头中使用 Authorization 字段提供 token 令牌
    原文链接:https://blog.csdn.net/wanghuohuo1998/article/details/118087204需要授权的 API ,必须在请求头中使用添加字段需要授权的API,必须在请求头中使用 Authoriz......
  • 嵌入式linux日常使用的网络工具分享
    前言作为嵌入式linux开发中我们经常会调试网络,这个时候需要一些网络工具辅助我们的工作,有一些是命令工具有些是GUI工具,这些生产力工具如何使用呢,今天做一个小分享(本篇文章......
  • (转)Linux crontab命令详解
    原文:https://www.cnblogs.com/ftl1012/p/crontab.htmlcrontab:定时任务的守护进程,精确到分,设计秒的我们一般写脚本 -->相当于闹钟       日志文件: ll/var/lo......
  • 【I/O模型】异步IO的原理和使用
    为什么要有异步I/O异步IO相比同步IO不会阻塞当前程序的执行,可以继续向下执行。即当应用程序发起一个IO操作后,调用者不会立刻得到结果,而是在内核完成IO操作后,通过信号或回......
  • Linux工作中最常用命令整理
    ls命令ls-a:显示所有文件夹,包含隐藏的.和..ls-l:显示文件的详细信息,包含文件形态,权限,所属,大小,其实就是平常用的llll-h:用易读的方式列出所有的文件信息cd......
  • Java中使用脚本引擎运行脚本语言
    在Java中运行脚本语言,例如JavaScript。步骤:1、创建脚本引擎管理器ScriptEngineManager2、从管理器中获取一个引擎ScriptEngine3、通过put(key,valu......
  • 17_1_kubernetes 常用命令与应用部署
    01基本概念Pod:K8s最小部署单元,一组容器的集合Deployment:最常见的控制器,用于更高级别部署和管理PodService:为一组Pod提供负载均衡,对外提供统一访问入口Label......
  • 常用Linux命令-学习
    常用Linux命令文件目录类命令命令格式命令名称-选项参数命令浏览目录命令ls命令英文原意:list功能描述:显示目录文件pwd命令英文原意:printworkingdirector......
  • Windows 10/11 家庭版中使用组策略gpedit.msc
    保存为了gpedit.bat,使用管理员身份运行@echooffpushd"%~dp0"dir/bC:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~3*.mum......
  • PYTHON 安装后没有pip命令
        python安装后没有pip命令解决方法:windows任一文件中,按SHIFT,右击,选择“在此处打开powershell"输入命令:python-mensurepip......