route command and its examples

The route command is used to display and modify the routing table of a system. Command allows you to view the existing routing table and update it by adding or deleting routes.

  • About route: To show / manipulate the IP routing table
  • Comes From : net-tools-X.XX
  • Configuration Files:
  • Path: /sbin/route

Examples:

1. To see the current routing table

# route

2. To show numerical addresses instead of trying to determine symbolic host names

# route -n

3. To use netstat-format for displaying the routing table

# route -e

4. To see the kernel routing cache

# route -C

5. To add the route into the system

# route add -net 192.168.200.0 netmask 255.255.255.0 gw 192.168.200.1
# route add -host 192.168.200.10 netmask 255.255.255.254 gw 192.168.200.1
# route add -host 192.168.200.10 netmask 255.255.255.254 gw 192.168.200.1 dev eth0

6. To add a default route via specified gateway

# route add default ge 192.168.200.1

7. To delete a route from the system

# route del -net 192.168.200.0 netmask 255.255.255.0 gw 192.168.200.1
# route del -host 192.168.200.10 netmask 255.255.255.0 gw 192.168.200.1

8. To reject a route

# route add -host 192.168.200.10 netmask 255.255.255.254 gw 192.168.200.1 reject
# route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.200.1 reject
# route add -net 192.168.0.0 netmask 255.255.0.0 reject

9. To see the help

# route -h
# route –help

10. To see the version

# route -V
# route –version

11. To set to verbose mode

# route -v

Related Commands: ip

Leave a Reply

Your email address will not be published. Required fields are marked *