2024年Linux最全Linux系统之ifconfig命令的基本使用_linux怎么ifconfig提示(1),靠这份Linux运维知识点PDF成功跳槽

最后的话

最近很多小伙伴找我要Linux学习资料,于是我翻箱倒柜,整理了一些优质资源,涵盖视频、电子书、PPT等共享给大家!

资料预览

给大家整理的视频资料:

给大家整理的电子书资料:

如果本文对你有帮助,欢迎点赞、收藏、转发给朋友,让我有持续创作的动力!

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以点击这里获取!

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

以下是ifconfig的使用参数

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模式; 

三、安装ifconfig命令工具

1. 安装net-tools软件包

ifconfig命令的软件包在centos7.6中为net-tools

[root@docker yum.repos.d]# yum -y install net-tools Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed --> Finished Dependency Resolution  Dependencies Resolved  =============================================================================================================================  Package                    Arch                    Version                                      Repository             Size ============================================================================================================================= Installing:  net-tools                  x86_64                  2.0-0.25.20131004git.el7                     base                  306 k  Transaction Summary ============================================================================================================================= Install  1 Package  Total download size: 306 k Installed size: 917 k Downloading packages: net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                                                         | 306 kB  00:00:00      Running transaction check Running transaction test Transaction test succeeded Running transaction   Installing : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                 1/1    Verifying  : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                 1/1   Installed:   net-tools.x86_64 0:2.0-0.25.20131004git.el7                                                                                  Complete!  

2. 查看ifconfig工具的版本

使用ifconfig -V,查看版本情况。

[root@docker ~]# ifconfig -V net-tools 2.10-alpha 

四、ifconfig的基本使用

1. 启停网卡

ifconfig eth0 up为启动网卡eth0,ifconfig eth0 down为关闭网卡eth0。

ifconfig eth0 up   # 启动网卡eth0 ifconfig eth0 down   # 关闭网卡eth0 

2. 显示eth0网卡信息

单独显示eth0网卡信息

[root@docker ~]# ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500         inet 192.168.3.127  netmask 255.255.255.0  broadcast 192.168.3.255         inet6 fd58:bc95:d4fb::83b  prefixlen 128  scopeid 0x0<global>         inet6 fe80::3bde:d1ba:1b78:4dbd  prefixlen 64  scopeid 0x20<link>         inet6 fd58:bc95:d4fb:0:ff42:9e46:82f5:7a5f  prefixlen 64  scopeid 0x0<global>         ether ee:99:c7:4b:23:e2  txqueuelen 1000  (Ethernet)         RX packets 2321266  bytes 571440099 (544.9 MiB)         RX errors 0  dropped 30683  overruns 0  frame 0         TX packets 468692  bytes 53519750 (51.0 MiB)         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

3. 设置最大传输单元

设置能通过的最大数据包大小为 1500 bytes

fconfig eth0 mtu 1500  

4. 启用和关闭arp协议

对eth0网卡启用和关闭arp协议

ifconfig eth0 arp    #开启网卡eth0 的arp协议 ifconfig eth0 -arp   #关闭网卡eth0 的arp协议 

5. 查看所有已激活网卡信息

使用ifconfig命令显示所有已激活网卡信息

[root@docker ~]# ifconfig  docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500         inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255         ether 02:42:fe:57:e3:ac  txqueuelen 0  (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  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500         inet 192.168.3.127  netmask 255.255.255.0  broadcast 192.168.3.255         inet6 fd58:bc95:d4fb::83b  prefixlen 128  scopeid 0x0<global>         inet6 fe80::3bde:d1ba:1b78:4dbd  prefixlen 64  scopeid 0x20<link>         inet6 fd58:bc95:d4fb:0:ff42:9e46:82f5:7a5f  prefixlen 64  scopeid 0x0<global>         ether ee:99:c7:4b:23:e2  txqueuelen 1000  (Ethernet)         RX packets 2482  bytes 445608 (435.1 KiB)         RX errors 0  dropped 39  overruns 0  frame 0         TX packets 1529  bytes 391681 (382.5 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 14  bytes 2683 (2.6 KiB)         RX errors 0  dropped 0  overruns 0  frame 0         TX packets 14  bytes 2683 (2.6 KiB)         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

6. 查看所有网卡网卡信息

查看所有网卡(包括未激活)网卡信息

[root@docker ~]# ifconfig  -a docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500         inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255         ether 02:42:fe:57:e3:ac  txqueuelen 0  (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  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500         inet 192.168.3.127  netmask 255.255.255.0  broadcast 192.168.3.255         inet6 fd58:bc95:d4fb::83b  prefixlen 128  scopeid 0x0<global>         inet6 fe80::3bde:d1ba:1b78:4dbd  prefixlen 64  scopeid 0x20<link>         inet6 fd58:bc95:d4fb:0:ff42:9e46:82f5:7a5f  prefixlen 64  scopeid 0x0<global>         ether ee:99:c7:4b:23:e2  txqueuelen 1000  (Ethernet)         RX packets 2579  bytes 454207 (443.5 KiB)         RX errors 0  dropped 41  overruns 0  frame 0         TX packets 1553  bytes 395235 (385.9 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 14  bytes 2683 (2.6 KiB)         RX errors 0  dropped 0  overruns 0  frame 0         TX packets 14  bytes 2683 (2.6 KiB)         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

五、配置IP地址

1. 设置网卡的IP地址

对eth0物理网卡配置IP地址。注意ssh连接时,设置后立即生效,单网卡情况下会断开连接。此设置是临时生效,重启服务器后,网卡恢复为原来的IP地址。

ifconfig eth0 192.168.200.200  netmask 255.255.255.0  broadcast 192.168.200.255 

2. 新增网卡的IP地址

对网卡eth0新增IP,临时生效。

[root@docker ~]# ifconfig eth0 add 192.168.200.200 netmask 255.255.255.0   [root@docker ~]# ifconfig  docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500         inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255         ether 02:42:dc:0d:79:4b  txqueuelen 0  (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  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500         inet 192.168.3.127  netmask 255.255.255.0  broadcast 192.168.3.255         inet6 fd58:bc95:d4fb::83b  prefixlen 128  scopeid 0x0<global>         inet6 fe80::3bde:d1ba:1b78:4dbd  prefixlen 64  scopeid 0x20<link>         inet6 fd58:bc95:d4fb:0:ff42:9e46:82f5:7a5f  prefixlen 64  scopeid 0x0<global>         ether ee:99:c7:4b:23:e2  txqueuelen 1000  (Ethernet)         RX packets 1341  bytes 327185 (319.5 KiB)         RX errors 0  dropped 21  overruns 0  frame 0         TX packets 1253  bytes 362959 (354.4 KiB)         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500         inet 192.168.200.200  netmask 255.255.255.0  broadcast 192.168.3.255         ether ee:99:c7:4b:23:e2  txqueuelen 1000  (Ethernet)  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 28  bytes 4337 (4.2 KiB)         RX errors 0  dropped 0  overruns 0  frame 0         TX packets 28  bytes 4337 (4.2 KiB)         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

3. 删除网卡的IP地址

删除网卡的IP地址,临时生效。

[root@docker ~]# ifconfig eth0 del  192.168.200.200 netmask 255.255.255.0   [root@docker ~]# ifconfig  docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500         inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255         ether 02:42:dc:0d:79:4b  txqueuelen 0  (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  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500         inet 192.168.3.127  netmask 255.255.255.0  broadcast 192.168.3.255         inet6 fd58:bc95:d4fb::83b  prefixlen 128  scopeid 0x0<global>         inet6 fe80::3bde:d1ba:1b78:4dbd  prefixlen 64  scopeid 0x20<link>         inet6 fd58:bc95:d4fb:0:ff42:9e46:82f5:7a5f  prefixlen 64  scopeid 0x0<global>         ether ee:99:c7:4b:23:e2  txqueuelen 1000  (Ethernet)         RX packets 1547  bytes 344429 (336.3 KiB)         RX errors 0  dropped 23  overruns 0  frame 0         TX packets 1359  bytes 374005 (365.2 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 28  bytes 4337 (4.2 KiB)         RX errors 0  dropped 0  overruns 0  frame 0         TX packets 28  bytes 4337 (4.2 KiB)         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

4. 修改MAC地址

用ifconfig修改MAC地址,临时生效。

ifconfig eth0 hw ether 10:BA:CB:54:86:B3 

本文转自 https://mp.weixin.qq.com/s/r6Q4zadRLMpmKnsrhq176g,如有侵权,请联系删除。

黑客&网络安全如何学习

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以点击这里获取!

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

**

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以点击这里获取!

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值