《Linux学习并不难》Linux网络命令(2):ifconfig命令显示和配置网络接口

27.2  《Linux学习并不难》Linux网络命令(2):ifconfig命令显示和配置网络接口


使用ifconfig命令可以显示和配置网络接口,比如设置IP地址、MAC地址、激活或关闭网络接口。

命令语法:

ifconfig [接口] [选项| IP地址]

命令中各选项的含义如表所示。

选项

选项含义

-a

显示所有网络接口的状态

netmask <子网掩码>

设置网络设备的子网掩码

up

激活指定的网络设备

down

关闭指定的网络设备

hw <类型> <硬件地址 >

设置这个接口的硬件地址(MAC地址)。目前支持的硬件类型包括etherEthernet)、ax25 AMPR AX.25)、ARCnetnetrom AMPR NET/ROM  


例:配置网卡eno16777736的IP地址,同时激活该设备。

[root@rhel ~]# ifconfig eno16777736 192.168.0.2 netmask 255.255.255.0 up

例:配置网卡eno16777736的别名设备eno16777736:1的IP地址。

[root@rhel ~]# ifconfig eno16777736:1 192.168.0.3

例:激活网卡eno16777736:1设备。

[root@rhel ~]# ifconfig eno16777736:1 up

例:查看网卡eno16777736设备的配置。

[root@rhel ~]# ifconfig eno16777736

例:查看所有的网卡设备。

[root@rhel ~]# ifconfig -a

例:关闭网卡eno16777736:1设备。

[root@rhel ~]# ifconfig eno16777736:1 down



本文节选自Linux学习并不难》教材,这是一本最实用的、理论实践并重的Linux入门教材。如需阅览整本书的内容请访问Linux运维者www.linuxywz.com)网站




猜你喜欢

转载自blog.51cto.com/10923902/2112441