Skip to content

Instantly share code, notes, and snippets.

@tobert
Created June 15, 2017 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tobert/1c0250e2daba48bc35f5e6a37da91524 to your computer and use it in GitHub Desktop.
Save tobert/1c0250e2daba48bc35f5e6a37da91524 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