Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Freebsd from installation to desired state configuration

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Preface

The author has been working for many years and has heard of the name of bsd series freebsd, which belongs to the branch of unix. Today, I finally made up my mind to play, and found that it is still different from the details of linux. Record the common configuration here for later reference.

2. Installation of the system

System download:

Https://www.freebsd.org/zh_CN/where.html

Installation of the system:

Https://www.freebsd.org/doc/zh_CN.UTF-8/books/handbook/bsdinstall.html

Note: please install FreeBSD 10.2-RELEASE

3. Service management

3.1. View currently installed services

Ls / etc/rc.d/

3.2. Options for services

/ etc/rc.d/moused

The explicit expressions are as follows:

Usage: / etc/rc.d/moused [fast | force | one | quiet] (start | stop | restart | rcvar | enabled | status | poll)

3.3. Service operation

/ etc/rc.d/moused start # moused service startup / etc/rc.d/moused restart # moused service restart / etc/rc.d/moused status # moused service status / etc/rc.d/moused stop # moused service shutdown

3.4. Service self-startup

Vi / etc/rc.conf

The configuration is as follows:

Moused_enable= "YES" # moused service boot by default moused_enable= "NO" # moused service does not start by default

3.5. List of common services

/ etc/rc.d/netif # Network Interface Service / etc/rc.d/routing # routing Service

Note: for more information on how to use it, please see the operation of 3.3 service.

4. Configuration of the network

4.1, wired network

4.1.1. Dhcp automatically acquires IP

Vi / etc/rc.conf

The configuration is as follows:

Ifconfig_re0= "DHCP"

Re0 is the name of the specified network card

4.1.2. Static IP configuration

Vi / etc/rc.conf

The detailed configuration is as follows

Ifconfig_re0= "inet 10.168.0.8 netmask 255.255.255.0" # IP address configuration ifconfig_re0_alias0= "inet 10.168.0.9 netmask 255.255.255.0" # multiple IP address configuration (optional) defaultrouter= "10.168.0.1" # Gateway configuration

Restart the service

/ etc/rc.d/netif restart # restart network interface service to make IP configuration effective / etc/rc.d/routing restart # restart network interface service to make routing configuration effective

4.2. Dns configuration

Vi / etc/resolv.conf

The detailed configuration is as follows:

Nameserver 202.96.128.86nameserver 202.96.128.166nameserver 8.8.8.8nameserver 8.8.4.4

4.3. Wireless network

4.3.1. Extract windows driver

1) go to the one-click studio to download a pe production tool for USB disk, website: http://www.upanok.com/

2) Boot from the PE system of the USB disk

3) the mode of starting PE network

4) use the driver extraction tool included in PE to extract the driver file of the wireless network card (* .inf, * .sys)

Note: the above applies to 32-bit operating systems

4.3.2, make kernel driver

1) the extracted drive files are copied to the system on USB disk

Mount-t msdos / dev/da1s1 / mnt/ # Mount the USB disk

Note: uninstall method

Unmount / mnt # Uninstall USB disk

2) generate kernel drivers

Cd / mntndisgen x.inf x.sys

Note: enter all the way above and you can see the generated x_sys.ko file

4.3.3. Load kernel driver

1) load manually

Kldload. / x_sys.koifconfig

Wireless network cards can be found:

Ndis0: flags=8843 metric 0 mtu 2290 ether 00:25:56:77:85:b6 nd6 options=29 media: IEEE 802.11 Wireless Ethernet autoselect mode 11g status: associated

2) automatically load the kernel

Cp. / x_sys.ko / boot/modules/echo "kldload / boot/modules/x_sys.ko" > > / etc/rc.local

4.3.4. Load other kernels required for wireless

1) Kernel loading

If_ath_load= "YES" wlan_scan_ap_load= "YES" wlan_scan_sta_load= "YES" wlan_wep_load= "YES" wlan_ccmp_load= "YES" wlan_tkip_load= "YES"

2) restart the system

Reboot

4.3.5. Create Wirel

1) manually create Wirel

Ifconfig wlan0 create wlandev ndis0

2) automatically create wireless

Echo "ifconfig wlan0 create wlandev ndis0" > > / etc/rc.local

4.3.6. Create a wireless authentication

1) configure authentication

Vi / etc/wpa_supplicant.conf

Add the following configuration:

Network= {ssid= "ssid-name" psk= "password"}

2) restart network services

/ etc/rc.d/netif restart

4.3.7. Inspection

Ifconfig

The display is as follows:

Wlan0: flags=8843 metric 0 mtu 1500 ether 00:25:56:77:85:b6 inet 10.168.0.77 netmask 0xffffff00 broadcast 10.168.0.255 nd6 options=29 media: IEEE 802.11 Wireless Ethernet autoselect mode 11g status: associated ssid will-work channel 6 (2437 MHz 11g) bssid 12:18:d6:8f:b7:f8 country US authmode WPA2/802.11i privacy OFF powersavemode CAM powersavesleep 100 txpower 0 bmiss 7 mcastrate 6 Mgmtrate 6 scanvalid 60 protmode CTS roaming MANUAL bintval 0

4.3.8. Graphics wifi management

Pkg install wifimgr

5. Software package installation

5.1. Common instructions

Pkg search vim # search vimpkg install vim # install vimpkg remove vim # Delete vim

5.2. Configuration file

5.2.1 official pkg source

Cat / etc/pkg/FreeBSD.conf

The display is as follows:

FreeBSD: {url: "pkg+ http://pkg.FreeBSD.org/${ABI}/quarterly", mirror_type:" srv ", signature_type:" fingerprints ", fingerprints:" / usr/share/keys/pkg ", enabled: yes}

5.2.2 Local Custom pkg Source

Mkdir-p / usr/local/etc/pkg/reposvi / usr/local/etc/pkg/repos/FreeBSD_install_http.conf

The definition is as follows:

FreeBSD_install_http: {url: "http://192.168.0.200/FreeBSD-11.0-RELEASE-amd64/packages/${ABI}", mirror_type:" none ", enabled: yes} FreeBSD: {enabled: no}

6. Ssh service configuration

6.1. Add users

Adduser

After execution, fill in the user's information according to the wizard.

6.2. Users join the group

Vim / etc/group

Wheel:*:0:root,user1

Because root forbids ssh login by default, the ordinary user user1 is added to the wheel group (you can use the su directive)

6.3. switch to root user

Su-

6.4. Start the service and

/ etc/rc.d/sshd start

6.5. Set the service to start itself.

Vim / etc/rc.conf

The configuration is as follows

Sshd_enable= "YES"

7. Command line usage

Since keys such as [end] cannot be used, the following shortcuts are provided for users to use:

[ctrl] + a # reach the beginning of the line [ctrl] + e # reach the end of the line [ctrl] + u # clear to the beginning of the line [ctrl] + k # clear [ctrl] + w # clear a word to the beginning of the line

8. Desktop environment installation

8.1. Installation of binary packages

Pkg install xorg gnome3

8.2. Configuration

8.2.1. Configure / proc mount (required for GNOME operation)

Vim / etc/fstab

The configuration is as follows:

Proc / proc procfs rw 0 0

After saving and exiting

Mount-a

8.2.2, configure the startup file

Echo "/ usr/local/bin/gnome-session" > ~ / .xinitrc

8.2.3. Boot the desktop environment

1) configure the service

Vim / etc/rc.conf

The configuration is as follows:

Gnome_enable= "YES"

Or write like this.

Gdm_enable= "YES" dbus_enable= "YES"

2) restart and test

Reboot

8.2.4. Start the desktop environment manually

1) configure the service

Vim / etc/rc.conf

The configuration is as follows:

# gnome_enable= "YES" # gdm_enable= "YES" dbus_enable= "YES"

2) restart and test

Rebootstartx

8.2.5. Chinese input method

Pkg install ibus zh-ibus-pinyin

After installation, select the following menu to add input method:

Activities-> Setting-> Region & Language-> Input Sources-> Click [+]-> Chinese (China)-> Chinese (Pinyin)-> Add

8.2.6, office software

Pkg install libreoffice xpdf xpdfopen zh-xpdf-zhfont gimp

8.2.7 installation of the browser

1) install firefox-esr browser

Pkg install-y firefox-esr

Flash installation

Pkg install nspluginwrappercd / usr/ports/www/linux-f10-flashplugin11make installmake cleannspluginwrapper-v-a-inspluginwrapper-v-a-upright color v output details #-an automatic probe available plug-ins #-I install plug-ins #-u update plug-ins

2) install chrome browser

Pkg install-y chromiumsysctl kern.ipc.shm_allow_removed=1echo "kern.ipc.shm_allow_removed=1" > > / etc/sysctl.conf

Flash installation

Cd ~ wget https://fpdownload.adobe.com/pub/flashplayer/pdc/25.0.0.127/flash_player_ppapi_linux.x86_64.tar.gz#wget https://fpdownload.adobe.com/pub/flashplayer/pdc/25.0.0.127/flash_player_ppapi_linux.i386.tar.gztar-xf flash_player_ppapi_linux.x86_64.tar.gz#tar-xf flash_player_ppapi_linux.i386.tar.gzmkdir-p / usr/local / share/chromium/RepperFlashcp libpepflashplayer.so manifest.json / usr/local/share/chromium/RepperFlashchmod-R 755 / usr/local/share/chromium/RepperFlashvim / usr/local/share/applications/chromium-browser.desktopExec=chome% U-- ppapi-flash-path=/usr/local/share/chromium/RepperFlash/libpepflashplayer.so

8.2.8, remote control

Pkg install tigervnc

9. Rescue mode

9.1. What is the Rescue Model

Rescue mode is used for system rescue, for example, when there is an error in modifying kernel parameters, so that the system can not boot normally, we need to boot to the normal operating system with the help of CD-ROM, and switch to the working mode that can repair the original system environment.

9.2. Operation steps

1) prepare a CD and boot from the CD-ROM drive

2) Select "boot single user" mode to start

3) press enter when prompted as follows

Enter full pathname of shell or RETURN for / bin/sh:

4) Mount the file system

Mount / dev/ad0p2 / mnt # Mount the system partition to / mntls / mnt # confirm the system partition

5) switch root to file system

Chroot / mnt

6) do the reverse operation to repair the wrong configuration file

7) reboot into the system

Reboot

10. Error handling

10.1. Error prompt 1

Pkg: cached package xxx: size mismatch, cannot continue

Processing commands:

Pkg update-f

11. Set time zone and correction time

Cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtimentpdate 0.pool.ntp.org

References:

System download:

Https://www.freebsd.org/zh_CN/where.html

U disk production

Http://www.freebsd.org/doc/zh_TW/books/handbook/book.html#bsdinstall-pre

Installation of the system:

Https://www.freebsd.org/doc/zh_CN.UTF-8/books/handbook/bsdinstall.html

Use help:

Https://www.freebsd.org/doc/zh_CN.UTF-8/books/handbook/

Installation of flash:

Https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/desktop-browsers.html

Wireless driver solution:

Http://www.kuqin.com/docs/freebsd-handbook/config-network-setup.html?UpdatedPage=aGlqYWNr

Upgrade method:

Https://www.freebsd.org/doc/zh_CN/books/handbook/updating-upgrading-freebsdupdate.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report