LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-28-2005, 03:29 PM   #1
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Rep: Reputation: 30
Question Routes


Hi,

I understand that I can configure my NIC using ifconfig or netcfg. I was wondering what's the purposes of using the route command and what does it exactly do.

Thanks.
 
Old 04-28-2005, 03:36 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Route manipulates the kernel's IP routing tables. Its
primary use is to set up static routes to specific hosts
or networks via an interface after it has been configured
with the ifconfig(8) program.

When the add or del options are used, route modifies the
routing tables. Without these options, route displays the
current contents of the routing tables.
do a man route for more info...

 
Old 04-28-2005, 03:44 PM   #3
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Original Poster
Rep: Reputation: 30
Sorry win32sux, I still don't follow what it exactly achieves. Can you give me an example of when I use routes and when I don't?
 
Old 04-28-2005, 03:51 PM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
well, you are using a route right now... you are able to connect to this website because you are sending IP packets through a gateway... so (for example) you could use the route command to set your gateway, like, if you have just configured the eth0 interface with ifconfig (ip and netmask) and you need to set it's gateway to 192.168.0.1 you could do a:
Code:
route add default gateway 192.168.0.1 eth0
 
Old 04-28-2005, 06:16 PM   #5
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Original Poster
Rep: Reputation: 30
Thanks. However how does that differ to me editing the /etc/sysconfig/network and adding a reference to GATEWAY and GATEWAYDEV for example?
 
Old 04-28-2005, 06:20 PM   #6
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
changes made using the route command (or ifconfig) don't get written to disk, hence they will be gone upon reboot.. also, when you make changes in your config file you'd have to restart the network for them to take effect (so that the ifconfig/route commands in your network scripts could pick-up the changes)...


Last edited by win32sux; 05-20-2005 at 05:20 PM.
 
Old 04-28-2005, 06:29 PM   #7
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Original Poster
Rep: Reputation: 30
Ok, let me get this right. From what you are saying if I use route/ifconfig the changes are not permanent (not taking into account I may have amended my config file) and hence it’s a temporary solution to get a network solution? Is this assumption correct? I suppose if I want them to be permanent I could just add the ‘rules’ to the /etc/rc.d/rc.local file (if I don’t update the configuration files). So I don’t really need to use route if I have updated the config files. Is this assumption correct? If so why would I use route to check my routing?

Sorry if this sounds dumb but am trying to get my head around routes.
 
Old 04-28-2005, 06:44 PM   #8
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
yeah, technically you could add route/ifconfig commands to your rc.local if you wanted to... like, for example, you could add an ifconfig command that would spoof a MAC address for your network interface, or a route command that would change the tcp window size for connections going through a certain route...

looking at your config files will show you what you are supposed to have (in other words, what ifconfig/route would pick-up next time the network scripts are run), but looking at the output of ifconfig/route will show you what you are CURRENTLY working with, regardless of what could be written in your configs - so by manually using ifconfig/route to look at the info they output you could maybe spot errors in your configs, for example (among other things)...


Last edited by win32sux; 05-20-2005 at 05:22 PM.
 
Old 04-28-2005, 06:48 PM   #9
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Original Poster
Rep: Reputation: 30
Thanks. That's starting to make sense. It's primarily a tool for 'debugging'. What else could I use them for?
 
Old 04-28-2005, 06:51 PM   #10
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Original Poster
Rep: Reputation: 30
Based on your comment

“looking at your config files will show you what you are supposed to have, but looking at the output of ifconfig/route will show you what you are currently working with, regardless of what could be written in your configs - they could help you spot errors in your configs, for example, among other things...”

How does it differ to the comment “hi there it reads from your ethernet card configuration files generally /etc/sysconfig/network-scripts/ifcfg-eth0” from http://www.linuxquestions.org/questi...hreadid=299489
 
Old 04-28-2005, 06:52 PM   #11
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
there's route use examples in the route man page:

http://www.die.net/doc/linux/man/man8/route.8.html
 
Old 04-28-2005, 06:58 PM   #12
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally posted by Obie
How does it differ to the comment “hi there it reads from your ethernet card configuration files generally /etc/sysconfig/network-scripts/ifcfg-eth0”
i just opened my network configuration files... i changed my IP address to PIZZA... i changed my netmask to MUSHROOMS... i made my gateway SOMALIA... then i saved the changes and i exited the text editor... then i did a "ifconfig" and guess what... IT DIDN'T SHOW ANYTHING ABOUT SOMALI MUSHROOM PIZZA... hehe... why? because ifconfig and route don't care about what i have in my configs, they will only show me my current ACTIVE configuration...

note to self: remember undo the changes the conf file, hehe...


Last edited by win32sux; 04-28-2005 at 07:02 PM.
 
Old 04-28-2005, 07:01 PM   #13
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Original Poster
Rep: Reputation: 30
Thanks. So how do they know what you are running currently assuming I didn't run the ifconfig and route command? I'm assuming after making those changes you restarted the network daemon?
 
Old 04-28-2005, 07:06 PM   #14
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
no, i didn't restart the network, that's the point...

if i would have restarted then the new configuration would have become active (the ifconfig/route commands in my network script would have picked-up the new config), and it would then be what ifconfig/route would report... ifconfig/route themselves DON'T read from the config file, the network startup script does that...

of course in my example the pizza and mushrooms wouldn't be valid parameters so the network would probably not even come-up and route/ifconfig would show that... i would be able to see with route/ifconfig that my network was down and mis-configured... looking at the config files wouldn't tell me anything about the current status of the network - looking at route/ifconfig would...


Last edited by win32sux; 05-20-2005 at 05:25 PM.
 
Old 04-28-2005, 07:10 PM   #15
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Original Poster
Rep: Reputation: 30
ahhh, that makes sense. I was right in saying that they are 'debugging tools'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
routes himyuza *BSD 6 08-03-2004 10:41 AM
where are routes stored? Ph0enix2003 Linux - Networking 1 06-23-2004 10:46 PM
I need some routes |Drakehash| Linux - Newbie 1 06-08-2003 12:22 AM
I need some routes |Drakehash| Linux - Networking 1 06-07-2003 02:36 PM
Multiple routes DavidPhillips Linux - Networking 2 12-03-2001 12:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration