La tabella di routing contiene una lista di reti e le rotte verso queste. E’ possibile da riga di comando mettere rotte statiche permanenti e non, nel caso di rotte non permanenti al reboot queste andranno perse.
Se vuoi aggiungere le rotte statiche, “route” è il comando da utilizzare:
route syntax
route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]
-f : Pulisce la tabella di routing.
-p : Quando usato con il comando add rende la rotta permanente ad ogni reboot del sistema.
Command : Sono i comandi che vuoi eseguire.
add
change
delete
mask Netmask : indica la netmask (sottorete).
Gateway : Specifies the forwarding or next hop IP address over which the set of addresses defined by the network destination and subnet mask are reachable.
metric Metric : Specifies an integer cost metric (ranging from 1 to 9999) for the route, which is used when choosing among multiple routes in the routing table that most closely match the destination address of a packet being forwarded.
if Interface : Specifies the interface index for the interface over which the destination is reachable.
Esempi:
Per mostrare il contenuto della tabella di routing:
route print
Per mostrare le rotte che iniziano con 10.:
route print 10.*
Per aggiungere una rotta statica con relativo indirizzo di gateway 192.168.12.1:
route add 0.0.0.0 mask 0.0.0.0 192.168.12.1
Per aggiungere una rotta per tutta la rete 10.41.0.0 con subnetmask 255.255.0.0 ed indirizzo gateway 10.27.0.1:
route add 10.41.0.0 mask 255.255.0.0 10.27.0.1
Per rendere una rotta permanente, dobbiamo aggiungere lo switch -p:
route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1
Per eliminare la rotta 10.41.0.0 con subnetmask 255.255.0.0:
route delete 10.41.0.0 mask 255.255.0.0
Per eliminare tutte le rotte che cominciano con 10.:
route delete 10.*
Per modificare una rotta:
route change 10.41.0.0 mask 255.255.0.0 10.27.0.25
e così via…..