Linux中ifconfig命令的使用

1、安装ifconfig

找不到,发现ifconfig命令在net-tools 里面

yum search ifconfig
yum install net-tools  安装net-tools

 

 通过whatis命令显示简单描述

[root@rocky9 bin]# whatis ifconfig
ifconfig (8) - configure a network interface

2、ifconfig --help  通过帮助文档学习ifconfig的使用帮助

 

 3、通过man帮助学习ifconfig命令的使用

man ifconfig

 

 参数描述:

-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

4、ifconfig命令的功能和用法

Linux 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模式。
  • [IP地址] 指定网络设备的IP地址。
  • [网络设备] 指定网络设备的名称。

显示网络设备:

 

 

启动或关闭制定的网卡:

# ifconfig eth0 down
# ifconfig eth0 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


posted @ 2022-11-16 13:49  郭小栋  阅读(729)  评论(0编辑  收藏  举报