文章出处:http://blog.csdn.net/shift_wwx
使用ifconfig eth0 down; ifconfig eth0 up
使用disable networking 后 enable networking
等都不行。
ifconfig 是一个用来查看、配置、启用或禁用网络接口的工具,这个工具极为常用的。可以用这个工具来临时性的配置网卡的IP地址、掩码、广播地址、网关等。也可以把它写入一个文件中(比如/etc/rc.d/rc.local),这样系统引导后,会读取这个文件,为网卡设置IP地址。
激活和终止网络接口的用ifconfig 命令,后面接网络接口,然后加上down或up参数,就可以禁止或激活相应的网络接口了。当然也可以用专用工具ifup和ifdown 工具
来看一下/etc/network/interfaces:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
可以看到eht0是自动获取ip,用的是dhcp协议,所以对于DHCP自动分配的ip,就不能用ifconfig来激活或停止。
dhclient -r eth0;
dhclient eth0;
就跟windows中的ipconfig /release一样
本文介绍了如何在Linux系统中配置网络接口,包括使用ifconfig工具激活和禁用网络接口的方法,以及针对DHCP自动分配IP地址的情况如何进行操作。文中还提到了dhclient命令的作用类似于Windows系统的ipconfig/release。
912

被折叠的 条评论
为什么被折叠?



