FreeBSD route

From wikinotes

Tool to alter FreeBSD's routing table.

Documentation

man route https://www.freebsd.org/cgi/man.cgi?query=route&apropos=0&sektion=0&manpath=FreeBSD+13.0-RELEASE+and+Ports&arch=default&format=html

Concepts

The routing table determines where internet queries are made to.

  • the default route is used when no other route is matched
  • the loopback route refers to the current computer's network
  • other routes could be other networks, VPNs, etc.

Usage

Interactive

netstat -r    # show routes (both ipv4/ipv6)
netstat -4 -r # show ipv4 routes
route show default    # show 'default's route
route show 10.0.0.10  # show '10.0.0.10's route

route delete default

route add -4 default 192.168.1.1           # set default ipv4 gateway
route add -6 default 2607:f0d0:1002:51::4  # set default ipv6 addr

Persistent

# /etc/rc.conf

defaultrouter="192.168.1.1"                # ipv4 'default' route
ipv6_defaultrouter="2607:f0d0:1002:51::4"  # ipv6 'default' route

restart networking for change to take effect

service netif restart
service routing restart