Skip to content

Instantly share code, notes, and snippets.

@1mm0rt41PC
Forked from tobert/linux-dnsmasq-mitm.sh
Created November 17, 2020 17:55
Show Gist options
  • Save 1mm0rt41PC/a4dc3733778e6fbb8b30d391a2832e75 to your computer and use it in GitHub Desktop.
Save 1mm0rt41PC/a4dc3733778e6fbb8b30d391a2832e75 to your computer and use it in GitHub Desktop.
Instructions + iptables script for MITM laptop for tcpdump and/or wireshark
#!/bin/bash
# put this in /etc/dnsmasq.conf then start/restart it
# modify the interface= to point at the ethernet port the device is connected to
# optionally, set MAC address in the dhcp-host line to be the MAC of the device
#interface=enp0s31f6
#dhcp-range=192.168.102.9,192.168.102.20,255.255.255.0,12h
#dhcp-host=70:58:12:a8:e5:35,192.168.102.10
# set INTERNET_INTERFACE to the laptop's internet access interface, e.g. wifi interfaces
# usually start with a "w" or "tun0" for openvpn, etc.
INTERNET_INTERFACE=wlp4s0
INTERNET_INTERFACE=tun0
# set DEVICE_INTERFACE to the name of the ethernet port
DEVICE_INTERFACE=enp0s31f6
sysctl -w net.ipv4.ip_forward=1
iptables -A FORWARD -o $INTERNET_INTERFACE -i $DEVICE_INTERFACE -s 192.168.102.0/24 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o $INTERNET_INTERFACE -j MASQUERADE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment