How to add a Static route in Linux?
Its very easy to add a static route in windows, its straight forward and will not disturb you more. But in linux the syntax is little different .
Usage: inet_route [-vF] del {-host|-net} Target[/prefix] [gw Gw] [metric M] [[dev] If]
    inet_route [-vF] add {-host|-net} Target[/prefix] [gw Gw] [metric M]
                [netmask N] [mss Mss] [window W] [irtt I]
                [mod] [dyn] [reinstate] [[dev] If]
    inet_route [-vF] add {-host|-net} Target[/prefix] [metric M] reject
    inet_route [-FC] flush    NOT supportedDont be confused by the above syntax , It is simple as below mentionedÂ
route add -net 192.168.1.0 gw 172.16.2.254 netmask 25.255.255.0
where 192.168.1.0 is the destination network
and 172.16.2.254 is the gateway to reach 192.168.1.0 network
if tou want to show the route just type route in the terminal, it will give the below listed output
[root@st1 /]# route Kernel IP routing table Destination   Gateway     Genmask     Flags Metric Ref   Use Iface 192.168.1.0   172.16.2.254   255.255.255.0  UG   0    0     0 eth0 172.16.2.0    *        255.255.255.0  U   0    0     0 eth0 169.254.0.0   *        255.255.0.0   U   0    0     0 eth0
Latest posts by Editor (see all)
- How to Show files by size, biggest last- Linux Commands - January 21, 2011
- How to test for unreadable blocks on disk- Linux Commands - January 21, 2011
- How to Do a read speed test on disk sda – Linux Commands - January 21, 2011
