How to configure static routes: Difference between revisions
Linker3000 (talk | contribs) mNo edit summary |
(replace /etc/init.d with rc-service) |
||
(11 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
This document describes how to configure persistent static routes in Alpine Linux so | {{Obsolete|These directions need to be updated for Alpine v3.10+}} | ||
This document describes how to configure persistent static routes in Alpine Linux so the route definitions survive server reboots. | |||
This process was tested with release 2.1.4, dated 2011-01-07. | This process was tested with release 2.1.4, dated 2011-01-07. | ||
Line 5: | Line 7: | ||
First, set the staticroute service to start automatically on boot by entering the following command: | First, set the staticroute service to start automatically on boot by entering the following command: | ||
{{Cmd|rc-update add staticroute}} | |||
rc-update add staticroute | |||
You can now define your static routes in one of three ways: | You can now define your static routes in one of three ways: | ||
==Option 1: Edit /etc/conf.d/staticroute== | |||
Routes are added as a parameter value - the staticroute file has header information that explains the syntax - for example: | Routes are added as a parameter value - the staticroute file has header information that explains the syntax - for example: | ||
staticroute="net 10.200.200.0 netmask 255.255.255.0 gw 192.168.202.12" | |||
If you need to add multiple static routes, just add additional routes to the end of the text between the quotes | If you need to add multiple static routes, just add additional routes to the end of the text between the quotes with each route separated by a semicolon or a line break (press ENTER). | ||
==Option 2: Create /etc/route.conf== | |||
Use nano, vi or your favourite | Use nano, vi, or your favourite editor to create the file /etc/route.conf | ||
Add each static route on a separate line - for example: | |||
net 10.200.200.0 netmask 255.255.255.0 gw 192.168.200.12 | |||
net 10.200.200.0 netmask 255.255.255.0 gw 192.168.200.12 | net 10.200.201.0 netmask 255.255.255.0 gw 192.168.200.13 | ||
net 10.200.201.0 netmask 255.255.255.0 gw 192.168.200.13 | |||
==Option 3: Set up routes in /etc/network/interfaces== | |||
If you have static network configuration in /etc/network/interfaces, you can add a static route that gets activated when an interface is brought up: | |||
auto eth0 | |||
iface eth0 inet static | |||
address 192.168.0.1 | |||
netmask 255.255.255.0 | |||
up ip route add 10.14.0.0/16 via 192.168.0.2 | |||
up ip route add 192.168.100.0/23 via 192.168.0.3 | |||
Once editing is complete, remember to save your changes if you are running the OS in RAM (eg: booting from a USB stick) - if you are not sure how to do this, see this article: [http://5718wiki.gatorfone.com/wikka.php?wakka=KennyAralAlpine How to Boot Alpine Linux and Save Settings on a USB Stick] or [[Alpine_local_backup]] | Once editing is complete, remember to save your changes if you are running the OS in RAM (eg: booting from a USB stick) - if you are not sure how to do this, see this article: [http://5718wiki.gatorfone.com/wikka.php?wakka=KennyAralAlpine How to Boot Alpine Linux and Save Settings on a USB Stick]{{dead link}} or [[Alpine_local_backup]] | ||
You can verify your settings by restarting the server, or by issuing the following commands: | You can verify your settings by restarting the server, or by issuing the following commands: | ||
Line 35: | Line 44: | ||
To add your defined static routes manually (for testing): | To add your defined static routes manually (for testing): | ||
{{Cmd|rc-service staticroute start}} | |||
To remove your defined static routes: | To remove your defined static routes: | ||
{{Cmd|rc-service staticroute stop}} | |||
There is a 'restart' option to do an automatic stop/start, but it seems less reliable than using the two above. | There is a 'restart' option to do an automatic stop/start, but it seems less reliable than using the two above. | ||
[[Category:Networking]] | |||
Latest revision as of 10:19, 17 November 2023
This material is obsolete ... These directions need to be updated for Alpine v3.10+ (Discuss) |
This document describes how to configure persistent static routes in Alpine Linux so the route definitions survive server reboots.
This process was tested with release 2.1.4, dated 2011-01-07.
First, set the staticroute service to start automatically on boot by entering the following command:
rc-update add staticroute
You can now define your static routes in one of three ways:
Option 1: Edit /etc/conf.d/staticroute
Routes are added as a parameter value - the staticroute file has header information that explains the syntax - for example:
staticroute="net 10.200.200.0 netmask 255.255.255.0 gw 192.168.202.12"
If you need to add multiple static routes, just add additional routes to the end of the text between the quotes with each route separated by a semicolon or a line break (press ENTER).
Option 2: Create /etc/route.conf
Use nano, vi, or your favourite editor to create the file /etc/route.conf Add each static route on a separate line - for example:
net 10.200.200.0 netmask 255.255.255.0 gw 192.168.200.12 net 10.200.201.0 netmask 255.255.255.0 gw 192.168.200.13
Option 3: Set up routes in /etc/network/interfaces
If you have static network configuration in /etc/network/interfaces, you can add a static route that gets activated when an interface is brought up:
auto eth0 iface eth0 inet static address 192.168.0.1 netmask 255.255.255.0 up ip route add 10.14.0.0/16 via 192.168.0.2 up ip route add 192.168.100.0/23 via 192.168.0.3
Once editing is complete, remember to save your changes if you are running the OS in RAM (eg: booting from a USB stick) - if you are not sure how to do this, see this article: How to Boot Alpine Linux and Save Settings on a USB Stick[Dead Link] or Alpine_local_backup
You can verify your settings by restarting the server, or by issuing the following commands:
To add your defined static routes manually (for testing):
rc-service staticroute start
To remove your defined static routes:
rc-service staticroute stop
There is a 'restart' option to do an automatic stop/start, but it seems less reliable than using the two above.