ifconfig命令的使用
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命令的使用的更多相关文章
- ip命令和ifconfig命令(转载)
Linux的ip命令和ifconfig类似,但前者功能更强大,并旨在取代后者.使用ip命令,只需一个命令,你就能很轻松地执行一些网络管理任务.ifconfig是net-tools中已被废弃使用的一个命 ...
- centos7中没有安装ifconfig命令的解决方法
初装centos 7时,运行config报 command not found 错误,我在网上找了大量资料,下面的资料中查找原因和解决方式最详细,能很好的解决这个问题. ifconfig命令是设置或显 ...
- CentOS 7 安装后没有ifconfig命令
/bin,/sbin,/usr/bin,/usr/sbin下面都没有ifconfig命令. 执行命令 yum install net-tools 即可.
- 使用 python 获取 Linux 的 IP 信息(通过 ifconfig 命令)
我们可以使用 python 代码通过调用 ifconfig 命令来获取 Linux 主机的 IP 相关信息,包括:网卡名称.MAC地址.IP地址等. 第一种实现方式: #!/usr/bin/pytho ...
- 【CentOS】ifconfig命令 :command not found & yum命令 :cannot find a valid baserl for repo: base/7/x86_64
第一课,学习的是安装linux的远程连接.相信看阿铭视频的朋友们都会知道,第一个开机输入完root后要敲的命令就是--ifconfig 非常幸运,这迎来了我的第一个问题 这时候你会选择百度,会搜索到这 ...
- 每天一个linux命令(52):ifconfig命令
许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...
- CentOS 7最小化安装后找不到‘ifconfig’命令——修复小提示
如果你不知道在哪里可以找到ifconfig命令,请按照以下简单的步骤来找到它.首先,让我们找出哪个包提供了ifconfig命令.要完成这项任务,输入以下命令: [root@jrserver app_f ...
- RedHat不能使用ifconfig命令
安装RedHat后,使用ifconfig命令,结果报错command not found,解决方法如下: 1.cat ~/.bash_profile 查看path 2.vi /etc/prof ...
- 每天一个linux命令(44):ifconfig命令
许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...
- ifconfig命令(转)
许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...
随机推荐
- KingbaseES 局部索引
一个列要不要建立btree索引,判断条件是其键值分布是否够离散,比如主键.唯一键,可以建立索引.如果这个列有大量重复的值,则建立索引没有意义. 在生产环境中常会碰到键值分布不均匀的列,如表t1有一个名 ...
- 动态调整日志级别思路&实现
引言 上篇文章 性能调优--小小的 log 大大的坑 已将详细的介绍了高并发下,不正确的使用日志姿势,可能会导致服务性能急剧下降问题.文末也给各位留下了解决方案--日志级别动态调整. 本文将详细介绍& ...
- 【设计模式】Java设计模式 - 组合模式
Java设计模式 - 组合模式 不断学习才是王道 继续踏上学习之路,学之分享笔记 总有一天我也能像各位大佬一样 原创作品,更多关注我CSDN: 一个有梦有戏的人 准备将博客园.CSDN一起记录分享自己 ...
- (数据科学学习手札141)利用Learn Git Branching轻松学习git常用操作
1 简介 大家好我是费老师,Git作为世界上最流行的版本控制系统,可以说是每一位与程序打交道的朋友最值得学习的软件之一.除了管理自己的项目,如果你对参与开源项目感兴趣,那么Git更是联结Github. ...
- SSM保姆级从创建项目到使用,包括事务和设置回滚
1. 简介 Spring 和 Mybaits整合 2. 创建项目 负责将代理类记性扫描,扫描的是Mapper接口所在的包,这个是mybatis提供的,所以会去找SqlSessionFactory 2. ...
- 【Spring】Spring bean中id和name的差异
id和name都是spring 容器中中bean 的唯一标识符. id: 一个bean的唯一标识 , 命名格式必须符合XML ID属性的命名规范 name: 可以用特殊字符,并且一个bean可以用多个 ...
- Prometheus样本采集器汇总
系统基本信息 Linux Servers: Exporter https://github.com/prometheus/node_exporter Dashboard https://grafana ...
- Docker镜像仓库Harbor之Swagger REST API整合配置
转载自:https://cloud.tencent.com/developer/article/1010618 1.Swagger 介绍 Swagger 是一个规范和完整的框架,用于生成.描述.调用和 ...
- windows下mysql的数据主主同步
mysql主主备份: 保证各服务器上的数据库中的数据一致,因此需要开启数据库同步机制.由于是一整套系统,并且系统内含数据库.由于任何一台服务器都有可能被选中,因此要让所有的数据库上的数据都是最新的,任 ...
- Qemu/Limbo/KVM镜像 Ubuntu 22.04 精简版,可运行Windows软件,内存占用不到200M
镜像特征: Ubuntu 22.04系统 内置Wine 7.8,可运行大量Windows 软件 高度精简,内存占用仅200M不到. 自制UI,Windows3.1风格. 完全开源 镜像说明: 用户名为 ...