良许Linux教程网 Linux命令大全 Linux常用命令ifconfig命令具体使用方法

Linux常用命令ifconfig命令具体使用方法

Linux常用命令ifconfig命令用于显示或设置网络设备,ifconfig可设置网络设备的状态,或是显示目前的设置,下面良许教程网为大家分享一下Linux常用命令ifconfig命令具体使用方法。

Linux常用命令ifconfig命令具体使用方法

语法

 ifconfig [网络设备][down up -allmulti -arp -promisc][add][del][][io_addr][irq][media][mem_start][metric][mtu][netmask][tunnel][-broadcast][-pointopoint][IP地址]

参数说明

  • add 设置网络设备IPv6的IP地址。

  • del 删除网络设备IPv6的IP地址。

  • down 关闭指定的网络设备。

  • 设置网络设备的类型与硬件地址。

  • io_addr 设置网络设备的I/O地址。

  • irq 设置网络设备的IRQ。

  • media 设置网络设备的媒介类型。

  • mem_start 设置网络设备在主内存所占用的起始地址。

  • metric 指定在计算数据包的转送次数时,所要加上的数目。

  • mtu 设置网络设备的MTU。

  • netmask 设置网络设备的子网掩码。

  • tunnel 建立IPv4与IPv6之间的隧道通信地址。

  • up 启动指定的网络设备。

  • -broadcast 将要送往指定地址的数据包当成广播数据包来处理。

  • -pointopoint 与指定地址的网络设备建立直接连线,此模式具有保密功能。

  • -promisc 关闭或启动指定网络设备的promiscuous模式。

  • [IP地址] 指定网络设备的IP地址。

  • [网络设备] 指定网络设备的名称。

实例

显示网络设备信息

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

启动关闭指定网卡

 # ifconfig eth0 down
 # ifconfig eth0 up

为网卡配置和删除IPv6地址

 # ifconfig eth0 add 33ffe:3240:800:1005::2/ 64 //为网卡设置IPv6地址
 
 # ifconfig eth0 del 33ffe:3240:800:1005::2/ 64 //为网卡删除IPv6地址

用ifconfig修改MAC地址

 # ifconfig eth0 down //关闭网卡
 # ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //修改MAC地址
 # ifconfig eth0 up //启动网卡
 # ifconfig eth1 hw ether 00:1D:1C:1D:1E //关闭网卡并修改MAC地址
 # ifconfig eth1 up //启动网卡

配置IP地址

 # ifconfig eth0 192.168.1.56
 //给eth0网卡配置IP地址
 # ifconfig eth0 192.168.1.56 netmask 255.255.255.0
 // 给eth0网卡配置IP地址,并加上子掩码
 # ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255
 // 给eth0网卡配置IP地址,加上子掩码,加上个广播地址

启用和关闭ARP协议

 # ifconfig eth0 arp  //开启
 # ifconfig eth0 -arp  //关闭

设置最大传输单元

 # ifconfig eth0 mtu 1500
 //设置能通过的最大数据包大小为 1500 bytes

至此关于Linux常用命令ifconfig命令的使用方法分享结束,大家如果对ifconfig命令的使用方法还有问题可以通过评论区将问题提交我们。

以上就是良许教程网为各位朋友分享的Linux系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !

img

本文由 良许Linux教程网 发布,可自由转载、引用,但需署名作者且注明文章出处。如转载至微信公众号,请在文末添加作者公众号二维码。
良许

作者: 良许

良许,世界500强企业Linux开发工程师,公众号【良许Linux】的作者,全网拥有超30W粉丝。个人标签:创业者,CSDN学院讲师,副业达人,流量玩家,摄影爱好者。
上一篇
下一篇

发表评论

联系我们

联系我们

公众号:良许Linux

在线咨询: QQ交谈

邮箱: yychuyu@163.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部