Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. Enabling IP port forwarding on the fly
  2.  
  3. Enable IP Forwarding on the fly
  4.  
  5. As with any sysctl kernel parameters we can change the value of net.ipv4.ip_forward on the fly (without rebooting the system):
  6.  
  7. sysctl -w net.ipv4.ip_forward=1
  8. or
  9.  
  10. echo 1 > /proc/sys/net/ipv4/ip_forward
  11. the setting is changed instantly; the result will not be preserved after rebooting the system.
  12.  
  13. Permanent setting using /etc/sysctl.conf
  14.  
  15. If we want to make this configuration permanent the best way to do it is using the file /etc/sysctl.conf where we can add a line containing net.ipv4.ip_forward = 1
  16.  
  17. /etc/sysctl.conf:
  18. net.ipv4.ip_forward = 1
  19. if you already have an entry net.ipv4.ip_forward with the value 0 you can change that 1.
  20.  
  21. To enable the changes made in sysctl.conf you will need to run the command:
  22.  
  23. sysctl -p /etc/sysctl.conf
  24. On RedHat based systems this is also enabled when restarting the network service:
  25.  
  26. service network restart
  27. and on Debian/Ubuntu systems this can be also done restarting the procps service:
  28.  
  29. /etc/init.d/procps.sh restart
  30. Using distribution specific init scripts
  31.  
  32. Although the methods presented above should work just fine and you would not need any other method of doing this, I just wanted to note that there are also other methods to enable IP Forwarding specific to some Linux distributions. For example Debian based distributions might use the setting:
  33.  
  34. /etc/network/options:
  35. ip_forward=no
  36. set it to yes and restart the network service. Also RedHat distributions might set this using:
  37.  
  38. /etc/sysconfig/network:
  39. FORWARD_IPV4=true
  40. and again restart the network service.
  41.  
  42. Regardless the method you have used once you have completed this you can check it out using the same method shown above:
  43.  
  44. sysctl net.ipv4.ip_forward
  45. net.ipv4.ip_forward = 1
  46.  
  47.  
  48.  
  49.  
  50. cat /proc/sys/net/ipv4/ip_forward
  51. 1
  52. If the result is 1 then the Linux system will start forwarding IP packets even if they are not destined to any of its own network interfaces.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement