# echo "1" > /proc/sys/net/ipv4/ip_forward
this enables forwarding till you reboot your box
to make ip forwarding available upon boot, you can set forwarding in /etc/sysconfig/network by adding
FORWARD_IPV4="TRUE"
i have a note that this doesn't work on CentOS, though.
another way is to create a start-up script to set a value in the ip_forward file
# vi /etc/init.d/ip_forward
then add the following lines:
#!/bin/bash
# ip_forward
#
# chkconfig: 235 90 25
# description: enable ip_forward
PATH=/usr/bin:/sbin:/bin:/usr/sbin
export PATH
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
start() {
echo "1" > /proc/sys/net/ipv4/ip_forward
}
stop() {
echo "0" > /proc/sys/net/ipv4/ip_forward
}
restart() {
stop
start
}
status() {
cat /proc/sys/net/ipv4/ip_forward
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|status}"
exit 1
esac
exit $?
after creating the start-up file, add it in chkconfig as a service
# chkconfig --add ip_forward
ps. you can also just add this to your network start-up script
echo "1" > /proc/sys/net/ipv4/ip_forward
happy forwarding!!
ps. ps. one more way to do this in CentOS (tried it in 6.3) is by editing your
/etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
No comments:
Post a Comment