```bash
$ cat /etc/qnatcft.conf
local ip 10.10.10.2/27
ip addr 10.10.10.3/27 dev dpdk0.kni
ip addr 110.110.110.2/28 dev dpdk1.kni
ip route 10.10.10.3/32 dev inside kni_host
ip route 110.110.110.2/32 dev outside kni_host
ip route 10.0.0.0/8 via 10.10.10.1 dev inside
ip route 0.0.0.0/0 via 110.110.110.1 dev outside
hostname nattest
ip nat pool default
member ip 110.110.110.5/28
exit
ip nat source 10.0.0.0 10.255.255.255
dest pool default
exit
Keepalived is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
English | 中文
项目特色
QNAT是基于DPVS和DPDK项目创建一个高性能NAT(Network Address Translation,网络地址转换)项目,主要应用于IDC(数据中心)、中大型办公网出口等场景下,支持NAT44、流量透传、多地址池选择、限定单IP会话数、NAT会话记录等功能。同时我们还增加了命令行界面管理功能,让您能像管理网络设备一样对QNAT进行管理。环境需求
Linux Kernel version >= 2.6.34 (需要支持支持UIO和HUGETLBFS)DPDK version = 17.05.2GCC version >= 4.8.5测试环境
Linux Distribution: CentOS 7.2Kernel: 3.10.0-327.36.3.el7.x86_64CPU: Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHzNIC: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)Memory: 64G with two NUMA nodeGCC: gcc version 4.8.5 20150623 (Red Hat 4.8.5-4)DPDK: dpdk-stable-17.05.2架构
安装/配置说明
安装依赖包
获取DPDK
安装/配置DPDK
配置DPDK hugepage
绑定DPDK网卡驱动
```bash modprobeuio insmod build/kmod/igb_uio.ko $ insmod build/kmod/rte_kni.ko$ {path-of-dpdk}/usertools/dpdk-devbind.py -s
#获取需要绑定至DPDK下网卡的uio号,假定将要使用的eth0为0000:84:00.0,eth1为0000:84:00.1
ifconfigeth0down;ifconfigeth1down {path-of-dpdk}/usertools/dpdk-devbind.py -b igb_uio 0000:84:00.0 $ {path-of-dpdk}/usertools/dpdk-devbind.py -b igb_uio 0000:84:00.1
安装QNAT
配置QNAT
通过命令行进行配置
通过配置文件进行配置
```bash $ cat /etc/qnatcft.conf local ip 10.10.10.2/27 ip addr 10.10.10.3/27 dev dpdk0.kni ip addr 110.110.110.2/28 dev dpdk1.kni ip route 10.10.10.3/32 dev inside kni_host ip route 110.110.110.2/32 dev outside kni_host ip route 10.0.0.0/8 via 10.10.10.1 dev inside ip route 0.0.0.0/0 via 110.110.110.1 dev outside hostname nattest ip nat pool default member ip 110.110.110.5/28 exit ip nat source 10.0.0.0 10.255.255.255 dest pool default exit$ qnatsh #启动qnat命令行工具
/ \ / \ / \ / \ | \ /
| ######| ######| ######\ | ######| #######| ######
##__| ##| ##_##| ###| ## | ## | ##| ##/ ##| ##___## | ##| ## \ | ####\ ## | ## | ##| ## ## ##
#####| #######| ###### | ## | ##| ####### ######
| _| ##| ##__/ ##| ##_#### | ##/ ##| ## | __| ## ## ## ## ## ## ### ## ##| ## ## ## ###### ###### ###### ###### ## ######
nathost# ip nat start #启动NAT服务 nathost# load config #加载配置文件的配置 nattest# write file #保存配置
默认的255.255.255.255 = 10000 表示所有IP默认最大会话数为10000.可在配置文件中对单IP进行会话数限制配置。
NAT会话记录
由于日志数据量较大,建议在/etc/qnat/qnat.conf调整日志存放路径,并使用logrotate进行归档。License
Main code of QNAT is GNU General Public License, version 2 (GPLv2) licensed.
Other Dependencies:
DPVS is a high performance Layer-4 load balancer based on DPDK. It’s derived from Linux Virtual Server LVS and its modification alibaba/LVS.
Keepalived is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Linux Virtual Server kernel patches and related programs, released under the GNU General Public License (GPL).
Main code of DPDK is BSD licensed and Linux kernel related parts are naturally licensed under the GPL.
Linux Virtual Server kernel patches and related programs, released under the GNU General Public License (GPL).
Linux Kernel is available under GPL, see this document for details.
Alibaba/LVS is based on LVS kernel components and related programs.
Quagga Routing Software Suite, GPL licensed.
Consistent hashing library is BSD licensed.
联系我们