cancel
Showing results for 
Search instead for 
Did you mean: 
spurs
Flight Engineer
Flight Engineer
  • 843 Views

Enable packet forwarding?

Jump to solution

Hi guys, 

I was watching YouTube for RHCSA and there was a question asking that "Enable packet forwarding. This should persist after reboot"

and what the YouTuber did was configure/etc/sysctl.conf  [net.ipv4.ip_forward=1], and after reboot 

cat /proc/sys/net/ipv4/ip_forward and it showed 1. 

Anyone can explain what was going on here? I just don't want to memorize without understanding.

Tags (4)
1 Solution

Accepted Solutions
Chetan_Tiwary_
Moderator
Moderator
  • 758 Views

Hello @spurs !

Kernel parameters are variables that control the behavior of the Linux kernel. They can be configured at boot time, or they can be changed while the kernel is running. Here : net.ipv4.ip_forward  - this is a kernel parameter which controls whether or not the Linux kernel will forward IP packets between different networks. 

To list other kernel parameters - you can run this command : #sysctl -a 

/proc directory is a special directory in the Linux filesystem that contains information about the kernel and the running processes. It also contains files that can be used to configure kernel parameters.

For preparation of EX200 - I would strongly recommend to study the objectives mentioned here : https://www.redhat.com/en/services/training/ex200-red-hat-certified-system-administrator-rhcsa-exam?... 

Random post / video makers may have to tune some settings in their system in order to teach something ( which makes it complex and can deviate from the main objective of EX200) - hence you might need to filter out the notes from those  

Enrol in a training if you need by reaching out to : training@redhat.com 

View solution in original post

Tags (1)
4 Replies
Chetan_Tiwary_
Moderator
Moderator
  • 796 Views

Hello @spurs !

Thanks for reaching out !

You can refer to EX200 ( RHCSA ) objectives for your preparation : https://www.redhat.com/en/services/training/ex200-red-hat-certified-system-administrator-rhcsa-exam?... 

I doubt that these kernel parameter configurations are part of EX200 objectives. 

Coming back at your query :

Packet forwarding or IP forwarding is the ability for an operating system to accept incoming network packets on one interface, recognize that it is not meant for the system itself, but that it should be passed on to another network, and then forwards it accordingly. 

It is also known as Kernel IP forwarding because it uses the net.ipv4.ip_forward kernel variable. 

sysctl command allows you to view and change Linux kernel parameters ( refer here : https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/kernel_administration_... ) 

Now ,you can use the following sysctl command to check whether IP forwarding is enabled or disabled.
# sysctl net.ipv4.ip_forward


net.ipv4.ip_forward = 0


0 means it’s off. If it were set to 1, that would mean it’s enabled.

You can check the same through proc filesystem as well :

#cat  /proc/sys/net/ipv4/ip_forward

/proc directory on Linux contains virtual files that provide access to kernel information and configuration. When you execute cat /proc/sys/net/ipv4/ip_forward, it reads the current value of the net.ipv4.ip_forward parameter directly from the kernel  ( https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html )

***********************************************

So you can change the setting to enable or disable ( i.e 0 or 1 ) by using either of the below methods : 

1.  # sysctl -w net.ipv4.ip_forward=0                                 ( or 1 )

2.  # echo 0 > /proc/sys/net/ipv4/ip_forward                     ( or echo 1)

 

This will not persist after reboot. Hence to make changes permanent we need to edit the configuration file /etc/sysctl.conf : 

and add the line at the EOF :

net.ipv4.ip_forward = 0
OR
net.ipv4.ip_forward = 1

Run this command to make the it effective right away:  # sysctl -p  

 Then you can check the value you set uisng the cat /proc/sys/net/ipv4/ip_forward

**************************************************************************************

I would not recommend you to go this deep at RHCSA level. Post RHCE you can check the same in exams like EX342 & EX442 which are higher level exams. 

spurs
Flight Engineer
Flight Engineer
  • 760 Views

Cool! So, to check to enable or disable I can use both ways 

1. sysctl net.ipv4.ip_forward

2. cat /proc/sys/net/ipv4/ip_forward

Also, "I doubt that these kernel parameter configurations are part of EX200 objectives." in this, what exactly kernel parameter configuration is? is it because we are configuring /proc directory?

and sysctl -w is for temporary and to configure permanently, edit /etc/sysctl.conf.

You don't think packet forwarding is not on the exam as it's not on the objective right?
I didn't know that I was just searching for some random mock test videos.

Tags (2)
Chetan_Tiwary_
Moderator
Moderator
  • 759 Views

Hello @spurs !

Kernel parameters are variables that control the behavior of the Linux kernel. They can be configured at boot time, or they can be changed while the kernel is running. Here : net.ipv4.ip_forward  - this is a kernel parameter which controls whether or not the Linux kernel will forward IP packets between different networks. 

To list other kernel parameters - you can run this command : #sysctl -a 

/proc directory is a special directory in the Linux filesystem that contains information about the kernel and the running processes. It also contains files that can be used to configure kernel parameters.

For preparation of EX200 - I would strongly recommend to study the objectives mentioned here : https://www.redhat.com/en/services/training/ex200-red-hat-certified-system-administrator-rhcsa-exam?... 

Random post / video makers may have to tune some settings in their system in order to teach something ( which makes it complex and can deviate from the main objective of EX200) - hence you might need to filter out the notes from those  

Enrol in a training if you need by reaching out to : training@redhat.com 

Tags (1)
spurs
Flight Engineer
Flight Engineer
  • 752 Views

Alright thank you so much!

Join the discussion
You must log in to join this conversation.