Skip to content

Instantly share code, notes, and snippets.

@Noah-Huppert
Last active July 7, 2024 02:24
Show Gist options
  • Save Noah-Huppert/5fa04095da8238dcc5a0941562f32068 to your computer and use it in GitHub Desktop.
Save Noah-Huppert/5fa04095da8238dcc5a0941562f32068 to your computer and use it in GitHub Desktop.
VLAN with wireless access point, with AP connected to WLAN via a laptop acting as a router.

In these instructions the VLAN CIDRs are:

Wireless AP VLAN
10.100.100.0/24
Laptop to AP Ethernet VLAN
10.200.200.0/24

Adjust as needed.

  1. Create a file named .env which defines the env vars ieth0 and iwlp0 with the names of the laptop's ethernet interface and wireless interface, then source
  2. Setup wireless access point to have the 10.100.100.0/24 CIDR
  3. Enable IP forwarding on the laptop:
    echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
    
  4. Setup laptop ethernet to have 10.200.200.100/24 as its address
    sudo ip addr add 10.200.200.100/24 dev $ieth0
    
  5. Edit the /etc/dhcpd.conf file to have:
    subnet 10.200.200.0 netmask 255.255.255.0 {
        range 10.200.200.150 10.200.200.250;
        option domain-name-servers 8.8.8.8, 8.8.4.4;
        option routers 10.200.200.100;
    }
    
  6. Run the DHCP server:
    sudo dhcpd -f
    
  7. Ensure the DHCP server didn't configure a default route using the 10.200.200.0/24 subnet:
    ip route
    
    Ensure the only default is not via the laptop CIRD above. If there is a default for the laptop CIRD delete it:
    sudo ip route delete default via 10.200.200.100 dev $ieth0
    
  8. Go to the "Status" page of the router, it should have an IP on the laptop's network (Probably 10.200.200.150) and the gateway should be 10.200.200.100 on /24
  9. Setup IP tables on the laptop:
  • Cleanup any existing rules:
    sudo iptables --flush
    sudo iptables -t nat --flush
    sudo iptables --delete-chain
    sudo iptables -t nat --delete-chain
    
  • Enable NAT:
    sudo iptables -t nat -A POSTROUTING -o $iwlp0 -j MASQUERADE
    
  • Allow traffic to forwarded:
    sudo iptables -A FORWARD -i $ieth0 -o $iwlp0 -j ACCEPT
    sudo iptables -A FORWARD -i $iwlp0 -o $ieth0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
    
