Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guntiss/663bc69a23c821b08829a3f24b5f6d5c to your computer and use it in GitHub Desktop.
Save guntiss/663bc69a23c821b08829a3f24b5f6d5c to your computer and use it in GitHub Desktop.
Build FULLCONENAT iptables module for Ubuntu 18

Build FULLCONENAT iptables module for Ubuntu 18

This is set up instructions on now to build netfilter-full-cone-nat for Ubuntu 18.

Tested on Ubuntu 18.04.5 LTS. Kernel used: 4.15. You might need to apt install build-essential, before starting.

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):

# cat /boot/config-`uname -r` | grep CONFIG_NF_CONNTRACK_EVENTS
CONFIG_NF_CONNTRACK_EVENTS=y

Download and compile netfilter-full-cone-nat kernel module:

# cd
# git clone https://github.com/Chion82/netfilter-full-cone-nat.git
# cd netfilter-full-cone-nat/
# make

Check that module is started (If not, run insmod xt_FULLCONENAT.ko):

# lsmod | grep xt_FULLCONENAT
xt_FULLCONENAT         36864  0

Install libmnl:

# cd
# git clone git://git.netfilter.org/libmnl
# cd libmnl
# ./autogen.sh
# ./configure
# make
# make install

Install libnftnl:

# cd
# git clone git://git.netfilter.org/libnftnl
# cd libnftnl
# ./autogen.sh
# ./configure
# make
# make install

Install iptables modules:

# cd
# git clone git://git.netfilter.org/iptables.git
# cp netfilter-full-cone-nat/libipt_FULLCONENAT.c iptables/extensions/
# cd iptables
# ./autogen.sh
# ./configure
# make
# make install

Apply FULLCONENAT iptables rules on WAN interface:

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

Verify rules are applied:

# iptables -L -t nat
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
FULLCONENAT  all  --  anywhere             anywhere

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
FULLCONENAT  all  --  anywhere             anywhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment