[网络] 如何开机自动配置静态IP,并自动启动程序
背景:
需要固定ip地址,并且能够自动启动可执行文件。
流程:
1.在/etc/network/interfaces 中添加
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
2.将下面这行代码添加自动启动脚本
/etc/init.d/networking restart
这里/etc/inin.d/下的networking 可能对应不同的固件,名字不一样。比如1126中的就是
/etc/inin.d/S40network
自动执行脚本,在终端输入下面命令:
vi /etc/profile
...
/etc/init.d/networking restart
/home/.../start.sh
注意先配置ip,再启动程序,否则程序里可能会连不上。