需求:启动linux是需要添加自定义ip地址到eth0网卡
在/etc/rc.d/init.d目录下编辑auto_run文本:
#!/bin/bash
#add ip eth0ip addr add 10.8.2.1/32 dev eth0
添加auto_run服务: chkconfig --add auto_run
报错:
service auto_run does not support chkconfig
经过查证后才知需要添加两句代码:
#chkconfig: - 85 15
#description: nginx is a World Wide Web server. It is used to serve
修改后:
#!/bin/bash
#add ip eth0#chkconfig: - 85 15
#description: nginx is a World Wide Web server. It is used to serve
ip addr add 10.8.2.1/32 dev eth0
添加auto_run:
chkconfig --add auto_run
成功!
设置auto_run服务开机自启动:
chkconfig auto_run on
本文介绍如何在Linux系统中为eth0网卡配置自定义IP地址,并实现开机自启动。通过编写shell脚本并添加相应服务,确保每次系统启动时都能自动应用该IP配置。

3295

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



