How to Create Permanent Static Routes with rt_table on Rocky Linux 9
To make a static route permanent under Rocky Linux 9 with rt_table, follow these steps:
-
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. -
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
-
Save the file and exit.
-
Restart the network service to apply the changes:
systemctl restart network
-
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
-
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
-
Save the file and exit.
-
Restart the network service again to apply the changes:
systemctl restart network
-
Verify that the static route is still present in the routing table after a reboot by running the same command as in step 5.
原文地址: https://www.cveoy.top/t/topic/ohLf 著作权归作者所有。请勿转载和采集!