本文分享自天翼云開發者社區《Dummynet簡單部署》,作者:凸凹
部署流程
^準備內核版本
^參看系統內核版本
uname -r
我們需要將ipfw編譯成內核模塊,請確保ipfw用到的內核原始碼版本同你linux系統運行內核版本一致,
^編譯dummynet
https://github.com/FS1360472174/dummynet.git 下載包
^上傳解壓

^進入操作目錄
cd dummynet-master

^編譯
make KERNELPATH=/usr/src/kernels/3.10.0-957.el7.x86_64/

^加載ipfw 模塊
cd kipfw-mod
insmod ipfw_mod.ko

cd ../ipfw
cp ipfw /sbin
chmod 700 /sbin/ipfw

^驗證ipfw
ipfw add pipe 2 in proto tcp
可選擇地,將ipfw 設定為boot啟動
cp /root/dummynet-master/kipfw-mod/ipfw_mod.ko /lib/modules/3.10.0-957.el7.x86_64/kernel/net/netfilter
depmod
sh -c 'echo modprobe ipfw_mod >> /etc/rc.modules'
chmod +x /etc/rc.modules
^附錄
問題分析
1.insmod: ERROR: could not insert module ipfw_mod.ko: Invalid module format
解決:
modinfo ipfw_mod.ko 看下vermagic版本是不是uname -r的版本,
然后重新編譯ipfw 模塊
make KERNELPATH=/usr/src/kernels/3.10.0-957.el7.x86_64
2.ipfw: getsockopt(IP_FW_ADD): Protocol not available
解決:
ipfw 模塊未加載到內核
可以lsmod |grep ipfw看下
需要重述上述步驟,將ipfw編譯進內核模塊
3.編譯模塊時報錯
類似于ipfw2_mod.c line 848 nf_hook_ops.hk struct have errors.
解決:
Hook structure 在各個版本的linux中定義不一樣,所以如果是從dummynet 站點中下載的
老的dummynet 包可能就有錯誤,
查看下當前所用系統的hook 結構
/usr/src/kernels/linux-3.10.0-957.el7/include/linux/netfilter.h
定義了nf_hook_ops,nf_hookfn的結構
struct nf_hook_ops {
struct list_head list;
/* User fills in from here down. */
nf_hookfn *hook;
struct module *owner;
void *priv;
u_int8_t pf;
unsigned int hooknum;
/* Hooks are ordered in ascending priority. */
int priority;
/* Reserved for use in the future RHEL versions. Set to zero. */
unsigned long __rht_reserved1;
unsigned long __rht_reserved2;
unsigned long __rht_reserved3;
unsigned long __rht_reserved4;
unsigned long __rht_reserved5;
};
typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops,
struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
#ifndef __GENKSYMS__
const struct nf_hook_state *state
#else
int (*okfn)(struct sk_buff *)
#endif
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/553434.html
標籤:其他
上一篇:【PC遷移與管理】上海道寧為每個用戶和每個 PC 傳輸和遷移場景提供解決方案——PCmover
下一篇:返回列表
