
ifconfig 是 Linux 系统中用于查看或配置网络接口的常用命令,可用于设置网络设备的状态或显示当前网络配置信息。
<pre class="brush:php;toolbar:false;">ifconfig [网络设备][down up -allmulti -arp -promisc][add][del][<hw>][io_addr<i>][irq<irq>][media][mem_start][metric][mtu][netmask][tunnel][-broadcast][-pointopoint][IP地址]</irq></i></hw>
参数说明:
查看当前网络接口信息:
<pre class="brush:php;toolbar:false;"># ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:0A:0B:0C
inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe0a:b0c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:172220 errors:0 dropped:0 overruns:0 frame:0
TX packets:132379 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:87101880 (83.0 MiB) TX bytes:41576123 (39.6 MiB)
Interrupt:185 Base address:0x2024
<p>lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2022 errors:0 dropped:0 overruns:0 frame:0
TX packets:2022 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2459063 (2.3 MiB) TX bytes:2459063 (2.3 MiB)启用或禁用网卡:
<pre class="brush:php;toolbar:false;"># ifconfig eth0 down</p><h1>ifconfig eth0 up
为网卡添加和删除 IPv6 地址:
<pre class="brush:php;toolbar:false;"># ifconfig eth0 add 33ffe:3240:800:1005::2/ 64 //添加IPv6地址</h1><h1>ifconfig eth0 del 33ffe:3240:800:1005::2/ 64 //删除IPv6地址
修改 MAC 地址:
<pre class="brush:php;toolbar:false;"># ifconfig eth0 down //关闭网卡</h1><h1>ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //更改MAC地址</h1><h1>ifconfig eth0 up //启动网卡</h1><h1>ifconfig eth1 hw ether 00:1D:1C:1D:1E //关闭并修改另一块网卡的MAC地址</h1><h1>ifconfig eth1 up //重新启动该网卡
配置 IP 地址:
<pre class="brush:php;toolbar:false;"># ifconfig eth0 192.168.1.56</h1><p>//为eth0网卡分配IP地址</p><h1>ifconfig eth0 192.168.1.56 netmask 255.255.255.0</h1><p>//为eth0网卡分配IP地址,并指定子网掩码</p><h1>ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255</h1><p>//为eth0网卡分配IP地址、子网掩码及广播地址
开启或关闭 ARP 协议:
<pre class="brush:php;toolbar:false;"># ifconfig eth0 arp //开启ARP</p><h1>ifconfig eth0 -arp //关闭ARP
设置最大传输单元(MTU):
<pre class="brush:php;toolbar:false;"># ifconfig eth0 mtu 1500</h1><p>//设定允许通过的最大数据包大小为1500字节
以上就是linux配置网络接口是什么-ifconfig命令使用与实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号