Monthly Archives: 9月 2019

x86 openwrt 编译

# 大多数时候已经安装了
pacman -S zlib libtool findutils gawk gengetopt grep gettext unzip zip rsync subversion which
# 下面的是编译需要安装的
pacman -S binutils bzip2 gcc diffutils patch quilt flex make cmake automake autoconf automake bison screen asciidoc python perl

下载21.02.1稳定版[最新]

git clone -b v21.02.1 git://git.openwrt.org/openwrt/openwrt.git

或:

wget https://github.com/openwrt/openwrt/archive/refs/tags/v21.02.1.tar.gz

解压缩
tar xzvf v21.02.1.tar.gz
cd openwrt-21.02.1

改善和增加部分功能(Lean的源里面有很多好东西)
https://github.com/coolsnowwolf/lede
下载后,将package/lean 拷贝到openwrt的package目录下即可

添加x86目录权限
chmod -R 777 openwrt-21.02.1
chown -R zeno.users openwrt-21.02.1

su zeno
cd openwrt-21.02.1/

更新索引

./scripts/feeds update -a
./scripts/feeds install -a

修改默认语言
nano -w feeds/luci/modules/luci-base/root/etc/config/luci

config core main
         option lang zh_cn
         option mediaurlbase /luci-static/bootstrap
         option resourcebase /luci-static/resources
config extern flash_keep  #如果没有,增加下列保留的配置项
         option ocserv   "/etc/ocserv/"
         option samba    "/etc/samba/smbpasswd"

修改网络接口配置
nano -w package/base-files/files/bin/config_generate

    case "$protocol" in
            static)
                    local ipad
                    case "$1" in
                            lan) ipad=${ipaddr:-"172.16.1.1"} ;;
                            *) ipad=${ipaddr:-"172.16.$((addr_offset++)).1"} ;;
                    esac

                    netm=${netmask:-"255.255.255.0"}

                    uci -q batch <<-EOF
                            set network.$1.proto='static'
                            set network.$1.ipaddr='$ipad'
                            set network.$1.netmask='$netm'
                    EOF
                    [ -e /proc/sys/net/ipv6 ] && uci set network.$1.ip6assign='60'
            ;;

修改默认主机名
nano -w package/base-files/files/bin/config_generate
时区和LED设置也在这个文件中
推荐

            set system.@system[-1].hostname='horee'             
            set system.@system[-1].timezone='CST-8'
            set system.@system[-1].zonename='Asia/Shanghai'
            #这句话要加上,不然还是UTC

修改无线配置
nano -w package/kernel/mac80211/files/lib/wifi/mac80211.sh
set wireless.radio${devidx}.disabled=1改成0,默认开启wifi。
修改默认SSD:

            uci -q batch <<-EOF
                    set wireless.radio${devidx}=wifi-device                  
                    set wireless.radio${devidx}.type=mac80211
                    set wireless.radio${devidx}.channel=${channel}
                    set wireless.radio${devidx}.hwmode=11${mode_band}
                    ${dev_id}
                    ${ht_capab}
                    set wireless.radio${devidx}.disabled=0          

                    set wireless.default_radio${devidx}=wifi-iface
                    set wireless.default_radio${devidx}.device=radio${devidx}
                    set wireless.default_radio${devidx}.network=lan
                    set wireless.default_radio${devidx}.mode=ap             
                    set wireless.default_radio${devidx}.ssid=heuristic 
                    set wireless.default_radio${devidx}.encryption=none

默认情况下root是没有密码的,需设定密码才能开启ssh。
修改shadow文件,位于package/base-files/files/etc/shadow
root:$1$2nX0sqkM$XILd1/grLi/99Lgvp6Clz0:16922:0:99999:7:::
samba:HWp9sw69nPASU:18188:0:99999:7:::
密码经过加密,将密码修改成admin, samba用户是用户共享磁盘的,密码是admin123
增加用户
修改passwd文件,位于package/base-files/files/etc/passwd
samba:x:6801:6801::/home/samba:/bin/false


密码经过加密,将密码修改成admin。
增加用户
修改shadow文件,位于package/base-files/files/etc/password
samba:x:6801:6801::/home/samba:/bin/false

添加第三方源码ipk

把第三方ipk源码的package包放进source/feeds/packages目录
把第三方ipk源码的luci包放进source/feeds/luci/applications目录

部分默认参数的修改
增加代理ARP
nano -w package/base-files/files/etc/sysctl.d/10-default.conf

# Enables Proxy ARP on all interfaces
net.ipv4.conf.all.proxy_arp = 1

# Enables Proxy ARP on a specific interface (Replace M-!M-0interfacenameM-!M-1
# with your interface, eg.eth0, eth0.100, wlan0, etc.)
#net.ipv4.conf.eth0.proxy_arp = 1

增加一些别名到shell
nano -w package/base-files/files/etc/profile

alias ls='ls --color=auto'
alias ll='ls -ls --color=auto'
alias dir='dir --color=auto'
alias halt='halt -p'

修改lxc指定的死域名

if url and url:match("images.linuxcontainers.org") then

修改为

if url then

增加指向到自己的域名
nano -w package/base-files/files/etc/hosts

172.16.1.1 r.gating.site

写段脚本来自动更改lan口的映射关系

# delete the dns line 
sed -e '/r\.gating\.site/d' /etc/hosts > /etc/hosts2
mv /etc/hosts2 /etc/hosts

# get the ip address
ipaddr=`ip -f inet addr | grep 'global br-lan' | awk '{print $2}' | awk -F/ '{print $1}'`

echo "${ipaddr} r.gating.site">>/etc/hosts

增加docker的界面

cd package/lean
git clone https://github.com/lisaac/luci-app-docker.git

最后执行make menuconfig

Global build settings
[*] Compile with full language support

进入配置菜单

Target System (x86)
Subtarget (x86_64)
Target Profile (Generic)

Target Images —>

(Horee) Title for the menu entry in GRUB | |
[*] Build VMware image files (VMDK)
(512) Root filesystem partition size (in MB)

Image configuration —>
[*] Preinit configuration options —>
(172.16.1.1) IP address for preinit network messages
(255.255.255.0) Netmask for preinit network messages
(172.16.1.255) Broadcast address for preinit network messages

— Version configuration options
(Horee) Release distribution
(1.0.0) Release version number
(Zebra) Release version code
(http://dl.magicwall.org:8/openwrt/18.06.4) Release repository
(http://www.itseeker.net) Release Homepage
(ZOTAC) Manufacturer name
(http://www.zotac.com) Manufacturer URL
(ZBOX) Product name
(CI325) Hardware revision

Global build settings —>
Kernel build options —>
[*] Enable kernel cgroups
[*] Enable kernel namespaces
[*] Enable seccomp support

先选择LUCI,会自动选择依赖包
LuCI —> Collections —>
<*> luci
LuCI —> Modules —> Translations
<*> English
<*> Chinese
LuCI —> Applications —>
<*> luci-app-adblock
<*> luci-app-commands
<*> luci-app-cshark
<*> luci-app-ddns
<*> luci-app-dockerman
<*> luci-app-frpc
<*> luci-app-frps
<*> luci-app-hd-idle
<*> luci-app-lxc
<*> luci-app-ntpc
<*> luci-app-ocserv
<*> luci-app-p910nd
<*> luci-app-qos
<*> luci-app-samba4
<*> luci-app-statistics
<*> luci-app-transmission
<*> luci-app-upnp
<*> luci-app-usb-printer
<*> luci-app-vlmcsd
<*> luci-app-wifischedule
<*> luci-app-wol

LuCI —> Protocols
<*> luci-proto-openconnect
<*> luci-proto-vpnc. 千万不能有,否则依赖libgpg-error,无法编译

Base syatem
–> <*> blockd
–> <*> dnsmasq
–> <*> wireless-tools

Administration
–> <*> htop

Firmware —>
<*> intel-microcode
<*> iwlwifi-firmware-iwl3160
<*> iwlwifi-firmware-iwl3168
<*> iwlwifi-firmware-iwl5000
<*> iwlwifi-firmware-iwl5150
<*> iwlwifi-firmware-iwl7260
<*> iwlwifi-firmware-iwl7265
<*> iwlwifi-firmware-iwl7265d
<*> iwlwifi-firmware-iwl8260c
<*> iwlwifi-firmware-iwl8265
<*> iwlwifi-firmware-iwl9000
<*> iwlwifi-firmware-iwl9260

Kernel modules
–>Filesystems
-*- kmod-fs-cifs
<*> kmod-fs-ext4
<*> kmod-fs-ntfs
–>Native Language Support
—> kmod-nls-utf8
–>Input modules
–>Network Devices
<*> kmod-e1000e
<*> kmod-igb
<*> kmod-igbvf
<*> kmod-vmxnet3
–>Network Support
<*> kmod-pptp
<*> kmod-veth
–>USB Support —>
<*> kmod-usb-hid
<*> kmod-usb-storage
<*> kmod-usb-storage-extras
<*> kmod-usb-printer
<*> kmod-usb2
<*> kmod-usb3
Virtualization —>
<*> kmod-kvm-intel
–>Wireless Drivers 无线网卡驱动
Libraries —>
<*> libintl
<*> libpam
Network
–>File Transfer
<*> curl
<*> rsync
<*> wget-ssl
–>SSH
<*> openssh-sftp-client
<*> openssh-sftp-server
–>VPN
<*> ocserv
<*> openconnect
SSL library
(X) OpenSSL
————————————–
<*> 6rd
<*> cifsmount
<*> ethtool
<*> ipset
<*> ipset-dns
<*> samba4-admin
<*> samba4-client
*- samba4-server
<*> tcpdump

Utilities —>
Compression->
<*> gzip
<*> unrar
<*> unzip
<*> xz-utils
Disc ->
<*> blkid
<*> cfdisk
<*> hdparm
Editors —>
<*> nano
Encryption —>
<*> gnupg
<*> gnutls-utils
Virtualization —>
<*> qemu-bridge-helper
<*> qemu-firmware-efi
<*> qemu-firmware-seabios
<*> qemu-firmware-seavgabios
<*> qemu-img
<*> qemu-nbdV
<*> qemu-x86_64-softmmu
<*> virtio-console-helper

最后回到界面选择 EXIT 点保存回到命令提示符界面,

修改一次BUG, 否则会导致:
configure: error: Package requirements (protobuf >= 2.6.0) were not met:
需要把feeds/packages/libs/protobuf-c/Makefile的PKG_BUILD_DEPENDS:=protobuf-c/host改为PKG_BUILD_DEPENDS:=protobuf/host

SSR-PLLUS被隐藏了,编译好后装好机,输入以下命令即可出来
echo 0xDEADBEEF > /etc/config/google_fu_mode

输入nohup make -j8 download V=s & 可以下载dl包
输入nohup make -j1 V=sc &就可以正常编译了(耗时70分钟)
查看详细日志:nohup nohup.out

编译完成后清除之前的编译作业。(使用这个命令前,记得把编译好的固件备份出来,不然会被删除掉,切记)
make clean
恢复默认编译环境
make defconfig

编译单个模块

make package/qos/clean (清除某个模块)
make package/qos/compile (#单独编译某模块 #V=99表示输出详细的debug信息)
make package/qos/install