Skip to content

Instantly share code, notes, and snippets.

@RealYukiSan
Created May 23, 2024 09:34
Show Gist options
  • Save RealYukiSan/ea3ae0a3d7afce7433dbe651acdc70e0 to your computer and use it in GitHub Desktop.
Save RealYukiSan/ea3ae0a3d7afce7433dbe651acdc70e0 to your computer and use it in GitHub Desktop.
Make your laptop into a working repeater/hotspot
bind-interfaces
no-resolv
dhcp-range=192.168.33.2,192.168.33.20,12h
dhcp-option=3,192.168.33.1 # Gateway (gw)
dhcp-option=6,192.168.33.1 # DNS
log-queries
log-dhcp
listen-address=192.168.33.1
interface=wlan1
ssid=file-sharing
channel=6
hw_mode=g
wpa=2
wpa_passphrase=password123
wpa_key_mgmt=WPA-PSK
@RealYukiSan
Copy link
Author

RealYukiSan commented May 23, 2024

Make your computer act as a router or repeater

to enable hotspot, start the following service as root:

dnsmasq -C dnsmasq.conf -q -d
hostapd -dd -t hostapd.conf
ifconfig wlan1 192.168.33.1 netmask 255.255.255.0 up

helpful post, but there's an exception, the step on the post is not entirely accurate: route command is unnecessary, and the listen address must be the same as gateaway to be able response to the client request.

Debugging

list routing table: route -n or ip route list
monitor network traffic: tcpdump -vv -i wlan1 'port 67 or port 68' (see man 7 pcap-filter for more information about the expression)
list used port netstat -tulpn
list reserved port: less /etc/services

Link and Reference

@RealYukiSan
Copy link
Author

RealYukiSan commented May 23, 2024

To enable internet access, use the following command:

sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.33.0/24 ! -d 192.168.33.0/24 -j MASQUERADE

make sure it's applied:

iptables -t nat -S

flush or delete the rule:

iptables -t nat -F

Link and Reference

@RealYukiSan
Copy link
Author

Related link

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