Aspegic
Verified User
- Joined
- Aug 4, 2005
- Messages
- 283
I am setting up a new Centos 7 server to replace an old Centos 6 server.
I have installed DirectAdmin on the Centos 7 server. Everything works great.
I need this server to also act as a NAT server, so I created a csfpost.sh file with the following content:
I made the script executable and put it in the folder /etc/csf
This script runs fine and does exactly what it needs to do.
The problem is that it does not execute at startup. When I reboot the server, this script is not executed. I first have to login to DirectAdmin and choose "Firewall Restart" . Then the script is executed and it works.
I would assume that CSF is started automatically at boot time, and that it would execute csfpost.sh automatically, as is stated in the documentation. But it seems not.
I have searched a lot and tried several different solutions, but none have worked so far.
I tried adding csf -r to rc.local. That did not work.
I tried adding csfpost.sh itself to rc.local. That did not work either.
I do not know why it is not working....
Is there someone who can tell me what I need to do?
Thanks!
I have installed DirectAdmin on the Centos 7 server. Everything works great.
I need this server to also act as a NAT server, so I created a csfpost.sh file with the following content:
Code:
#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
/usr/sbin/iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
/usr/sbin/iptables -t nat -A POSTROUTING -o ens2 -j MASQUERADE
/usr/sbin/iptables --append FORWARD --in-interface eno1 -j ACCEPT
I made the script executable and put it in the folder /etc/csf
This script runs fine and does exactly what it needs to do.
The problem is that it does not execute at startup. When I reboot the server, this script is not executed. I first have to login to DirectAdmin and choose "Firewall Restart" . Then the script is executed and it works.
I would assume that CSF is started automatically at boot time, and that it would execute csfpost.sh automatically, as is stated in the documentation. But it seems not.
I have searched a lot and tried several different solutions, but none have worked so far.
I tried adding csf -r to rc.local. That did not work.
I tried adding csfpost.sh itself to rc.local. That did not work either.
I do not know why it is not working....
Is there someone who can tell me what I need to do?
Thanks!
Last edited: