Network - Static Routes, Policy Based Routing and Routing Tables
Jump to navigation
Jump to search
RHEL 8
- Create the default route for the interface
- nmcli con modify <interface> ipv4.routes "0.0.0.0/0 <gateway IP address> table=<table_id>"
- Add the subnet route
- nmcli con modify <interface> +ipv4.routes "<IP Range>/<CIDR subnet mask> <gateway IP address> table=<table_id>"
- 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>"
- 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>"
- Apply the new settings to the adapter
- nmcli dev reapply <interface>
- 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