Linux Routing Configuration: Difference between revisions
No edit summary |
|||
(18 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
* [[Routing]] | * [[Routing]] | ||
=Listing Routes= | |||
<pre> | |||
ip route | |||
</pre> | |||
=Adding a Static Route via a Specific Interface= | |||
<font color=red> | |||
TODO | |||
Route changes operated with ip are not saved. See [[#Routing_Configuration_that_Survives_Reboot|Routing configuration that survives reboot]]. | |||
</font> | |||
<pre> | |||
ip route add ... | |||
</pre> | |||
=Adding Multicast Routing to a Specific Network Interface= | =Adding Multicast Routing to a Specific Network Interface= | ||
Line 19: | Line 37: | ||
<pre> | <pre> | ||
route add 224.0.0.0 netmask 240.0.0.0 dev <device-name> | route add 224.0.0.0 netmask 240.0.0.0 dev <device-name> | ||
</pre> | |||
More information: {{External|http://lartc.org/howto/lartc.multicast.html}} | |||
The equivalent Mac command: [[Mac_Routing_Configuration#Add_a_Static_Multicast_Route|Adding a Static Route on Mac]]. | |||
==Deleting a Route== | |||
<font color=red> | |||
TODO | |||
Route changes operated with ip are not saved. See [[#Routing_Configuration_that_Survives_Reboot|Routing configuration that survives reboot]]. | |||
</font> | |||
<pre> | |||
ip route delete ... | |||
</pre> | </pre> | ||
=Routing Configuration that Survives Reboot= | =Routing Configuration that Survives Reboot= | ||
Add the routing configuration to <tt>/etc/sysconfig/network-scripts/route-<device-name></tt>: | Add the static routing configuration to <tt>/etc/sysconfig/network-scripts/route-<device-name></tt>: | ||
<pre> | <pre> | ||
... | |||
# default multicast route | # default multicast route | ||
224.0.0.0 | 224.0.0.0/4 via 172.20.1.12 | ||
</pre> | |||
where "172.20.1.12" is the IP address of the interface we want to route the multicast traffic over. It is sufficient to add static routing configuration only to the file route-* corresponding to the interface that will service the route. | |||
After reboot, we'll get this: | |||
<pre> | |||
[eap@app01 ~]$ ip route | |||
... | |||
224.0.0.0/4 via 172.20.1.12 dev eth1 | |||
</pre> | </pre> | ||
=Default Route= | |||
An interface is designate as serving the default route, and the routing table is configured accordingly at boot, if the corresponding ifcfg-* contains: | |||
DEFROUTE=yes | |||
If multiple network interfaces are configured, only one can service the default route. | |||
More on DEFROUTE in: {{Internal|Linux_7_Configuring_a_Network_Interface#DEFROUTE|Configuring a Network Interface}} |
Latest revision as of 05:43, 28 November 2017
External
Internal
Listing Routes
ip route
Adding a Static Route via a Specific Interface
TODO
Route changes operated with ip are not saved. See Routing configuration that survives reboot.
ip route add ...
Adding Multicast Routing to a Specific Network Interface
ip route add 224.0.0.0/4 dev <device-name>
More details about ip can be found here
The equivalent "route" command is:
route add 224.0.0.0 netmask 240.0.0.0 dev <device-name>
More information:
The equivalent Mac command: Adding a Static Route on Mac.
Deleting a Route
TODO
Route changes operated with ip are not saved. See Routing configuration that survives reboot.
ip route delete ...
Routing Configuration that Survives Reboot
Add the static routing configuration to /etc/sysconfig/network-scripts/route-<device-name>:
... # default multicast route 224.0.0.0/4 via 172.20.1.12
where "172.20.1.12" is the IP address of the interface we want to route the multicast traffic over. It is sufficient to add static routing configuration only to the file route-* corresponding to the interface that will service the route.
After reboot, we'll get this:
[eap@app01 ~]$ ip route ... 224.0.0.0/4 via 172.20.1.12 dev eth1
Default Route
An interface is designate as serving the default route, and the routing table is configured accordingly at boot, if the corresponding ifcfg-* contains:
DEFROUTE=yes
If multiple network interfaces are configured, only one can service the default route.
More on DEFROUTE in: