Linux ifconfig(英文全拼:network interfaces configuring)命令用于显示或设置Linux内核中网络接口的网络参数。
语法格式:ifconfig [参数]
常用参数:
add<地址> | 设置网络设备IPv6的IP地址 |
del<地址> | 删除网络设备IPv6的IP地址 |
down | 关闭指定的网络设备 |
up | 启动指定的网络设备 |
IP地址 | 指定网络设备的IP地址 |
参数说明:
参考实例
显示网络设备信息:
[root@bunian ~]# ifconfigeth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.17.0.12 netmask 255.255.240.0 broadcast 172.17.15.255 inet6 fe80::5054:ff:fe7f:b032 prefixlen 64 scopeid 0x20<link> ether 52:54:00:7f:b0:32 txqueuelen 1000 (Ethernet) RX packets 8261454 bytes 1055415894 (1006.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 7614067 bytes 1170666685 (1.0 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: 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 90 bytes 11225 (10.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 90 bytes 11225 (10.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
启动关闭指定网卡:
[root@bunian ~]# ifconfig eth0 down[root@bunian ~]# ifconfig eth0 up
为网卡配置和删除IPv6地址:
[root@bunian ~]# ifconfig eth0 add 33ffe:3240:800:1005::2/64[root@bunian ~]# ifconfig eth0 del 33ffe:3240:800:1005::2/64
用ifconfig修改MAC地址:
[root@bunian ~]# ifconfig eth0 down[root@bunian ~]# ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE[root@bunian ~]# ifconfig eth0 up[root@bunian ~]# ifconfig eth1 hw ether 00:1D:1C:1D:1E [root@bunian ~]# ifconfig eth1 up
配置IP地址:
[root@bunian ~]# ifconfig eth0 192.168.1.100 //给eth0网卡配置IP地址[root@bunian ~]# ifconfig eth0 192.168.1.100 netmask 255.255.255.0 // 给eth0网卡配置IP地址,并加上子掩码[root@bunian ~]# ifconfig eth0 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255 // 给eth0网卡配置IP地址,加上子掩码,加上个广播地址
启用和关闭ARP协议
[root@bunian ~]# ifconfig eth0 arp //开启[root@bunian ~]# ifconfig eth0 -arp //关闭
设置最大传输单元
[root@bunian ~]# ifconfig eth0 mtu 1500 //设置能通过的最大数据包大小为 1500 byte
Copyright © 2013-2021 8a.hk All Rights Reserved. 八艾云 版权所有 中山市八艾云计算有限公司 粤ICP备14095776号