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
+29k Golang : Calculate percentage change of two values
+25.2k Golang : Find files by extension
+8.1k Golang : How to check if a string with spaces in between is numeric?
+14.9k Golang : Read integer from file into array
+5.6k Golang : Calculate pivot points for a cross
+13.8k Golang : How to check for empty array string or string?
+6.5k Golang : Handling Yes No Quit query input
+17.6k Golang : Get host name or domain name from IP address
+26.5k Golang : Decode/unmarshal unknown JSON data type with map[string]interface
+20.9k Golang : Read directory content with filepath.Walk()
+35.1k Golang : Convert date or time stamp from string to time.Time type
+6.9k Golang : Load DSA public key from file example