• Stars
    star
    426
  • Rank 101,255 (Top 3 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A kernel module to turn MASQUERADE into full cone SNAT

Implementation of RFC3489-compatible full cone SNAT.

Assuming eth0 is external interface:

iptables -t nat -A POSTROUTING -o eth0 -j FULLCONENAT #same as MASQUERADE  
iptables -t nat -A PREROUTING -i eth0 -j FULLCONENAT  #automatically restore NAT for inbound packets

Currently only UDP traffic is supported for full-cone NAT. For other protos FULLCONENAT is equivalent to MASQUERADE.

Build

Prerequisites:

  • kernel source
  • iptables source ( git://git.netfilter.org/iptables.git )

Confirm the kernel configuration option CONFIG_NF_CONNTRACK_EVENTS is enabled. If this option is disabled on your system, enable it and rebuild your netfilter modules.

Kernel Module

$ make
# insmod xt_FULLCONENAT.ko

Iptables Extension

  1. Copy libipt_FULLCONENAT.c to iptables-source/extensions.

  2. Under the iptables source directory, ./configure(use --prefix to replace your current iptables by looking at which iptables), make and make install

OpenWRT

Package for openwrt is available at https://github.com/LGA1150/openwrt-fullconenat

Usage

Assuming eth0 is external interface:

Basic Usage:

iptables -t nat -A POSTROUTING -o eth0 -j FULLCONENAT
iptables -t nat -A PREROUTING -i eth0 -j FULLCONENAT

Random port range:

iptables -t nat -A POSTROUTING -o eth0 ! -p udp -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -p udp -j FULLCONENAT --to-ports 40000-60000 --random-fully

iptables -t nat -A PREROUTING -i eth0 -p udp -m multiport --dports 40000:60000 -j FULLCONENAT

Hairpin NAT (Assuming eth1 is LAN interface and IP range for LAN is 192.168.100.0/24):

iptables -t nat -A POSTROUTING -o eth0 -j FULLCONENAT
iptables -t nat -A POSTROUTING -o eth1 -s 192.168.100.0/24 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth0 -j FULLCONENAT
iptables -t nat -A PREROUTING -i eth1 -j FULLCONENAT

kernel Patch (Optional.)

  1. Copy xt_FULLCONENAT.c to kernel-source/net/netfilter/xt_FULLCONENAT.c
  2. Append following line to kernel-source/net/netfilter/Makefile:
obj-$(CONFIG_NETFILTER_XT_TARGET_FULLCONENAT) += xt_FULLCONENAT.o
  1. Insert following section into kernel-source/net/ipv4/netfilter/Kconfig right after config IP_NF_TARGET_NETMAP section:
config IP_NF_TARGET_FULLCONENAT
  tristate "FULLCONENAT target support"
  depends on NETFILTER_ADVANCED
  select NETFILTER_XT_TARGET_FULLCONENAT
  ---help---
  This is a backwards-compat option for the user's convenience
  (e.g. when running oldconfig). It selects
  CONFIG_NETFILTER_XT_TARGET_FULLCONENAT.

  1. Insert following section into kernel-source/net/netfilter/Kconfig right after config NETFILTER_XT_TARGET_NETMAP section:
config NETFILTER_XT_TARGET_FULLCONENAT
  tristate '"FULLCONENAT" target support'
  depends on NF_NAT
  ---help---
  Full Cone NAT

  To compile it as a module, choose M here. If unsure, say N.

  1. Run make menuconfig and select: Networking support -> Network options -> Network packet filtering framework (Netfilter) -> IP: Netfilter Configuration -> <M> FULLCONENAT target support

License

Copyright 2018 Chion Tang betaidc
GPL-2.0
See LICENSE

More Repositories

1

WeChatMomentStat-Android

Get your WeChat Moment statistics and export Moments to JSON. 微信朋友圈数据统计、导出工具
Java
980
star
2

hello-old-driver

お兄ちゃん大好き(琉璃神社爬虫脚本)
Python
629
star
3

kcptun-raw

Kcptun with raw socket and fake TCP headers.
C
416
star
4

WeChatMomentExport

Xposed module to export WeChat moments data to JSON(微信朋友圈数据导出Xposed模块)
Java
330
star
5

native-base-web

NativeBase for React Native Web. The missing piece of RN4WEB.
JavaScript
73
star
6

WeChatMomentStat

微信朋友圈简单数据分析脚本,配合WeChatMomentExport1.0使用(仅支持1.0的导出JSON)
Python
68
star
7

ASCII_bad_apple

ASCII art video of Bad Apple
Python
62
star
8

redux-wait-for-action

Redux middleware to make store.dispatch() return a promise and wait for another action.
JavaScript
55
star
9

react-native-web-extended

Extended version of react-native-web
JavaScript
25
star
10

xunlei_share

[失效]迅雷离线地址获取工具CLI版
Python
17
star
11

PixivHack

A python script to crawl and fetch illustrations from Pixiv. (P站爬图脚本)
Python
15
star
12

ChionLab

Source of ChionLab. Powered by Hexo
CSS
13
star
13

rnweb-native-base-starter

react-native-web + native-base-web starter kit (Boilerplate)
JavaScript
12
star
14

teaching-feeling-web

JavaScript
9
star
15

mwan3-traffic

Patch for mwan3 with realtime interface traffic monitor.
Shell
8
star
16

tcp-chain

A scalable TCP hook/proxy framework
C
6
star
17

react-redux-universal-minimal

Minimal starter kit (boilerplate) for universal (isomorphic) React apps.
JavaScript
6
star
18

NodeJS_midway_sample

A NodeJS midway sample project.
JavaScript
5
star
19

soft-router

Arch Linux下用于软路由的轻量级策略路由脚本
Shell
5
star
20

guapi-lu-cat

瓜皮撸猫,你身边的撸猫神器
4
star
21

Chion82.github.io

Chion82的未来道具研究所!
HTML
4
star
22

bilibili_accelerator

A Chrome extension to accelerate video loading on Bilibili
JavaScript
4
star
23

netfilter-name-set

dynamic domain name match extension for iptables by DNS hooks. WIP.
C
4
star
24

BadMine

有屏幕的地方就有Bad Apple——那么这次是XP的扫雷
C++
3
star
25

Unionpay_PHP_API

Unionpay PHP API is a simple and easy-to-use interface to implement web-based Unionpay online payment modules written in PHP.
PHP
2
star
26

163_music_cracker

[已失效]网易云音乐网页版 取消版权限制 自动选择高音质 chrome插件
JavaScript
1
star
27

native-base-web-example

Component demo app with react-native-web-extended and native-base-web.
JavaScript
1
star
28

plugin-weibo-postman

Poi插件 微博直播出击战绩和建造出货数据
JavaScript
1
star