Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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:
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)...
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.
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)...
“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...”
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...
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?
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.