freebsd 6.3 knowledge

  • static routes  (add into /etc/rc.conf)
static_routes="lan mumoffice foo"
route_lan="-net 192.168.1.0/24 192.168.1.254"


route_mumoffice="-net 10.0.0.0/8 10.30.110.5"
route_foo="-host 1.2.3.4 5.6.7.8"


note:
1.cannot write as follows:
static_routes="lan"
route_lan="-net 192.168.1.0/24 192.168.1.254"
static_routes="mumoffice"
route_mumoffice="-net 10.0.0.0/8 10.30.110.5"

otherwise, only mumoffice static routes will be added.

2. manually add static routing
route add -net
10.0.0.0/8 10.30.110.5
route add -host 1.2.3.4 4.5.6.7


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
10.10.10.0/24 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 1.2.3.4 netmask 255.255.255.0"
for alias on fxp0, put:

ifconfig_em0="inet 10.20.110.2 netmask 255.255.255.192 "
ifconfig_em0_alias0="inet 10.20.1.226 netmask 255.255.255.0"
ifconfig_em0_alias1="inet 10.20.1.227 netmask 255.255.255.0"
ifconfig_em0_alias2="inet 10.20.1.228 netmask 255.255.255.0"
manual way:
add alias: ifconfig em0 inet alias 10.20.1.226 netmask 255.255.255.0
remove alias: ifconfig em0 inet -alias 10.20.1.226 netmask 255.255.255.0

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
gateway_enable="yes"
note:
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
cp GENERIC /root/MYKERNEL
ln -sf /root/MYKERNEL
vi MYKERNEL to add the following:

# enable IPSEC
options IPSEC
options IPSEC_ESP
options IPSEC_DEBUG

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

cd /usr/src
make buildkernel KERNCONF=MYKERNEL
make installkernel KERNCONF=MYKERNEL
reboot
  • put in /etc/rc.conf for enabling pf
pf_enable="YES"
pf_flags=""
pf_rules="/etc/pf.conf"
pflog_logfile="/var/log/pflog"
pflog_flags=""

  • 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 10.0.202.80 netmask 255.255.255.0

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