FreeBSD Display Default Routing Table Command

Fig.01: FreeBSD Display Default Routing Table Command

Fig.01: FreeBSD Display Default Routing Table Command

To display IPv4 and IPv6 routing table on a FreeBSD operating system use the following command.

Syntax

netstat -r
netstat [options] -r

Sample outputs:

Routing tables
 
Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.1.254      UGS         0    12167 epair0
localhost          link#1             UH          0        0    lo0
192.168.1.0        link#2             U           0     2237 epair0
webserver          link#2             UHS         0        0    lo0
 
Internet6:
Destination        Gateway            Flags      Netif Expire
::                 localhost          UGRS        lo0
localhost          link#1             UH          lo0
::ffff:0.0.0.0     localhost          UGRS        lo0
fe80::             localhost          UGRS        lo0
fe80::%lo0         link#1             U           lo0
fe80::1%lo0        link#1             UHS         lo0
ff01::%lo0         localhost          U           lo0
ff02::             localhost          UGRS        lo0
ff02::%lo0         localhost          U           lo0

The -r option to the netstat command shows routing table. Normally netstat command attempts to resolve addresses and ports, and display them symbolically. To speed up and to avoid dns name resolution i.e. show network addresses and ports as numbers pass the -n option to the netstat command:
# netstat -r -n
To just show IPv4 or IPv6 routing table, enter:
### IPv4 only ###
netstar -4 -r -n
### IPv6 only ###
netstar -6 -r -n

Sample outputs:

Routing tables
 
Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.1.254      UGS         0    12169 epair0
127.0.0.1          link#1             UH          0        0    lo0
192.168.1.0/24     link#2             U           0     2315 epair0
192.168.1.30       link#2             UHS         0        0    lo0

Examples and usage: FreeBSD Set a Default Route / Gateway