Quote:
Originally Posted by fdahl_009
ok, found this in /etc/init.d/networking; isn't this telling the computer to put 1 in ip_forward?
|
Yes it is but it is implemented as a function. Some other line will have to call this function or it will not execute.
Code:
ip_forward () {
if [ -e /proc/sys/net/ipv4/ip_forward ]; then
if [ "$VERBOSE" != no ]; then
log_begin_msg "Enabling packet forwarding..."
echo 1 > /proc/sys/net/ipv4/ip_forward
log_end_msg $?
else
echo 1 > /proc/sys/net/ipv4/ip_forward
fi
fi
}
Code:
if [ -e /proc/sys/net/ipv4/ip_forward ]; then
Here the code tests the existence of the file /proc/sys/net/ipv4/ip_forward. If this file doesn't already exist then it will not turn ip forwarding on.
Code:
if [ "$VERBOSE" != no ]; then
At this point in the code ip forwarding will be turned on. This just tests to see if a log file entry should be made.
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
This turns ip forwarding on. Notice that the echo command does not have quotes around the 1. The code in my SuSE machine had quotes around the 1. I don't know if this is important.
So one or more of three things could be happening on your system. Either
1) the /proc/sys/net/ipv4/ip_forward file doesn't exist when the system starts or
2) this function isn't being called or
3) the lack of quotes around the 1 is incorrect.
You could rewrite the function as follows to see if it is being called and if it is trying to set a 1 in the ip_forward file. Make a backup copy of your original startup file before you make any edits. This change would only be temporary.
Code:
ip_forward () {
log_begin_msg "Entering ip_forward function"
log_end_msg
if [ -e /proc/sys/net/ipv4/ip_forward ]; then
if [ "yes" != no ]; then
log_begin_msg "Enabling packet forwarding..."
echo 1 > /proc/sys/net/ipv4/ip_forward
log_end_msg $?
else
echo 1 > /proc/sys/net/ipv4/ip_forward
fi
fi
}
The changes simply attempt to make an entry to the boot log file when the function is called and to use the verbose code regardless of the value of VERBOSE, wherever that is set.
Note that I've never seen or used the log_begin_msg or log_end_msg feature so I could be introducing an error.
When the system starts you should see the message that we added at the beginning of the function when you look at dmesg or in the /var/log/boot.msg file. If you don't see the message that we added at the beginning of the function then it (probably) is not being called. (Or I messed up with the log_begin_msg).
If you do see that message then you should also see a message saying that ip_forwarding is being enabled. If not then the /proc/sys/net/ipv4/ip_forward file doesn't exist. The fix for that would be to remove the test for the existence of that file.
If you do see the message indicating that ip forwarding is being enabled then the echo command has a problem. In that case I would try putting quotes around the 1.
Or you could just change the code as follows:
Code:
ip_forward () {
log_begin_msg "Enabling packet forwarding..."
echo 1 > /proc/sys/net/ipv4/ip_forward
log_end_msg $?
}
In this form the only question is whether the function gets called. If it does get called then it will work. I didn't put quotes around the 1 because I didn't know if it would cause a problem in the middle of the log_begin_msg ... log_end_msg. You could even eliminate that question with this rewrite.
Code:
ip_forward () {
echo "1" > /proc/sys/net/ipv4/ip_forward
}