温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用linux的ifconfig命令显示或设置网络设备

发布时间:2020-07-11 11:30:55 阅读:202 作者:清晨 栏目:服务器
Linux服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

这篇文章主要介绍使用linux的ifconfig命令显示或设置网络设备,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

ifconfig命令的英文全称是“network interfaces configuring”,即用于配置和显示Linux内核中网络接口的网络参数。用ifconfig命令配置的网卡信息,在网卡重启后机器重启后,配置就不存在。要想将上述的配置信息永远的存的电脑里,那就要修改网卡的配置文件了。

语法格式:ifconfig [参数]

常用参数:

add<地址>设置网络设备IPv6的IP地址
del<地址>删除网络设备IPv6的IP地址
down关闭指定的网络设备
up启动指定的网络设备
IP地址指定网络设备的IP地址

参考实例

显示网络设备信息:

[root@linuxcool ~]# ifconfigeth0   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)

启动关闭指定网卡:

[root@linuxcool ~]# ifconfig eth0 down[root@linuxcool ~]# ifconfig eth0 up 

为网卡配置和删除IPv6地址:

[root@linuxcool ~]# ifconfig eth0 add 33ffe:3240:800:1005::2/64[root@linuxcool ~]# ifconfig eth0 del 33ffe:3240:800:1005::2/64

用ifconfig修改MAC地址:

[root@linuxcool ~]# ifconfig eth0 down[root@linuxcool ~]# ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE[root@linuxcool ~]# ifconfig eth0 up[root@linuxcool ~]# ifconfig eth2 hw ether 00:1D:1C:1D:1E [root@linuxcool ~]# ifconfig eth2 up

配置IP地址:

[root@linuxcool ~]# ifconfig eth0 192.168.1.56 [root@linuxcool ~]# ifconfig eth0 192.168.1.56 netmask 255.255.255.0[root@linuxcool ~]# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255

以上是使用linux的ifconfig命令显示或设置网络设备的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×