Bash script to automate setup of Linux router useful for IoT device traffic analysis and SSL mitm
This Bash script automates the process of creating a wireless router/access point on a Linux system (specifically tested on Kali 2024.04). It allows you to quickly set up a network bridge with NAT, DHCP, and WiFi access point functionality.
- Dynamically detect network interfaces
- Create a bridge between LAN and WiFi interfaces
- Set up NAT (Network Address Translation)
- Configure DHCP server
- Create a secure WiFi access point
- Easy up/down management
- Kali Linux 2024.04 (or similar Debian-based distribution)
- Wireless adapter supporting AP mode . tested with TP-Link wn722n v1
- Root/sudo access
sudo apt update
sudo apt install -y hostapd dnsmasq iptables net-tools wireless-tools
Modify the following variables in the script to match your network setup:
WIFI_SSID
: Name of the WiFi networkWIFI_PASSWORD
: WiFi network passwordLAN_IP
: IP address for the bridge interfaceLAN_SUBNET
: Subnet in CIDR notation (e.g., 24 for 255.255.255.0)LAN_DHCP_START
andLAN_DHCP_END
: DHCP address rangeLAN_DNS_SERVER
: DNS server to use
# Make the script executable
chmod +x mitmrouter.sh
# Bring up the wireless router
sudo ./mitmrouter.sh up
# Tear down the wireless router
sudo ./mitmrouter.sh down
- Verify interface names using
ip link
oriwconfig
- Ensure wireless adapter supports AP mode
- Check that no other network management tools are interfering
- Requires manual interface configuration
- Temporarily disables NetworkManager
- Assumes a single wireless and LAN interface
- Change default passwords
- Use strong WiFi encryption
- Limit DHCP address range
- Consider additional firewall rules
Pull requests and improvements are welcome!
./mitmrouter.sh: <up/down>
The ./mitmrouter.sh up
command will bring down all the linux router components and then build them back up again
The ./mitmrouter.sh down
command will bring down all the linux router components