Skip to content

Instantly share code, notes, and snippets.

@prologic
Last active February 6, 2024 03:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prologic/d84634f3c49f6bde4d73 to your computer and use it in GitHub Desktop.
Save prologic/d84634f3c49f6bde4d73 to your computer and use it in GitHub Desktop.
iptables built as a static standalone binary
name=iptables
version=1.4.21
release=1
source=(ftp://ftp.netfilter.org/pub/iptables/$name-$version.tar.bz2)
PKG="$(pwd)/pkg"
if [ -d $PKG ]; then
mkdir -p $PKG
fi
if [ ! -d $name-$version ]; then
curl -q -L -O $source
tar xvf $name-$version.*tar*
fi
cd $name-$version
./configure \
--prefix=/usr \
--mandir=/usr/man \
--disable-shared \
--enable-static
export CFLAGS='-static'
export LDFLAGS='-static -dl'
make
make DESTDIR=$PKG install
ldd $PKG/usr/sbin/xtables-multi
@prologic
Copy link
Author

THe last step in the above script produces:

    linux-vdso.so.1 (0x00007fffaefdf000)
    libm.so.6 => /lib/libm.so.6 (0x00007f3f7006b000)
    libc.so.6 => /lib/libc.so.6 (0x00007f3f6fcc4000)
    /lib/ld-linux-x86-64.so.2 (0x00007f3f7036c000)

How can we build iptables statically?

@yybit
Copy link

yybit commented Feb 6, 2024

THe last step in the above script produces:

    linux-vdso.so.1 (0x00007fffaefdf000)
    libm.so.6 => /lib/libm.so.6 (0x00007f3f7006b000)
    libc.so.6 => /lib/libc.so.6 (0x00007f3f6fcc4000)
    /lib/ld-linux-x86-64.so.2 (0x00007f3f7036c000)

How can we build iptables statically?

try make LDFLAGS='-all-static'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment