配置linux作为路由器上网

#!/bin/bash

#LAN口IP网段
SRC_IP=192.168.1.0/24
#上网卡名称

# assuming wlo1 is STA interface
OUT_INTERFACE=wlo1

ip=`ifconfig ${OUT_INTERFACE}|grep 'inet '|awk '{print $2}'`
# all packets leaving wlan1 will change source IP to STA interface IP
iptables -t nat -A POSTROUTING -o ${OUT_INTERFACE} -j SNAT --to $ip

Related Posts