
update-rc.d
- the script (setipaddr.sh)
#! /bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:$PATH
ifconfig eth0 192.168.10.1/24
chmod +x setipaddr.sh
mv setipaddr.sh /etc/init.d
update-rc.d setipaddr.sh defaults
# If defaults is used then update-rc.d will make links to start the service in runlevels 2345 and to stop the service in runlevels 016
runlevel # get current level
systemctl
- service file (/etc/systemd/system/setipaddr.service)
[Unit]
Description=set ip on boot
After=network.target
[Service]
Type=oneshot
ExecStart=/opt/bin/setipaddr.sh
[Install]
WantedBy=multi-user.target
systemctl enable setipaddr.service