To make a static route permanent under Rocky Linux 9 with rt_table, follow these steps:

  1. Create a new file in the /etc/sysconfig/network-scripts/ directory with a name that follows the pattern route--<table_number>. For example, if you want to create a static route for eth0 using table 200, you would create a file named route-eth0-200.

  2. Edit the file and add the static route using the following syntax:

    <destination_network>/ via <gateway_ip> dev

    For example, to add a static route for the network 192.168.10.0/24 via the gateway 192.168.1.1 on eth0, you would add the following line:

    192.168.10.0/24 via 192.168.1.1 dev eth0

  3. Save the file and exit.

  4. Restart the network service to apply the changes:

    systemctl restart network

  5. Verify that the static route is added to the routing table using the following command:

    ip route show table <table_number>

    For example, to show the routes in table 200, you would run:

    ip route show table 200

  6. To make sure the route persists after a system reboot, add the following line to the /etc/iproute2/rt_tables file:

    <table_number> <table_name>

    For example, to add table 200 with the name 'mytable', you would add the following line:

    200 mytable

  7. Save the file and exit.

  8. Restart the network service again to apply the changes:

    systemctl restart network

  9. Verify that the static route is still present in the routing table after a reboot by running the same command as in step 5.

How to Create Permanent Static Routes with rt_table on Rocky Linux 9

原文地址: https://www.cveoy.top/t/topic/ohLf 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录