Skip to content

Instantly share code, notes, and snippets.

@scola
Created July 12, 2014 13:52
Show Gist options
  • Save scola/eed6772117df7eccd560 to your computer and use it in GitHub Desktop.
Save scola/eed6772117df7eccd560 to your computer and use it in GitHub Desktop.
use iptables to anti-dns poison on linux or openwrt
#!/bin/bash
iptables -I INPUT -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0x1010101,0xffffffff,0x4a7d7f66,0x4a7d9b66,0x4a7d2766,0x4a7d2771,0xd155e58a,0x42442b2,0x807c62d,0x253d369e" -j DROP
iptables -I INPUT -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0x2e52ae44,0x3b1803ad,0x402158a1,0x4021632f,0x4042a3fb,0x4168cafc,0x41a0db71,0x422dfced,0x480ecd68,0x480ecd63" -j DROP
iptables -I INPUT -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0x4e10310f,0x5d2e0859,0x80797e8b,0x9f6a794b,0xa9840d67,0xc043c606,0xca6a0102,0xcab50755,0xcba1e6ab,0xcb620741" -j DROP
iptables -I INPUT -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0xcf0c5862,0xd0381f2b,0xd1913632,0xd1dc1eae,0xd1244921,0xd155e58a,0xd35e4293,0xd5a9fb23,0xd8ddbcb6,0xd8eab30d" -j DROP
iptables -I INPUT -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0xf3b9bb03,0xf3b9bb27,0x807c62d,0xf3b9bb1e,0x9f1803ad" -j DROP
#forward chain
iptables -I FORWARD -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0x1010101,0xffffffff,0x4a7d7f66,0x4a7d9b66,0x4a7d2766,0x4a7d2771,0xd155e58a,0x42442b2,0x807c62d,0x253d369e" -j DROP
iptables -I FORWARD -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0x2e52ae44,0x3b1803ad,0x402158a1,0x4021632f,0x4042a3fb,0x4168cafc,0x41a0db71,0x422dfced,0x480ecd68,0x480ecd63" -j DROP
iptables -I FORWARD -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0x4e10310f,0x5d2e0859,0x80797e8b,0x9f6a794b,0xa9840d67,0xc043c606,0xca6a0102,0xcab50755,0xcba1e6ab,0xcb620741" -j DROP
iptables -I FORWARD -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0xcf0c5862,0xd0381f2b,0xd1913632,0xd1dc1eae,0xd1244921,0xd155e58a,0xd35e4293,0xd5a9fb23,0xd8ddbcb6,0xd8eab30d" -j DROP
iptables -I FORWARD -p udp -m udp --sport 53 -m u32 --u32 "0&0x0F000000=0x05000000 && 22&0xFFFF@16=0xf3b9bb03,0xf3b9bb27,0x807c62d,0xf3b9bb1e,0x9f1803ad" -j DROP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment