startup scripts
Where do I put scripts so that they run at boot?
|
depends what they are really. some more information would be useful....
if it's just a nondescript script then you can added it to the end of /etc/rc.local. |
You can put small ones in /etc/rc.local
If your script is a seperate file you an put it anywhere and just have a reference to it in rc.local ie: Code:
# in rc.local |
I want to run iptables and nat so I want to run this script:
iptables --flush - Flush all the rules in filter and nat tables iptables --table nat --flush iptables --delete-chain - Delete all chains that are not in default filter and nat table iptables --table nat --delete-chain # Set up IP FORWARDing and Masquerading iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE iptables --append FORWARD --in-interface eth0 -j ACCEPT - Assuming one NIC to local LAN echo 1 > /proc/sys/net/ipv4/ip_forward - Enables packet forwarding by kernel |
yeah i'd just stick that in rc.local, but if you wanted to create a full blown service file for it you should be able to.
|
Quote:
Thanks for the quick replies btw :) |
Depending on your distro, there are files to stop and start most of your services. They are usually in /etc/rc.d but may be elsewhere. They are tough for a beginner so depending on your experience you will probably just want to stick with rc.local
For a firewall what I did was put the commands in a file called /etc/rc.d/firewall , then simply add "/etc/rc.d/firewall" to rc.local. Make sure that it is executable and has "#!/bin/bash" as the first line. |
I have iptables running as a service/deamon. I'm running redhat 8.
I can put the above scripts in an iptables config file too? If so, where is this config file? |
iptables config
The iptables config is located at:
/etc/sysconfig/iptables Your best best is to set up your firewall using the script, then running: iptables-save This rewrites your firewall setup to /etc/sysconfig/iptables. |
All times are GMT -5. The time now is 01:18 PM. |