route: route has not been found

Code:
[root@freebsd ~]# cat /etc/rc.conf.d/network

ifconfig_em0="inet 10.1.222.12 netmask 255.255.254.0"

defaultrouter="10.1.223.254"

Code:
[root@freebsd ~]# ifconfig
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
   options=85059b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,LRO,VLAN_HWFILTER,VLAN_HWTSO>
   ether 08:00:27:80:09:1c
   inet 10.1.222.12 netmask 0xfffffe00 broadcast 10.1.223.255
   nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
   media: Ethernet autoselect (1000baseT <full-duplex>)
   status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
   options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
   inet6 ::1 prefixlen 128
   inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
   inet 127.0.0.1 netmask 0xff000000
   nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
   groups: lo

Code:
[root@freebsd ~]# ping www.google.com
ping: cannot resolve www.google.com: Host name lookup failure

Code:
[root@freebsd ~]# route get default
route: route has not been found

but I execute command:
Code:
[root@freebsd ~]# route add default 10.1.223.254
add net default: gateway 10.1.223.254

Code:
[root@freebsd ~]# ping www.hotmail.com
PING a-0010.a-msedge.net (204.79.197.212): 56 data bytes
64 bytes from 204.79.197.212: icmp_seq=0 ttl=115 time=32.551 ms
64 bytes from 204.79.197.212: icmp_seq=1 ttl=115 time=30.422 ms
64 bytes from 204.79.197.212: icmp_seq=2 ttl=115 time=32.515 ms
64 bytes from 204.79.197.212: icmp_seq=3 ttl=115 time=34.521 ms

My FreeBSD version infomation:
Code:
[root@freebsd ~]# uname -a
FreeBSD freebsd 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r327236: Wed Dec 27 16:32:46 UTC 2017     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64
 
I've never used the /etc/rc.conf.d/ directory to specify config. My rc.conf is usually small enough that I don't really see the point in splitting it into separate files.

Interestingly though it seems that the files in there have to match a service name. When the "network" service starts, it will try to load /etc/rc.conf.d/network, which is the file you created. However, defaultrouter is used by the "routing" service, and so you may find you need to move that setting to /etc/rc.conf.d/routing.

Unlike things like apache (or even other base utilities like newsyslog) where you can just spread config out and it all effectively gets read as if it's one big file, the rc scripts are all individual scripts, run separately, and each script is only going to load the core config files, plus its specific /etc/rc.conf.d/service file by the look of it.
 
Back
Top