Network - Static Routes, Policy Based Routing and Routing Tables

From UNIX Systems Administration
Jump to navigation Jump to search

RHEL 8

  1. Create the default route for the interface
    nmcli con modify <interface> ipv4.routes "0.0.0.0/0 <gateway IP address> table=<table_id>"
  2. Add the subnet route
    nmcli con modify <interface> +ipv4.routes "<IP Range>/<CIDR subnet mask> <gateway IP address> table=<table_id>"
  3. Create the routing rules from the IP to lookup the <table_id>
    nmcli con modify <interface> ipv4.routing-rules "priority <number> from <interface IP address>/32 table <table_id>"
  4. Add the iif rule to route all traffic coming in/out through the <interface> using <table_id>
    nmcli con modify <interface> +ipv4.routing-rules "priority <number + 1> iif <interface> table <table_id>"
  5. Apply the new settings to the adapter
    nmcli dev reapply <interface>
  6. Example
    nmcli con modify ens160 ipv4.routes "0.0.0.0/0 192.168.174.2 table=174"
    nmcli con modify ens160 +ipv4.routes "192.168.174.0/24 192.168.174.2 table=174"
    nmcli con modify ens160 ipv4.routing-rules "priority 32764 from 192.168.174.133/32 table 174"
    nmcli con modify ens160 +ipv4.routing-rules "priority 32765 iif ens160 table 174"
    nmcli dev reapply ens160


Further Reading

  1. Policy Based Routing with NetworkManager