what's the ifconfig
what's the ifconfig
ifconfig 简介
ifconfig 是 Linux 中常用的网络配置工具之一,用于配置和显示网络接口的具体状况。ifconfig 命令是在 UNIX 和类 UNIX 系统中常用的命令,它用于配置网络接口参数。以下是ifconfig命令的特点:
- 显示网络接口的状态:ifconfig命令可以显示网络接口(如网卡)的状态信息,包括IP地址、MAC地址、子网掩码、广播地址等。
- 配置网络接口参数:ifconfig命令可以配置网络接口参数,如设置IP地址、子网掩码、广播地址等。
- 显示网络接口统计信息:ifconfig命令可以显示网络接口的统计信息,如收发数据包的数量、错误数量等。
- 支持IPv4和IPv6协议:ifconfig命令支持IPv4和IPv6协议,可以用于配置和管理IPv4和IPv6网络接口。
- 可以启用和禁用网络接口:ifconfig命令可以启用和禁用网络接口,例如禁用无线网卡等。
- 可以用于调试网络问题:ifconfig命令可以用于调试网络问题,例如查看网络接口是否正常工作、是否配置正确等。
注意事项
- 用 ifconfig 命令配置的网卡信息,在网卡重启后机器重启后,配置就不存在。要想将上述的配置信息永远的存的电脑里,那就要修改网卡的配置文件。
- 要使用 ifconfig 命令,必须具有 superuser 权限。
- 在一些较新的 Linux 发行版中,ifconfig 命令已经被 ip 命令所取代,因此在使用 ifconfig 命令之前,需要先检查系统是否支持该命令。
- ifconfig 命令被用于配置和显示 Linux 内核中网络接口的网络参数。
ifconfig 安装
yum -y install net-tools
# 1.下载安装包 # 官方地址:https://vault.centos.org/7.9.2009/os/x86_64/Packages/net-tools-2.0-0.25.20131004git.el7.x86_64.rpm # 可以用 wget 下载,也可以用别的电脑下载后,scp、U盘等方式传输到目标机器 # 2.安装 rpm -ivh net-tools-2.0-0.25.20131004git.el7.x86_64.rpm # 3.测试网络命令 netstat -tuln ifconfig
ifconfig 使用
查看 ifconfig 的帮助信息
ifconfig --help
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 eth0 up # 启动网卡eth0 ifconfig eth0 down # 关闭网卡eth0
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 '''
fconfig eth0 mtu 1500
ifconfig eth0 arp #开启网卡eth0 的arp协议 ifconfig eth0 -arp #关闭网卡eth0 的arp协议
ifconfig
ifconfig -a
配置 IP 地址
ifconfig eth0 192.168.200.200 netmask 255.255.255.0 broadcast 192.168.200.255
ifconfig eth0 add 192.168.200.200 netmask 255.255.255.0
ifconfig eth0 del 192.168.200.200 netmask 255.255.255.0
ifconfig eth0 hw ether 10:BA:CB:54:86:B3
本文来自博客园,作者:''竹先森゜,转载请注明原文链接:https://www.cnblogs.com/zhuminghui/p/21479568
浙公网安备 33010602011771号