阿里云部署服务器的时候出现ifconfig没有网卡信息的问题,导致ssh连接不上,使用sudo dhclient eth0也只能在本次机器启动生效。所以需要将指令写到开机启动服务里边。
使用https://www.cnblogs.com/airdot/p/9688530.html提供方法设置启动服务。
rc.lcoal 里边写:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo dhclient eth0
echo "看到这行字,说明添加自启动脚本成功。" > /usr/local/test.log
exit 0
启动服务即可。