Linux routing table question

Posted on 2012-09-10
Last Modified: 2012-10-10
I have a question regarding linux routing table. IF  I  understand correctly,   all the incoming traffic and icoming traffics are handle through routing table. I thought only  outgoing traffic go through  routing table

Please confirm
Question by:mokkan
    LVL 68

    Assisted Solution

    As long as your machine doesn't carry out router/gateway functions incoming traffic is not affected by the routing table.
    LVL 19

    Assisted Solution

    This is not specifically a Linux question.

    This may provide some useful information

    Author Comment

    Its a linux question. For an example if we look at the routing table (netstat  -rn) , we can see what traffic go through what interface. My question is that, when traffic comes in, does it forward it to necessary interface?
    LVL 68

    Assisted Solution

    Traffic comes in through its interface to reach the respective port/application. No routing takes place.

    The statistics shown with "netstat -rCe" show under "Use" the number of packets sent via the particular route (Unix) or lookups (Linux) and the current number of active uses (Ref)
    LVL 57

    Assisted Solution

    In the most simplest terms, the routing table it used use to by the local host to figure out how to get to to a another host.  That is, it is used for outbound traffic only.

    When the local host goes to send traffic out, it uses the routing table to figure out what interface to use to send the traffic out on.  If the destination host is on a different IP subnet than the local host, it the routing table is also used to identify which gateway/router it must used.

    If a host has more than one IP address, inbound traffic is NOT routed to the local destination it is just "passed" if the traffic came in on a interface the destination address is not associated with.
    LVL 19

    Expert Comment

    I was trying to point out that the question is relevant to the way all routing works, not specifically Linux.

    I always thought that the routing was for outgoing connections and anything coming in would have been directed by the local gateways/routers but your q just got me wondering.

    Did the Wikipedia article not help.
    LVL 25

    Accepted Solution

    actually, most systems including linux go through the routing table when an incoming packet enters the system (and basically any time the IP stack is used, so the same applies for some of the loopback traffic).

    The routing table contains "local" entries that will tell the system that the destination is local. It is a bad idea to toy with these entries but you can display them. All the information you will get is useless if you already know your machine's addresses.

    These entries can be viewed on linux by using "ip route show dev ethX table local"

    but conceptually, since these roots are automagically handled by the kernel, you do not care about these routes unless the packets are leaving your machine


    /!\ just for the record, when we speak about incoming packets, we usually speak about packets routed by the host, bridged by the host or actually using the host as a destination, so much of the online documentations will be difficult to read not knowing this.

    Author Closing Comment

    Thank you all.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (…
    I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension ( This reminded me of questions tha…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now