前言:

By installation default, Linux distribution such as Redhat, CentOS, White OS,
and Fedora comes with IP Forwarding disabled.
The reason for this is that default linux installation, whether desktop or server,
does not consider a default OS installation of forwarding IP packets and request by default,
as the linux OS is not fully aware of how the users are planning to make use of
the Linux OS installation or even if the users need to enable /IP for
The need to forward IP packets from one source to another using linux
as the default gateway or linux router,
IP forwarding should be enabled from this considerations.
IP Forwarding can be done in many different ways that aims to only one thing, enable IP forwarding.

確認: ip forward是否開啟

(法一)
# cat /proc/sys/net/ipv4/ip_forward
如果ip_forward 開啟 顯示1
      ip_forward 關閉 顯示0

(法二)
# cat /etc/sysctl.conf | grep net.ipv4.ip_forward
or
# sysctl net.ipv4.ip_forward

net.ipv4.ip_forward = 0 ==> ip_forward關閉
net.ipv4.ip_forward = 1 ==> ip_forward開啟

修改: 開啟ip_forward

(法一)暫時修改
# echo 1 > net.ipv4.ip_forward = 1
or
# sysctrl -w net.ipv4.ip_forward=1

此兩種方法改完ip_forward就有效果了但是卻不是永久的
下次開機 要再重新設定 除非你每次開機都打一次或者把此指令寫到開機檔/etc/rc.local

(法二)永久修改
開啟 /etc/sysctl.conf

找到 net.ipv4.ip_forward = 0
改成 net.ipv4.ip_forward = 1

之後存檔離開即成功開啟ip_forward

 

 

reference: http://vertito.blogspot.tw/2008/07/how-to-enable-ip-forwarding-in-linux.html

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 LittleChoCho 的頭像
    LittleChoCho

    宇宇的異想世界

    LittleChoCho 發表在 痞客邦 留言(0) 人氣()