设置开放热点(通过 hostapd),使用 UFW 并通过 dnsmasq 使用自定义 DNS,通过 mac 地址进行过滤

设置开放热点(通过 hostapd),使用 UFW 并通过 dnsmasq 使用自定义 DNS,通过 mac 地址进行过滤

我正在尝试为我的 Nintendo 3DS 设置所谓的 Homepass。这基本上要求我具备以下条件:

  • 无需身份验证的无线网络(开放)
  • MAC 地址循环器(一段时间后更改无线网卡的 MAC 地址)

显然,这存在安全问题 - 谁愿意拥有开放的无线网络。我想通过实施以下措施来减轻这些风险:

  • MAC地址过滤(可伪造)
  • 隔离来自无线网络的任何内容,使其无法访问我的内部 LAN
  • 限制 DNS 查找以选择地址(我还不确定这些,我需要找出它们)
  • 限制可以访问的 IP 地址(同样,我不确定这些,我需要找出它们)

我目前已设置: - dnsmasq 充当本地网络的 DNS 服务器和 DHCP 服务器。我需要将其用于无线局域网。 - UFW 作为我的防火墙 - 一个脚本来循环无线网卡上的 MAC 地址 - hostapd 正在运行以充当热点

我目前遇到的问题: - 我的 3DS 可以连接到热点,但无法访问互联网。为了进一步测试,我允许访问另一台 PC 上的另一个无线设备。它可以连接,但也无法访问互联网。 - 我自己无知。我只是不知道如何做这些事情,而且由于我的问题的性质,我的谷歌搜索并没有太大帮助。

现有研究:-https://gbatemp.net/threads/how-to-have-a-homemade-streetpass-relay.352645/

我做了什么:

通过以下方式运行 hostapd:

sudo hostapd /opt/scripts/nzone/hostapd.conf

hostapd 配置:

interface=wlan1
driver=nl80211
ssid=NZ@McD1
hw_mode=g
channel=6
auth_algs=1
ignore_broadcast_ssid=0
wpa=0
country_code=CA
macaddr_acl=1
accept_mac_file=/opt/scripts/nzone/allowmac

dnsmasq 配置:

# Blocks incomplete requests from leaving the network
domain-needed

# Prevents non-routable private addresses from being forwarded out of the network
bogus-priv

server=/home.local/192.168.0.199
server=//192.168.0.199

# Upstream DNS servers
server=8.8.8.8 # Google
server=8.8.4.4 # Google
#server=208.67.222.222 # OpenDNS
#server=208.67.222.220 # OpenDNS

# Only queries for private domain are answered by Dnsmasq
#local=/home.local/
local=/local/

#domain=home.local
domain=local

interface=eth0
interface=wlan1

listen-address=127.0.0.1
listen-address=192.168.0.199
listen-address=192.168.0.210

# Only listen on the addresses specified with list-address
#bind-interfaces

no-hosts
#no-resolv
addn-hosts=/etc/dnsmasq.hosts # http://winhelp2002.mvps.org/hosts.htm

# Why does the interface command break now?  Worked before.
#dhcp-range=interface:eth0;192.168.0.21,192.168.0.100,6h
#dhcp-range=interface:wlan1,192.168.0.240,192.168.0.245,1h
dhcp-range=192.168.0.21,192.168.0.50,6h

# Default gateway
#dhcp-option=3,192.168.0.1
dhcp-option=option:router,192.168.0.1

dhcp-option=option:dns-server,0.0.0.0
#dhcp-option=option:ntp-server,3.ca.pool.ntp.org # This doesn't work.. why?

# Windows/Samba suggestions from default configuration
dhcp-option=option:ip-forward-enable,0
dhcp-option=option:netbios-ns,0.0.0.0
dhcp-option=option:netbios-dd,0.0.0.0
dhcp-option=option:netbios-nodetype,8

