There are similar questions already, but I can't follow their descriptions. Here's what I have:
+-----+ +--------------------+ +----------------------+ +---------------+
| | | ISP's Modem/Router | | Debian Box with | <--GbE-- | |
| ISP | <-- | (opposite corner | <--WiFi-- | USB WiFi adapter and | <--GbE-- | Local Network |
| | | of the house) | | 8-port GbE switch | <--GbE-- | |
+-----+ +--------------------+ +----------------------+ +---------------+
And some of those local Ethernet cords are getting kinda long.
So here's what I want:
+-----+ +--------------------+ +---------------------------+ +---------------+
| | | ISP's Modem/Router | | Debian Box with | <--GbE--- | |
| ISP | <-- | (opposite corner | <--WiFi-- | TWO USB WiFi adapters and | <--GbE--- | Local Network |
| | | of the house) | | 8-port GbE switch | <--WiFi-- | |
+-----+ +--------------------+ +---------------------------+ +---------------+
Essentially, I'm just replacing the longer wires with WiFi, in the same local network. The overall result should be as if a standard WiFi router had its WAN port converted to a separate WiFi adapter, in that the local combination of wired and wireless behaves as a single network, and I can connect anything to it by just matching the "router's" SSID and password. (The "router" in this case refers to the Debian box, not the ISP's modem/router.)
Here are my config files so far, for that Debian box, which currently produce the top diagram. The question is how to modify them after plugging in the second WiFi adapter, to produce the second diagram, and to guarantee that the two adapters don't switch roles. (The one that presently connects to the ISP claims to also support AP mode, but falls apart when it tries. So I want to keep that one in its present role, and have the new one as the new AP.)
/etc/network/if-pre-up.d/swconfig:
# Affects several other files:
# /etc/dnsmasq.conf
# /etc/network/interfaces
# /root/Scripts/Startup-Network.sh
#---------------------------#
# BPI-R1 VLAN configuration #
#---------------------------#
#
# This will create the following ethernet port:
# - eth0.101 = LAN (5 port switch)
ifconfig eth0 up
# The swconfig port number are:
# |2|1|0|4| |3|
# (looking at front of ports)
swconfig dev eth0 set reset 1
swconfig dev eth0 set enable_vlan 1
swconfig dev eth0 vlan 101 set ports '4 0 1 2 3 8t'
swconfig dev eth0 set apply 1
exit 0
/etc/network/interfaces:
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
# eth0.x matches the 'vlan x set ports' line(s) in /etc/network/if-pre-up.d/swconfig
auto eth0.101
# dhcp configuration
#iface eth0.101 inet dhcp
# static ip configuration
iface eth0.101 inet static
address 192.168.50.1 # (not my actual IP, but you get the idea)
netmask 255.255.255.0
# gateway 192.168.50.1
auto wlan0
iface wlan0 inet dhcp
wpa-ssid <ISP's SSID>
wpa-psk <ISP's password>
/etc/dnsmasq.conf is entirely commented out except for this at the bottom:
# eth0.x matches the 'vlan x set ports' line(s) in /etc/network/if-pre-up.d/swconfig
interface=eth0.101
# normal DHCP
dhcp-range=192.168.50.100,192.168.50.199,12h
# special, need to be found easily
# Static1 (by MAC address instead of hostname, so that a replacement can exist simultaneously for a while)
dhcp-host=12:34:56:78:9a:bc,192.168.50.25
# Static2 (by MAC address instead of hostname, so that a replacement can exist simultaneously for a while)
dhcp-host=34:56:78:9a:bc:de,192.168.50.35
# Static3 (by MAC address instead of hostname, so that a replacement can exist simultaneously for a while)
dhcp-host=56:78:9a:bc:de:f0,192.168.50.72
/root/Scripts/Startup-Network.sh runs on startup, ultimately from /etc/rc.local:
# Match settings in /etc/network/interfaces
IFACE_WAN="wlan0"
IFACE_LAN="eth0.101"
# Actual work
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables --table nat --append POSTROUTING --out-interface $IFACE_WAN -j MASQUERADE
iptables --append FORWARD --in-interface $IFACE_LAN -j ACCEPT