How to disable IP forwarding on RHEL 9?

Updated -

You can disable IPv4 and IPv6 forwarding either temporarily or permanently. The following sections describe both methods.

  1. Temporary Disable (until reboot)

    To immediately disable IPv4 and IPv6 forwarding without rebooting, run:

     $ sysctl -w net.ipv4.ip_forward=0
     $ sysctl -w net.ipv6.conf.all.forwarding=0
    
  2. Permanent Disable (persistent across reboots)

    2.1 Edit /etc/sysctl.conf

    net.ipv4.ip_forward = 0
    net.ipv6.conf.all.forwarding = 0
    

    2.2 Reload sysctl settings:

    $ sysctl -p

Comments