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
+43.9k Golang : Get hardware information such as disk, memory and CPU usage
+13.3k Golang : How to get a user home directory path?
+19.4k Golang : Execute shell command
+16.2k Golang : Read large file with bufio.Scanner cause token too long error
+33.9k Golang : All update packages with go get command
+22.9k Golang : Round float to precision example
+12.5k Golang : How to display image file or expose CSS, JS files from localhost?
+7k Golang : Decode XML data from RSS feed
+23.3k Golang : simulate tail -f or read last line from log file example
+12.4k Golang : Split strings into command line arguments
+52.9k Golang : How to get struct field and value by name
+14k Golang : Image to ASCII art example