# 开启ip转发
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
# 用iptables 实现拦截 nat伪装
sudo iptables -t nat -I POSTROUTING -j MASQUERADE
sudo ifconfig eth0 down #关闭网卡
sudo ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE #然后改地址
sudo ifconfig eth0 up #然后启动网卡
查看当前系统所有的监听端口
nc -zv localhost 1-65535
如何查看HTTP头
w3m -dump_head http://www.example.com
或 curl --head http://www.example.com
我的一个脚本: 笔记本作热点
#!/bin/bash
# Start
# Configure IP address for WLAN
sudo ifconfig wlan0 192.168.150.1
# Start DHCP/DNS server
sudo service dnsmasq restart
# Enable routing
sudo sysctl net.ipv4.ip_forward=1
# Enable NAT
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
# Run access point daemon
sudo hostapd /etc/hostapd.conf
# Stop
# Disable NAT
# sudo iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE
# Disable routing
# sudo sysctl net.ipv4.ip_forward=0
# Disable DHCP/DNS server
# sudo service dnsmasq stop
# sudo service hostapd stop