lost rc.ip_forward
Hey guys,
I did something really stupid and lost my rc.ip_forward script. Is there an easy way to recover it? Some place to download the default? Thanks, Blake |
#!/bin/sh
# /etc/rc.d/rc.ip_forward: start/stop IP packet forwarding # # If you intend to run your Linux box as a router, i.e. as a # computer that forwards and redistributes network packets, you # will need to enable IP packet forwarding in your kernel. # # To activate IP packet forwarding at boot time, make this # script executable: chmod 755 /etc/rc.d/rc.ip_forward # # To disable IP packet forwarding at boot time, make this # script non-executable: chmod 644 /etc/rc.d/rc.ip_forward # Start IP packet forwarding: ip_forward_start() { if [ -f /proc/sys/net/ipv4/ip_forward ]; then echo "Activating IPv4 packet forwarding." echo 1 > /proc/sys/net/ipv4/ip_forward fi # When using IPv4 packet forwarding, you will also get the # rp_filter, which automatically rejects incoming packets if the # routing table entry for their source address doesn't match the # network interface they're arriving on. This has security # advantages because it prevents the so-called IP spoofing, # however it can pose problems if you use asymmetric routing # (packets from you to a host take a different path than packets # from that host to you) or if you operate a non-routing host # which has several IP addresses on different interfaces. To # turn rp_filter off, uncomment the lines below: #if [ -r /proc/sys/net/ipv4/conf/all/rp_filter ]; then # echo "Disabling rp_filter." # echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter #fi } # Stop IP packet forwarding: ip_forward_stop() { if [ -f /proc/sys/net/ipv4/ip_forward ]; then echo "Disabling IPv4 packet forwarding." echo 0 > /proc/sys/net/ipv4/ip_forward fi } # Restart IP packet forwarding: ip_forward_restart() { ip_forward_stop sleep 1 ip_forward_start } case "$1" in 'start') ip_forward_start ;; 'stop') ip_forward_stop ;; 'restart') ip_forward_restart ;; *) echo "usage $0 start|stop|restart" esac |
You rock!
Thanks so much! |
I got an error when I tried to run that, but it was pretty simple to fix. The "ip_forward_stop() {" is commented out, so the "}" is unexpected. I just had to move the ip_forward_stop to a new line. I do have a question though. What is the "fi" at the end of the start and stop routines, and why isn't it included at the end of the restart routine?
Thanks again |
"fi" is the ending of a "if" block.
|
I think you can disable ip_forward service unless you are using your linux box as a router.
|
All times are GMT -5. The time now is 07:36 PM. |