Padavan編譯技巧

修改config
cd /opt/rt-n56u/trunk

下面是修改內核配置需要做的操作:

cp -f configs/boards/<機型名稱>/kernel-3.4.x.config linux-3.4.x/.config

make -C linux-3.4.x menuconfig

menuconfig的配置方法見後文,修改完成後移動回原目錄:

mv -f linux-3.4.x/.config configs/boards/<機型名稱>/kernel-3.4.x.config

修改機型的.config配置文件

nano configs/templates/<機型名稱>.config

menuconfig的配置
以修改netfilter擴展支持和修改RAM大小爲例,在linux-3.4.x目錄下執行make menuconfig之後,彈出圖形配置頁面,這裏可以配置內核選項

menuconfig-1
menuconfig-2
在Machine selection —>DRAM Size裏可以配置RAM大小
在menuconfig中,[*]表示編譯進內核中,[M]表示編譯成模塊(.ko文件),< >表示該項目既可編譯爲模塊也可集成於內核中,[ ]表示不包含。兩次按下ESC回退到上一級菜單,按下/鍵可以搜索,例如 輸入tproxy搜索得到以下結果
menuconfig-3

menuconfig-4
搜索結果包含了搜索對象的所在位置和依賴關係,例如tproxy的第一個結果,Depends on中包含EXPERIMENTAL [=y],表明需要先開啓EXPERIMENTAL選項才能開啓此項支持。

Symbol: NETFILTER_XT_TARGET_TPROXY [=m]
Type : tristate
Prompt: “TPROXY” target support (EXPERIMENTAL)
Defined at net/netfilter/Kconfig:655
Depends on: NET [=y] && INET [=y] && NETFILTER [=y] && EXPERIMENTAL [=y] && NETFILTER_TPROXY [=m] && NETFILTER_XTABLES [=y] && NETFILTER_ADVANCED [=y]
Location:
-> Networking support (NET [=y])
-> Networking options
-> Network packet filtering framework (Netfilter) (NETFILTER [=y])
-> Core Netfilter Configuration
-> Netfilter Xtables support (required for ip_tables) (NETFILTER_XTABLES [=y])
Selects: NF_DEFRAG_IPV4 [=y] && NF_DEFRAG_IPV6 [=y]

Symbol: NETFILTER_TPROXY [=m]
Type : tristate
Prompt: Transparent proxying support (EXPERIMENTAL)
Defined at net/netfilter/Kconfig:364
Depends on: NET [=y] && INET [=y] && NETFILTER [=y] && **EXPERIMENTAL [=y] **&& IP_NF_MANGLE [=m] && NETFILTER_ADVANCED [=y]
Location:
-> Networking support (NET [=y])
-> Networking options
-> Network packet filtering framework (Netfilter) (NETFILTER [=y])
-> Core Netfilter Configuration
照此方法,可以調整wifi驅動版本以及其他內核驅動,如USB串口驅動等。
改完以後,反覆按ESC回退到主菜單,選擇exit並確認保存。

iptables的tproxy支持與napt66(ipv6 nat)
ss的udp轉發需要iptables的tproxy支持,在openwrt中可以直接安裝kmod-ipt-tproxy,在padavan中則需要從源碼入手。
首先在內核中開啓tproxy的支持,這個在menuconfig中配置,詳見上文;
接着是開啓iptables自己的支持,只需要將/opt/rt-n56u/trunk/user/iptables/iptables-1.4.16.3/extensions/disabled/中的文件全部複製到 extensions/中即可。
刷好固件後,手動在開機腳本中加一行(自定義設置-腳本-啓動後)

modprobe xt_TPROXY
Padavan的內核原生不支持ipv6 NAT,所以需要第三方的NAPT66(北郵學生開發的在ipv6下的NAT方案)
參考NAPT66文檔,在編譯內核時,只需修改trunk/linux-3.4.x/net/ipv6/ip6_output.c即可。

鏈接:https://www.jianshu.com/p/3a9ec169336e

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章