#dhcp-option=19,0           # option ip-forwarding off
#dhcp-option=44,0.0.0.0     # set netbios-over-TCP/IP nameserver(s) aka WINS     server(s)
#dhcp-option=45,0.0.0.0     # netbios datagram distribution server
#dhcp-option=46,8           # netbios node type

dhcp-leasefile=/var/lib/misc/dnsmasq.leases
bogus-nxdomain=64.94.110.11
dhcp-authoritative

mx-host=home.local,mail.home.local,30
txt-record=home.local,"v=spf1 mx -all"

# For debugging purposes, log each DNS query as it passes through
# dnsmasq.
#log-queries

# Log lots of extra information about DHCP transactions.
#log-dhcp

# Include another lot of configuration options.
conf-dir=/etc/dnsmasq.d

我的 UFW 状态:

Status: active

To                         Action      From
--                         ------      ----
23/tcp                     DENY        Anywhere
Samba                      ALLOW       192.168.0.0/24
Anywhere                   ALLOW       192.168.0.103/udp
Postfix                    ALLOW       Anywhere
OpenSSH                    LIMIT       Anywhere
Calibre                    ALLOW       192.168.0.0/24
PlexPY                     ALLOW       192.168.0.0/24
Ubooquity                  ALLOW       192.168.0.0/24
Syslog                     ALLOW       192.168.0.0/24
dnsmasq                    ALLOW       Anywhere
Plex                       ALLOW       Anywhere
ZNC                        ALLOW       Anywhere
PlexWebTools               ALLOW       192.168.0.0/24
HDHRExtend                 ALLOW       192.168.0.104
dnsmasq (v6)               ALLOW       Anywhere (v6)

在我的 /etc/sysctl.conf 文件中我有:

net.ipv4.ip_forward=1

我已经手动为 iptables 运行了这些命令:

iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
iptables -I FORWARD -i wlan1 -j ACCEPT

为了完整起见,我的 /etc/network/interfaces:

# The loopback network interface
#auto lo eth0 wlan0 wlan1
auto lo eth0

iface lo inet loopback

# The primary network interface

#iface eth0 inet dhcp
iface eth0 inet static
    address 192.168.0.199
    netmask 255.255.255.0
    gateway 192.168.0.1
    broadcast 192.168.0.255
    network 192.168.0.0
    up ethtool -s eth0 wol g
    dns-domain home.local
    dns-search home.local
    dns-nameservers 192.168.0.199

#iface wlan0 inet dhcp
#       wpa-ssid SSID
#       wpa-psk blargh
#       wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

#       pre-up /sbin/wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
#       post-dwn killall -q wpa_supplicant

#iface wlan1 inet static
#       hostapd /etc/hostapd/hostapd.conf
#       address 192.168.0.200
#       netmask 255.255.255.0
#       gateway 192.168.0.1
#       broadcast 192.168.0.255
#       network 192.168.0.0
#       dns-domain home.local
#       dns-search home.local
#       dns-nameservers 192.168.0.199

# This is an autoconfigured IPv6 interface
iface eth0 inet6 auto

我通过以下方式启动无线接口:

ifconfig wlan1 192.168.0.210 up

我通过以下方式更改其 MAC 地址:

ifconfig wlan1 down hw ether $MAC up

来自系统日志的一些信息:

Nov  8 16:13:48 ubuntu hostapd: wlan1: STA MACADDRESS IEEE 802.11: authenticated
Nov  8 16:13:48 ubuntu hostapd: wlan1: STA MACADDRESS IEEE 802.11: authenticated
Nov  8 16:13:48 ubuntu hostapd: wlan1: STA MACADDRESS IEEE 802.11: associated (aid 1)
Nov  8 16:13:48 ubuntu hostapd: wlan1: STA MACADDRESS IEEE 802.11: associated (aid 1)
Nov  8 16:14:04 ubuntu hostapd: wlan1: STA MACADDRESS IEEE 802.11: disassociated
Nov  8 16:14:04 ubuntu hostapd: wlan1: STA MACADDRESS IEEE 802.11: disassociated

相关内容