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, <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)

* 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端口

ifconfig命令的使用的更多相关文章

  1. ip命令和ifconfig命令(转载)

    Linux的ip命令和ifconfig类似,但前者功能更强大,并旨在取代后者.使用ip命令,只需一个命令,你就能很轻松地执行一些网络管理任务.ifconfig是net-tools中已被废弃使用的一个命 ...

  2. centos7中没有安装ifconfig命令的解决方法

    初装centos 7时,运行config报 command not found 错误,我在网上找了大量资料,下面的资料中查找原因和解决方式最详细,能很好的解决这个问题. ifconfig命令是设置或显 ...

  3. CentOS 7 安装后没有ifconfig命令

    /bin,/sbin,/usr/bin,/usr/sbin下面都没有ifconfig命令. 执行命令  yum install net-tools 即可.

  4. 使用 python 获取 Linux 的 IP 信息(通过 ifconfig 命令)

    我们可以使用 python 代码通过调用 ifconfig 命令来获取 Linux 主机的 IP 相关信息,包括:网卡名称.MAC地址.IP地址等. 第一种实现方式: #!/usr/bin/pytho ...

  5. 【CentOS】ifconfig命令 :command not found & yum命令 :cannot find a valid baserl for repo: base/7/x86_64

    第一课,学习的是安装linux的远程连接.相信看阿铭视频的朋友们都会知道,第一个开机输入完root后要敲的命令就是--ifconfig 非常幸运,这迎来了我的第一个问题 这时候你会选择百度,会搜索到这 ...

  6. 每天一个linux命令(52):ifconfig命令

    许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...

  7. CentOS 7最小化安装后找不到‘ifconfig’命令——修复小提示

    如果你不知道在哪里可以找到ifconfig命令,请按照以下简单的步骤来找到它.首先,让我们找出哪个包提供了ifconfig命令.要完成这项任务,输入以下命令: [root@jrserver app_f ...

  8. RedHat不能使用ifconfig命令

    安装RedHat后,使用ifconfig命令,结果报错command not found,解决方法如下: 1.cat ~/.bash_profile     查看path 2.vi /etc/prof ...

  9. 每天一个linux命令(44):ifconfig命令

    许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...

  10. ifconfig命令(转)

    许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...

随机推荐

  1. Spark 读取HDFS csv文件并写入hive

    package com.grady import org.apache.spark.SparkConf import org.apache.spark.sql.{Row, SaveMode, Spar ...

  2. C++ 指针与二维数组名

    和一维数组类似,C++ 将二维数组名解释为其第一个元素的地址,而二维数组的第一个元素为一维数组,以下面的程序为例,二维数组名 array2d 和 &array2d[0] 等效,它们的类型都为 ...

  3. Python 代码智能感知 —— 类型标注与特殊的注释(献给所有的Python人)

    [原文地址:https://xiaokang2022.blog.csdn.net/article/details/126936985] ​ 一个不会写好的类型标注和注释的Python程序员,是让使用T ...

  4. CentOS7使用yum方式安装Containerd

    # 安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的 yum install -y yum-utils device-m ...

  5. [题解] Codeforces 1349 D Slime and Biscuits 概率,推式子,DP,解方程

    题目 神题.很多东西都不知道是怎么凑出来的,随意设置几个变量,之间就产生了密切的关系.下次碰到这种题应该还是不会做罢. 令\(E_x\)为最后结束时所有的饼干都在第x个人手中的概率*时间的和.\(an ...

  6. python合并多个excel

    前言 1.工作中,经常需要合并多个Excel文件.如果文件数量比较多,则工作量大,易出错,此时,可以使用Python来快速的完成合并. 2.使用方法:将需要合并的多个Excel文件放到同一个文件夹下, ...

  7. The XOR Largest Pair (trie树)

    题目描述 在给定的 NN 个整数 A_1,A_2,--,A_NA1​,A2​,--,AN​ 中选出两个进行xor运算,得到的结果最大是多少?xor表示二进制的异或(^)运算符号. 输入格式 第一行输入 ...

  8. Mac Mojave 10.14.5安装python tesserocr

    <1>先安装两个依赖库: brew install tesseract brew install leptonica 网上有些教程说要安装imagemagick,这里我觉得应该是不需要的, ...

  9. Activiti7基本介绍

    官方地址 官方地址 官方最新用户文档-V6.0.0 码云镜像-activiti-7-developers-guide 关于BPMN BPMN(Business Process Model AndNot ...

  10. Typora设置代码块Mac风格三个圆点

    写作不停,美化不止! mac小圆点效果 原本代码块样式就挺....干净的,光秃秃的,太单调了: 是吧很丑,于是自己发挥改成了这样: 好吧还是太单调,也没好看到哪里去,于是隔了两天又重新改,DuangD ...