Linux : Disable and enable IPv4 forwarding
A quick note on how to disable or enable IP (version 4) forwarding in Linux. IP forwarding is a routing process used to determine which path a packet or datagram can be sent. If you are using Linux as a web server and you do not want your web server to be used in this routing process. You can disable the IP forwarding.
There are couple of ways you can disable IP forwarding.
In /etc/sysctl.conf
file, change net.ipv4.ip_forward = 0
or issue this command :
>sudo sysctl -w net.ipv4.ip_forward=0
to check if the IP forwarding has been disabled, you can view the /proc/sys/net/ipv4/ip_forward
file content. If it is 0
that means IP forwarding has been disabled.
In case you want to reverse your action, you can enable IP forwarding back with this command.
>sudo sysctl -w net.ipv4.ip_forward=1
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+29.8k Golang : Strip slashes from string example
+12.9k Golang : Set up source IP address before making HTTP request
+5.2k Golang : Array mapping with Interface
+11.4k Golang : Accurate and reliable decimal calculations
+4.5k Golang : Create new color from command line parameters
+12.2k Golang : Iterate linked list example
+15.5k Golang : Padding data for encryption and un-padding data for decryption
+7.8k Golang : Select region of interest with mouse click and crop from image
+38.6k Golang : Read tab delimited file with encoding/csv package
+3.9k Swift : Convert string array to array example
+24.1k Golang : Get time.Duration in year, month, week or day
+4.2k Fix fatal error: evacuation not done in time problem