首先要切换到root用户

执行:

ifconfig 

如果没有IP,执行:

dhclient

如果不能执行dhclient ,先执行:

 pkill dhclient

再执行:

dhclient

就可以获取IP了。