What is the function of the route command in Linux?

The route command in Linux is used to view and configure the IP routing table. It can display information about the current system’s routing table, including network destination, gateway, subnet mask, interface, and can also add, delete, or modify routing table entries.

Specifically, the route command can be used for the following functions:

  1. Display the current system’s routing table information: route or route -n.
  2. Add a static route: route add -net destination network netmask gateway.
  3. Delete a static route by entering the command: route del -net destination_network subnet_mask gateway
  4. Change a static route: route change -net destination network subnet mask gateway
  5. Set up the default gateway: route add default gw gateway.
  6. Delete all routing table entries: route flush

The route command is used to manage the system’s routing table, ensuring that data packets are forwarded correctly to the destination network, facilitating network communication.

bannerAds