36

I have searched a lot with google. It is only documented how to enable IP Forwarding in the linux kernel but not WHEN and WHY I have to enable it. I would be thankful for advice.

When and why do I have to enable it? (For example when I install a bridge?, or when using iptables? or when using route add ?)

(Good links are appreciated, but I was not able to found one. )

Thank you very much!

Jan

1
  • it is basically for inter-network pkt transfer and not for inter interface transfers. by this i mean that if two interfaces are on the same network den we dont need to enable IP forwarding on the server,i believe.... only for a server inbetween two networks or LANS.....hope this helps:D – user303748 Aug 7 '15 at 14:53
40

IP forwarding should be enabled when you want the system to act as a router, that is transfer IP packets from one network to another.

In the simplest case, consider a server with two physical ethernet ports which is meant to connect to two different networks (say your internal network and the outside world as provided by a DSL modem). If you just connect and configure those two interfaces, the system can communicate on either network. However, packets from one network cannot travel to the other network, because forwarding is not enabled.

Consider the specific example of 'route add'. If you have two network interfaces, you will add a minimum of two routes, one for each interface. When the kernel considers where to send a network packet, it will pick the most specific applicable route and then send it along to that interface.

However, if forwarding is turned off, the kernel will first check to see which interface the packet came from. If it didn't come from the same interface, the kernel will discard it.

EDIT: First note that you can use a router without having two physical network interfaces. For example if you are using VLANs, your server can transfer IP packets between vlans but only have one physical network interface. This is called a one-armed router. However for the simplest case yes you can say that if you only have one physical network interface then you don't need to enable IP forwarding.

IP forwarding involves transferring packets between network interfaces (real or virtual) so I think that if you had two interfaces on the same network, you would have to enable ip forwarding to allow packets to move between the interfaces. However since the interfaces are already on the same network, it doesn't seem to make a lot of sense to transfer packets between them.

2
  • Basically, if you aren't using the computer as a router, i.e. if you don't have 2 network cards installed, do not enable IP forwarding. – LawrenceC Mar 18 '11 at 2:27
  • thanks for the answer: Is it a requirement that the IP packets go over interfaces or is the focus on "go over network boundries", that is also "inter process communication" requires IP Forwarding (if crossing network boundries)? And secondly does this only apply with packets crossing different networks (like xxx.xxx.xxx.xxx/24 and yyy.yyy.yyy.yyy/24) or also with pakets within the same network going from one interface to another? thanks. – jan Mar 18 '11 at 2:54
1

According to Wikipedia...

IP forwarding also known as Internet routing is a process used to determine which path a packet or datagram can be sent. The process uses routing information to make decisions and is designed to send a packet over multiple networks. Generally, networks are separated from each other by routers.

It is required when you want the system to use as a router. Check the link below to know the exact use of the IP forwarding. http://www.linuxjournal.com/content/linux-advanced-routing-tutorial?

0

IP forwarding enable your computer act as a router when it is enabled, so that packets can pass through that as well so that it will ease to reach source to destination.

Found a simple explanation here in Youtbe video link

Probably this will helo in high level!

2
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Gerald Schneider Nov 26 '20 at 7:47
  • Thanks i have added it! – user17109 Nov 26 '20 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.