welw | About_me Blog WebAssembly

Add route to 172.30.x.x via 192.168.10.100 on freebsd

To add a route to 172.30.x.x via 192.168.10.100 on FreeBSD, you can use the route command. Here is how:

sh sudo route add 172.30.0.0/16 192.168.10.100

This adds a route to the 172.30.0.0/16 subnet via the gateway 192.168.10.100.

If you want this route to persist after reboots, you can add it to the /etc/rc.conf file or the /etc/rc.conf.d/routing file:

  1. Edit /etc/rc.conf or /etc/rc.conf.d/routing:

    • You can use an editor like vi or nano. For example: sh nano /etc/rc.conf.d/routing
  2. Add the route:

    • Add the following line: sh static_routes="my_route" route_my_route="172.30.0.0/16 192.168.10.100"
  3. Save and exit:

  4. Activate the route immediately:

    • Run the command: sh sudo service routing start

This ensures that the route is added every time the system boots.