<mxfile host="app.diagrams.net" modified="2024-07-07T02:23:28.552Z" agent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0" etag="V0HZRMX3mSf2Czxp4yrN" version="24.6.4" type="device">
<diagram name="Page-1" id="M90xtGZ9PsTCg2V_fbbm">
<mxGraphModel dx="1153" dy="1675" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-29" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="180" y="140" width="390" height="160" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-27" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="180" y="310" width="390" height="200" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-25" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="180" y="520" width="390" height="220" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" edge="1" parent="1" source="7YtVhMAh9MGJ8kOwzz-x-21" target="7YtVhMAh9MGJ8kOwzz-x-24">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-23" value="Ethernet" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7YtVhMAh9MGJ8kOwzz-x-4">
<mxGeometry x="0.0829" y="-2" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-1" value="" style="image;html=1;image=img/lib/clip_art/networking/Wireless_Router_N_128x128.png" vertex="1" parent="1">
<mxGeometry x="340" y="460" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;dashed=1;" edge="1" parent="1" source="7YtVhMAh9MGJ8kOwzz-x-2" target="7YtVhMAh9MGJ8kOwzz-x-3">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-7" value="WLAN" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7YtVhMAh9MGJ8kOwzz-x-6">
<mxGeometry x="0.2" y="2" relative="1" as="geometry">
<mxPoint x="2" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-2" value="" style="image;html=1;image=img/lib/clip_art/computers/Laptop_128x128.png" vertex="1" parent="1">
<mxGeometry x="323" y="274" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-3" value="" style="image;html=1;image=img/lib/clip_art/networking/Wireless_Router_N_128x128.png" vertex="1" parent="1">
<mxGeometry x="323" y="90" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-11" style="rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;dashed=1;" edge="1" parent="1" source="7YtVhMAh9MGJ8kOwzz-x-8" target="7YtVhMAh9MGJ8kOwzz-x-1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-14" value="WLAN" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7YtVhMAh9MGJ8kOwzz-x-11">
<mxGeometry x="-0.1052" y="-1" relative="1" as="geometry">
<mxPoint x="1" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-8" value="" style="image;html=1;image=img/lib/clip_art/computers/Laptop_128x128.png" vertex="1" parent="1">
<mxGeometry x="230" y="640" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-12" style="rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;dashed=1;" edge="1" parent="1" source="7YtVhMAh9MGJ8kOwzz-x-9" target="7YtVhMAh9MGJ8kOwzz-x-1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-15" value="WLAN" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7YtVhMAh9MGJ8kOwzz-x-12">
<mxGeometry x="-0.1091" y="4" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-9" value="" style="image;html=1;image=img/lib/clip_art/computers/Laptop_128x128.png" vertex="1" parent="1">
<mxGeometry x="340" y="650" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-13" style="rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;dashed=1;" edge="1" parent="1" source="7YtVhMAh9MGJ8kOwzz-x-10" target="7YtVhMAh9MGJ8kOwzz-x-1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-16" value="WLAN" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7YtVhMAh9MGJ8kOwzz-x-13">
<mxGeometry x="-0.0508" y="1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-10" value="" style="image;html=1;image=img/lib/clip_art/computers/Laptop_128x128.png" vertex="1" parent="1">
<mxGeometry x="460" y="640" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-17" value="" style="points=[[0.005,0.09,0],[0.08,0,0],[0.76,0.25,0],[1,0.92,0],[0.91,0.995,0],[0.57,0.995,0],[0.045,0.955,0],[0.005,0.43,0]];verticalLabelPosition=bottom;sketch=0;html=1;verticalAlign=top;aspect=fixed;align=center;pointerEvents=1;shape=mxgraph.cisco19.3g_4g_indicator;fillColor=#005073;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="295" y="591" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-18" value="" style="points=[[0.005,0.09,0],[0.08,0,0],[0.76,0.25,0],[1,0.92,0],[0.91,0.995,0],[0.57,0.995,0],[0.045,0.955,0],[0.005,0.43,0]];verticalLabelPosition=bottom;sketch=0;html=1;verticalAlign=top;aspect=fixed;align=center;pointerEvents=1;shape=mxgraph.cisco19.3g_4g_indicator;fillColor=#005073;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="348" y="596" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-19" value="" style="points=[[0.005,0.09,0],[0.08,0,0],[0.76,0.25,0],[1,0.92,0],[0.91,0.995,0],[0.57,0.995,0],[0.045,0.955,0],[0.005,0.43,0]];verticalLabelPosition=bottom;sketch=0;html=1;verticalAlign=top;aspect=fixed;align=center;pointerEvents=1;shape=mxgraph.cisco19.3g_4g_indicator;fillColor=#005073;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="412" y="588" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-20" value="" style="points=[[0.005,0.09,0],[0.08,0,0],[0.76,0.25,0],[1,0.92,0],[0.91,0.995,0],[0.57,0.995,0],[0.045,0.955,0],[0.005,0.43,0]];verticalLabelPosition=bottom;sketch=0;html=1;verticalAlign=top;aspect=fixed;align=center;pointerEvents=1;shape=mxgraph.cisco19.3g_4g_indicator;fillColor=#005073;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="335" y="209" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-21" value="" style="sketch=0;pointerEvents=1;shadow=0;dashed=0;html=1;strokeColor=#d6b656;fillColor=#fff2cc;aspect=fixed;labelPosition=center;verticalLabelPosition=bottom;verticalAlign=top;align=center;outlineConnect=0;shape=mxgraph.vvd.ethernet_port;" vertex="1" parent="1">
<mxGeometry x="352" y="460" width="22" height="22" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-22" value="WAN" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="338" y="475" width="50" height="30" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-24" value="" style="sketch=0;pointerEvents=1;shadow=0;dashed=0;html=1;strokeColor=#d6b656;fillColor=#fff2cc;aspect=fixed;labelPosition=center;verticalLabelPosition=bottom;verticalAlign=top;align=center;outlineConnect=0;shape=mxgraph.vvd.ethernet_port;" vertex="1" parent="1">
<mxGeometry x="352" y="350" width="22" height="22" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-26" value="&lt;div align=&quot;left&quot;&gt;VLAN&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;10.100.100.0/24&lt;br&gt;&lt;/div&gt;" style="text;html=1;align=left;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="185" y="520" width="110" height="40" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-28" value="&lt;div align=&quot;left&quot;&gt;VLAN&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;10.200.200.0/24&lt;br&gt;&lt;/div&gt;" style="text;html=1;align=left;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="185" y="314" width="110" height="40" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-30" value="&lt;div align=&quot;left&quot;&gt;VLAN&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;192.168.0.1/24&lt;br&gt;&lt;/div&gt;" style="text;html=1;align=left;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="185" y="140" width="100" height="40" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-31" value="The Internet" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="297" y="-50" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-34" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.55;entryY=0.95;entryDx=0;entryDy=0;entryPerimeter=0;startArrow=classic;startFill=1;" edge="1" parent="1" source="7YtVhMAh9MGJ8kOwzz-x-3" target="7YtVhMAh9MGJ8kOwzz-x-31">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-35" value="House Wide Router" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=default;" vertex="1" parent="1">
<mxGeometry x="383" y="100" width="130" height="30" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-36" value="Laptop" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=default;" vertex="1" parent="1">
<mxGeometry x="374" y="270" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="7YtVhMAh9MGJ8kOwzz-x-37" value="Private Network Router" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=default;" vertex="1" parent="1">
<mxGeometry x="405" y="477" width="150" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment