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
+7.5k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+4.9k Javascript : How to replace HTML inside <div>?
+38.3k Golang : UDP client server read write example
+6.1k Linux : How to fix Brother HL-1110 printing blank page problem
+7.6k Golang : How to join strings?
+10.5k Get form post value in Go
+33.6k Golang : Upload and download file to/from AWS S3
+13.4k Golang : How to shuffle elements in array or slice?
+2.3k Golang : Switch Redis database redis.NewClient
+18.2k Golang : Delete item from slice based on index/key position
+15.8k Golang : How to tell if a file is compressed either gzip or zip ?
+8k Golang : automatically figure out array length(size) with three dots