Operating System - Linux
1831645 Members
2369 Online
110029 Solutions
New Discussion

what differences with setup gateway Vs route add default gateway?

 

what differences with setup gateway Vs route add default gateway?

i can set one gateway and dns by manuel of setup.networking setting.gateway, on the other hand, i can also set gateway by
route add -net default gateway 192.168.0.1 dev eth0

my problem is , what differences with this two way? why the linux can remember the fore one and i has to reset the behind one, after the network restart???

thanks for your tips,
frederick

frederick
2 REPLIES 2
U.SivaKumar_2
Honored Contributor

Re: what differences with setup gateway Vs route add default gateway?

Hi,
When you setup a gateway , if modifies the kernel routing table and the configuration
file.
So When you restart the route entry is read from the configuration file and put in to kernel routing entry. Therefore route persists
even after reboot.
But When you use route add command route added
directly to kernel routing table and it does not alter the configuration file.So route is lost if system reboots.

regards,
U.SivaKumar

Innovations are made when conventions are broken
U.SivaKumar_2
Honored Contributor

Re: what differences with setup gateway Vs route add default gateway?

HI,
When you setup gateway the gateway is configured in this file /etc/sysconfig/network
The file is saved with new gateway. So even after reboot the system will get the route read
from the above file.

regards,
U.SivaKumar
Innovations are made when conventions are broken