linux_wiki:route_ip_traffic_and_create_static_routes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux_wiki:route_ip_traffic_and_create_static_routes [2016/10/10 15:56]
billdozor
linux_wiki:route_ip_traffic_and_create_static_routes [2019/05/25 23:50] (current)
Line 11: Line 11:
 The following virtual machines will be used: The following virtual machines will be used:
   * server1.example.com (192.168.1.150) -> Configure the routes here   * server1.example.com (192.168.1.150) -> Configure the routes here
 +
 +----
 +
 +====== Help ======
 +
 +Finding help in this section.
 +  * nmcli examples<code bash>man nmcli-examples</code>
  
 ---- ----
Line 18: Line 25:
 Ensure IP Forwarding is enabled if using router like functionality Ensure IP Forwarding is enabled if using router like functionality
 <code bash> <code bash>
-# Temp Immediate Change 
-echo 1 > /proc/sys/net/ipv4/ip_forward 
- 
 # Persistent Change that takes place upon system boot # Persistent Change that takes place upon system boot
 vim /etc/sysctl.d/overrides.conf vim /etc/sysctl.d/overrides.conf
Line 32: Line 36:
 ip route show ip route show
 </code> </code>
- 
-\\ 
-Create static route (NOT persistent) 
-<code bash> 
-ip route add 216.58.217.0/24 via 192.168.1.254 dev eth1 
-</code> 
-  * 216.58.217.0/24 -> destination network 
-  * via 192.168.1.254 -> use this gateway 
-  * dev eth1 -> use this interface 
- 
-\\ 
-Remove static route 
-<code bash> 
-ip route delete 216.58.217.0/24 via 192.168.1.254 dev eth1 
-</code> 
- 
-\\ 
  
 ===== Persistent Static Route ===== ===== Persistent Static Route =====
  
-**Option A: Use a static config file**+Creating persistent static route.
  
-Create config file +----
-<code bash> +
-vim /etc/sysconfig/static-routes+
  
-any net 216.58.217.0/24 gw 192.168.1.254 dev eth0 +==== Option AUse nmcli ====
-</code> +
-  * any net -> source from any network +
-  * 216.58.217.0/24 -> traffic to this destination +
-  * gw 192.168.1.254 -> use this gateway +
-  * **OPTIONAL**dev eth0 -> use this device+
  
-\\ +Interface specific route using nmcli. 
-Restart the network service +  * Create route<code bash>nmcli con mod enp0s3 +ipv4.routes 216.58.219.0/24</code> 
-<code bash> +  * Bring up the new connection config<code bash>nmcli con up enp0s3</code
-systemctl restart network +  * Verify route<code bash>ip route show</code>
-</code>+
  
-\\ +----
-View route +
-<code bash> +
-ip route show +
-</code>+
  
- +==== Option B: Use nmtui ====
-\\ +
-**Option B: Use nmtui**+
  
   * Open nmtui<code bash>nmtui</code>   * Open nmtui<code bash>nmtui</code>
Line 92: Line 65:
   * Scroll to the bottom and Enter on "<OK>"   * Scroll to the bottom and Enter on "<OK>"
   * Tab over to <QUIT>   * Tab over to <QUIT>
 +  * File is created at: /etc/sysconfig/network-scripts/route-<ifname>
 +  * Restart the network service<code bash>systemctl restart network</code>
 +  * View route<code bash>ip route show</code>
 +
 +----
 +
 +==== Option C: Use a static config file ====
 +
 +**Note**: This method is considered "legacy", but if it works, that is all that matters on the exam.
 +
 +  * Create config file<code bash>vim /etc/sysconfig/static-routes
 +
 +# Minimal route entry
 +any net 216.58.217.0/24 gw 192.168.1.254
 +
 +# Can also specify a device to use for the route
 +any net 216.58.217.0/24 gw 192.168.1.254 dev eth0
 +
 +# Can also specify a route metric
 +any net 216.58.217.0/24 gw 192.168.1.254 dev eth0 metric 110</code>
 +    * any -> source from any
 +    * net 216.58.217.0/24 -> traffic to this network destination
 +    * gw 192.168.1.254 -> use this gateway
 +    * **OPTIONAL**: dev eth0 -> use this device
 +
   * Restart the network service<code bash>systemctl restart network</code>   * Restart the network service<code bash>systemctl restart network</code>
   * View route<code bash>ip route show</code>   * View route<code bash>ip route show</code>
  • linux_wiki/route_ip_traffic_and_create_static_routes.1476129387.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)