freebsd 6.3 knowledge

  • static routes  (add into /etc/rc.conf)
static_routes="lan mumoffice foo"


1.cannot write as follows:

otherwise, only mumoffice static routes will be added.

2. manually add static routing
route add -net
route add -host

note: for RHEL 5, static routing:

To set static routes, use the /etc/sysconfig/network-scripts/route-<interface> files which read at network service initialization time. For example to add static route for eth0, create a file /etc/sysconfig/network-scripts/route-eth0 and add the routes as explained below.

There are two possible formats for this file.  The first is with ip command arguments and the second is with  network/netmask directives.

Format 1:

For ip commands, the ifup-route script supplies ip route add and the contents of the file are all parameters necessary to set up the route. For example, to set up a default route, the file would contain the following:

default via X.X.X.X dev bond0 via X.X.X.X dev bond0

  • mounting usb thumb drive
mkdir /mnt/usb
mount -t msdos /dev/da0s1 /mnt/usb
  • ifconfig in /etc/rc.conf
ifconfig_fxp0="inet netmask"
for alias on fxp0, put:

ifconfig_em0="inet netmask "
ifconfig_em0_alias0="inet netmask"
ifconfig_em0_alias1="inet netmask"
ifconfig_em0_alias2="inet netmask"
manual way:
add alias: ifconfig em0 inet alias netmask
remove alias: ifconfig em0 inet -alias netmask

note: enabling ip alias is normally required for doing port forwarding (rdr)

  • gateway enable
in order to automatic enable a freebsd box as gateway machine which normally has 2 NICs and it will do ip forwarding, put the following into /etc/rc.conf
for manually enabling gateway: run command : sysctl -w net.inet.ip.forwarding=1

  • DNS and ssh slowness response issue
vi /etc/nssswitch.conf to take out 'dns' from hosts line
  • add user 'jephe' to allow to use 'su -'
vi /etc/group to add user 'jephe' to 'wheel' group
1. we assume /dev/da0 is the first hard disk which has OS installed , we need to add /dev/da1 which is the second hard disk to the raid1 mirror system
2. run commands below
# sysctl kern.geom.debugflags=16
#gmirror label -v -b round-robin gm0 /dev/da0
#echo geom_mirror_load=YES >> /boot/loader.conf
# vi /etc/fstab (to change all /dev/da0 to /dev/mirror/gm0, :%s#da0#mirror\/gm0#g)

bsd# more /etc/fstab
/dev/mirror/gm0s2b none swap sw 0 0
/dev/mirror/gm0s1a / ufs rw 1 1
/dev/mirror/gm0s4d /usr ufs rw 2 2
# reboot
after reboot, you can use command 'gmirror status' or 'gmirror list' to check the raid1 status
for adding the second hard disk /dev/da1 to raid array, run
# gmirror forget gm0 (optional, depends)
# gmirror insert gm0 /dev/da1

Note: testing raid1
after rebuilding finished (gmirror status to check), you can actually shutdown da0, just use da1 to boot up.
I have tested okay.

  • compile kernel to enable ipsec and carp
cd /usr/src/sys/i386/conf
ln -sf /root/MYKERNEL
vi MYKERNEL to add the following:

# enable IPSEC
options IPSEC
options IPSEC_ESP

# or enable CARP
device pf
device pflog
device pfsync
device carp

cd /usr/src
make buildkernel KERNCONF=MYKERNEL
make installkernel KERNCONF=MYKERNEL
  • put in /etc/rc.conf for enabling pf

  • mounting cdrom and usb
mount /cdrom ( see /etc/fstab)
insert usb thumb drive
mkdir /mnt/usb
mount -t msdos /dev/da0s1 /mnt/usb

  • error message '/dev/pf no such file or device'
solution: add pf_load="YES" to /boot/loader.conf, then reboot or run 'kldload pf' with reboot

  • add alias
ifconfig bge0 inet alias netmask

to remove alias
ifconfig bge0 inet -alias netmask
to review alias
# ifconfig (without parameters)