当前位置:网站首页>The ifconfig compared with IP command
The ifconfig compared with IP command
2022-08-11 02:24:00 【yuyuyuliang00】
基于LinuxRelease provides a simple and powerful way to configure the network of command line tools.These commands collection fromnet-tools软件包获取,This package in most distributions around for a long time,And contains likeifconfig, route, nameif, iwconfig, iptunnel, netstat, arp的命令.
These commands for any new orlinuxExperts in configure the network basic has had enough schooling,,But because in the past few yearsLinuxThe progress of the kernel and not maintain this command package collection,They have been abandoned and an alternative to the all these commands more powerful alternative to appear.
This alternative has appeared for a long time and more powerful than any of these commands.The rest will be emphasized from the alternatives and make itnet-toolsPack a command(ifconfig)做比较.
ip用于替代ifconfig
ifconfig已经存在很长时间了,And still be a lot of people are used to configure,Display and control network interface,但现在在LinuxThere is a new alternative to release,它比ifconfig要强大的多.The alternative is fromiproute软件包的ip命令.
[[email protected] network-scripts]# yum whatprovides "ip"
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.lzu.edu.cn
* epel: ftp.iij.ad.jp
* extras: mirror.lzu.edu.cn
* updates: download.nus.edu.sg
iproute-4.11.0-30.el7.x86_64 : Advanced IP routing and network device configuration tools
Repo : base
Matched from:
Filename : /usr/sbin/ipAlthough this command at first looks a little complicated,但功能上比ifconfig更加全面.On the function of two layer network stack organization it,即是第二层(数据链路层),第三层(IP层),And have come fromnet-toolsPackage the above mentioned command all the features of.
ifconfigDisplays or modifies system basically interface,ipCommand can do the following tasks:
- Displays or modifies the interface properties
- 添加、移除ARPCache entry and not host to create a new staticARP条目
- Show all interfaces relatedMAC地址
- Display and modify the kernel routing table
ipCommand is one of the main is different fromifconfig的重点是使用ioctlFor network configuration,ifconfig使用ioctlFor network configuration,This is a way to interact with the kernel is not popular,ipUsed for the same purposenetlink套接字机制,这是使用rtnetlinkUsed for internal communication between the kernel and user spaceioctlThe more flexible successor.
We are now beginning to highlightifconfigFeatures and how to effectively useipCommand to replace them.
ip vs ifconfig命令
The following section stressifconfig命令以及使用ip命令替换:
1、在LinuxShow all network interface
ifconfig命令
[[email protected] network-scripts]# ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.50.74 netmask 255.255.255.0 broadcast 192.168.50.255
inet6 fe80::755d:a1a5:8380:e9f9 prefixlen 64 scopeid 0x20<link>
ether 00:19:0f:3d:c9:3d txqueuelen 1000 (Ethernet)
RX packets 1079386 bytes 104138658 (99.3 MiB)
RX errors 0 dropped 1027598 overruns 0 frame 0
TX packets 7795 bytes 711277 (694.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf7f00000-f7f20000
...
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.3.30 netmask 255.255.255.0 broadcast 192.168.3.255
inet6 fe80::53ff:e021:58e4:1629 prefixlen 64 scopeid 0x20<link>
ether c4:00:ad:54:a3:23 txqueuelen 1000 (Ethernet)
RX packets 21748 bytes 1311860 (1.2 MiB)
RX errors 0 dropped 21271 overruns 0 frame 0
TX packets 123 bytes 13015 (12.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xf6f00000-f6ffffff
...ip命令
[[email protected] network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether c4:00:ad:54:a3:23 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.30/24 brd 192.168.3.255 scope global noprefixroute enp3s0
valid_lft forever preferred_lft forever
inet6 fe80::53ff:e021:58e4:1629/64 scope link noprefixroute
valid_lft forever preferred_lft forever
...
8: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:19:0f:3d:c9:3d brd ff:ff:ff:ff:ff:ff
inet 192.168.50.74/24 brd 192.168.50.255 scope global noprefixroute dynamic eno1
valid_lft 81779sec preferred_lft 81779sec
inet6 fe80::755d:a1a5:8380:e9f9/64 scope link noprefixroute
valid_lft forever preferred_lft forever
...2、添加或删除IP地址
ifconfig添加IP地址
[[email protected] network-scripts]# ifconfig enp3s0 add 192.168.3.31
[[email protected] network-scripts]# ip addr show enp3s0
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether c4:00:ad:54:a3:23 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.30/24 brd 192.168.3.255 scope global noprefixroute enp3s0
valid_lft forever preferred_lft forever
inet 192.168.3.31/24 brd 192.168.3.255 scope global secondary enp3s0:0
valid_lft forever preferred_lft forever
inet6 fe80::53ff:e021:58e4:1629/64 scope link noprefixroute
valid_lft forever preferred_lft foreverifconfig删除IP地址
[[email protected] network-scripts]# ifconfig enp3s0 del 192.168.3.31
[[email protected] network-scripts]# ip addr show enp3s0
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether c4:00:ad:54:a3:23 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.30/24 brd 192.168.3.255 scope global noprefixroute enp3s0
valid_lft forever preferred_lft forever
inet6 fe80::53ff:e021:58e4:1629/64 scope link noprefixroute
valid_lft forever preferred_lft foreverip添加IP地址
[[email protected] network-scripts]# ip addr add 192.168.3.31 dev enp3s0
[[email protected] network-scripts]# ip addr show enp3s0
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether c4:00:ad:54:a3:23 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.30/24 brd 192.168.3.255 scope global noprefixroute enp3s0
valid_lft forever preferred_lft forever
inet 192.168.3.31/32 scope global enp3s0
valid_lft forever preferred_lft forever
inet6 fe80::53ff:e021:58e4:1629/64 scope link noprefixroute
valid_lft forever preferred_lft foreverip删除IP地址
[[email protected] network-scripts]# ip addr del 192.168.3.31 dev enp3s0
Warning: Executing wildcard deletion to stay compatible with old scripts.
Explicitly specify the prefix length (192.168.3.31/32) to avoid this warning.
This special behaviour is likely to disappear in further releases,
fix your scripts!
[[email protected] network-scripts]# ip addr show enp3s0
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether c4:00:ad:54:a3:23 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.30/24 brd 192.168.3.255 scope global noprefixroute enp3s0
valid_lft forever preferred_lft forever
inet6 fe80::53ff:e021:58e4:1629/64 scope link noprefixroute
valid_lft forever preferred_lft forever3、添加MACHardware address to a network interface
The following command for the interfaceenp3s0Set hardware address is specified in the command value.检查ifconfig命令输出中HWaddr可以确认.
使用ifconfig命令添加MAC地址的语法:
[[email protected] network-scripts]# ifconfig enp3s0 hw ether 00:aa:bb:cc:dd:ee
[[email protected] network-scripts]# ifconfig enp3s0
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.3.30 netmask 255.255.255.0 broadcast 192.168.3.255
inet6 fe80::53ff:e021:58e4:1629 prefixlen 64 scopeid 0x20<link>
ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet)
RX packets 22661 bytes 1366894 (1.3 MiB)
RX errors 0 dropped 22182 overruns 0 frame 0
TX packets 158 bytes 17635 (17.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xf6f00000-f6ffffffip添加MAC地址
使用ip命令添加MAC地址的语法:
[[email protected] network-scripts]# ip link set dev enp3s0 address 00:ee:dd:cc:bb:aa
[[email protected] network-scripts]# ip addr show enp3s0
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:ee:dd:cc:bb:aa brd ff:ff:ff:ff:ff:ff
inet 192.168.3.30/24 brd 192.168.3.255 scope global noprefixroute enp3s0
valid_lft forever preferred_lft forever
inet6 fe80::53ff:e021:58e4:1629/64 scope link noprefixroute
valid_lft forever preferred_lft forever4、Set the network interface of other configuration
除了IPAddress or hardware address,Can be applied to other interface configuration includes:
- MTU
- Multicast tag
- 传输队列长度
- 混杂模式
- 启用或禁用所有多播模式
a) 设置MTU值为2000
ifconfig --Other network configuration
[[email protected] network-scripts]# ifconfig enp3s0 mtu 2000
ip -- Other network configuration
[[email protected] network-scripts]# ip link set dev enp3s0 mtu 2000b) Enable or disable the multicast tag
ifconfig
[[email protected] network-scripts]# ifconfig enp3s0 multicastip
[[email protected] network-scripts]# ip link set dev enp3s0 multicast onc) Set the transmission queue length
ifconfig
[[email protected] network-scripts]# ifconfig enp3s0 txqueuelen 1200
ip
[[email protected] network-scripts]# ip link set dev enp3s0 txqueuelen 12004) Enable or disable the promiscuous mode
ifconfig
[[email protected] network-scripts]# ifconfig enp3s0 promisc
ip
[[email protected] network-scripts]# ip link set dev enp3s0 promisc on5、启用或禁用网络接口
ifconfigDisable specific network interface
[[email protected] network-scripts]# ifconfig enp3s0 down
[[email protected] network-scripts]# ifconfig enp3s0
enp3s0: flags=4866<BROADCAST,PROMISC,ALLMULTI,MULTICAST> mtu 2000
ether 00:ee:dd:cc:bb:aa txqueuelen 1200 (Ethernet)
RX packets 23966 bytes 1445944 (1.3 MiB)
RX errors 0 dropped 23483 overruns 0 frame 0
TX packets 211 bytes 25494 (24.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xf6f00000-f6ffffffifconfigEnable specific network interface
[[email protected] network-scripts]# ifconfig enp3s0 up
[[email protected] network-scripts]# ifconfig enp3s0
enp3s0: flags=4931<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,MULTICAST> mtu 2000
inet 192.168.3.30 netmask 255.255.255.0 broadcast 192.168.3.255
inet6 fe80::53ff:e021:58e4:1629 prefixlen 64 scopeid 0x20<link>
ether c4:00:ad:54:a3:23 txqueuelen 1200 (Ethernet)
RX packets 23969 bytes 1446147 (1.3 MiB)
RX errors 0 dropped 23486 overruns 0 frame 0
TX packets 228 bytes 28022 (27.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xf6f00000-f6ffffffipDisable specific network interface
[[email protected] network-scripts]# ip link set enp3s0 down
[[email protected] network-scripts]# ip addr show enp3s0
2: enp3s0: <BROADCAST,MULTICAST,ALLMULTI,PROMISC> mtu 2000 qdisc mq state DOWN group default qlen 1200
link/ether 00:ee:dd:cc:bb:aa brd ff:ff:ff:ff:ff:ff
ipEnable specific network interface
[[email protected] network-scripts]# ip link set enp3s0 up
[[email protected] network-scripts]# ip addr show enp3s0
2: enp3s0: <BROADCAST,MULTICAST,ALLMULTI,PROMISC,UP,LOWER_UP> mtu 2000 qdisc mq state UP group default qlen 1200
link/ether c4:00:ad:54:a3:23 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.30/24 brd 192.168.3.255 scope global noprefixroute enp3s0
valid_lft forever preferred_lft forever
inet6 fe80::53ff:e021:58e4:1629/64 scope link tentative noprefixroute
valid_lft forever preferred_lft forever6、启用或者禁用ARP协议
The following command on the specified network interface to enable or disableARP协议
ifconfig--启用/禁用ARP协议
以下命令使ARPCan deal with the interfaceenp3s0一起使用.To disable this option,只要用-arp替代arp.
[[email protected] network-scripts]# ifconfig enp3s0 arp
[[email protected] network-scripts]# ifconfig enp3s0 -arpip--启用或禁用ARP协议
以下命令是ip使得ARPProtocols can be used to interfaceenp3s0.要禁用它,只要用off替代on.
[[email protected] network-scripts]# ip link set dev enp3s0 arp on边栏推荐
猜你喜欢

js原型和原型链及原型继承

单面PCB布线阻抗的工程设计
![[The method of calling the child page from the parent page of the iframe] Stepping on the pit: It is the key to use `[x]` when getting elements. You cannot use `.eq(x)`, otherwise it will not be obtai](/img/ec/0cca8c7011770429c34a6aa1f36460.png)
[The method of calling the child page from the parent page of the iframe] Stepping on the pit: It is the key to use `[x]` when getting elements. You cannot use `.eq(x)`, otherwise it will not be obtai

gRPC闭包调度器

通过微透镜阵列的传播

Lianshengde W801 series 6-Analyze the Bluetooth communication source code of W801 from the perspective of WeChat applet (indicate method)

Oops novice template Framework project guide

如何开展性能测试,你知道吗?

数据的存储(下)——浮点型在内存中的存储

关于地图GIS开发事项的一次实践整理(上)
随机推荐
软件测试面试题:软件测试的过程的V模型,说出它的缺点?
PIFuHD配置记录
数据存储全方案----详解持久化技术
TRCX:掺杂过程分析
async和await的理解和用法
一次简单的 JVM 调优,拿去写到简历里
How to solve the problem of Tomcat booting and crashing
OpenWrt之opkg详解
gRPC基础概念:闭包
测试3年,开口就要25k?面试完最多给15k...
[Detailed explanation of C data storage] (1) - in-depth analysis of the storage of shaping data in memory
【PHP】入门知识
YTU 2411: 谁去参加竞赛?【简单循环】
①CAS SSO单点登录框架源码深度分析
惨遭面试官吊打高并发系统设计,回来学习 2400 小时后成功复仇
Experiment record of Shengxin (part3)--scipy.spatial.distance_matrix
Mask RCNN 网络详解
全局大喇叭--广播机制
软件测试面试题:测试用例与测试脚本?
MySQL的主从复制+读写分离+分库分表,看这一篇文章就够了