Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Last active November 14, 2018 03:27
Show Gist options
  • Save cleverca22/84e8794d3b050f61bd865ca2aa8d8752 to your computer and use it in GitHub Desktop.
Save cleverca22/84e8794d3b050f61bd865ca2aa8d8752 to your computer and use it in GitHub Desktop.
network setup

an I-240G-U "modem" connects to the main fiber coming into the house

https://www.scribd.com/document/393153219/I-240G-U-manual is a copy of the manual i found online

coming out of it are 2 telephone ports, 4 gibabit ethernet, and 0 coax ports (the 240 in the model#)

it appears to be designed as a self-contained router, but it must not have suited the ISP's needs

1 telephone port and 3 ethernet are disabled, the ethernet wont even get a link LED when connecting

the 1 remaining ethernet port has at least 3 VLAN's on it

  • vlan 33 appears to be a backdoor, the ISP router bridges it into the private lan
  • vlan 34 is the tv service, with a 10.x.y.z address space, and multicast packets
  • vlan 35 is the internet service, dhcp to get a public ip

currently, the ISP router is configured to use pppoe on its "uplink", and the ISP patches cause that to be on vlan 35

the nixos_router is then running a pppoe-server on its uplink (also vlan 35), which its sharing between the modem and ISP router

vlan 34 is then left purely to the ISP router, which handles tv service over it

i have not been able to get vlan 34 and its multicast traffic to work on the nixos router

dot network.dot -Tsvg > network.svg
dot network.dot -Tpng > network.png
digraph {
ISP -> ONT [label="fiber"]
ONT -> phone [label="regular old analog phone lines"]
ONT -> switch1 [label="vlan 34+35"]
switch1 -> isp_router [label="vlan 34"]
switch1 -> nixos_router [label="vlan 35"]
nixos_router -> switch2
switch2 -> dlink_ap
switch2 -> nas
switch2 -> c2d
switch2 -> switch3
switch3 -> amd
switch3 -> raspberrypi
dlink_ap -> laptop [label="wifi"]
dlink_ap -> cellphone [label="wifi"]
dlink_ap -> tablet [label="wifi"]
}
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.40.1 (20161225.0304)
-->
<!-- Title: %3 Pages: 1 -->
<svg width="551pt" height="538pt"
viewBox="0.00 0.00 551.09 538.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 534)">
<title>%3</title>
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-534 547.0923,-534 547.0923,4 -4,4"/>
<!-- ISP -->
<g id="node1" class="node">
<title>ISP</title>
<ellipse fill="none" stroke="#000000" cx="133.4469" cy="-512" rx="27" ry="18"/>
<text text-anchor="middle" x="133.4469" y="-508.3" font-family="Times,serif" font-size="14.00" fill="#000000">ISP</text>
</g>
<!-- ONT -->
<g id="node2" class="node">
<title>ONT</title>
<ellipse fill="none" stroke="#000000" cx="133.4469" cy="-425" rx="30.5947" ry="18"/>
<text text-anchor="middle" x="133.4469" y="-421.3" font-family="Times,serif" font-size="14.00" fill="#000000">ONT</text>
</g>
<!-- ISP&#45;&gt;ONT -->
<g id="edge1" class="edge">
<title>ISP&#45;&gt;ONT</title>
<path fill="none" stroke="#000000" d="M133.4469,-493.9735C133.4469,-482.1918 133.4469,-466.5607 133.4469,-453.1581"/>
<polygon fill="#000000" stroke="#000000" points="136.947,-453.0033 133.4469,-443.0034 129.947,-453.0034 136.947,-453.0033"/>
<text text-anchor="middle" x="146.9469" y="-464.8" font-family="Times,serif" font-size="14.00" fill="#000000">fiber</text>
</g>
<!-- phone -->
<g id="node3" class="node">
<title>phone</title>
<ellipse fill="none" stroke="#000000" cx="34.4469" cy="-338" rx="34.394" ry="18"/>
<text text-anchor="middle" x="34.4469" y="-334.3" font-family="Times,serif" font-size="14.00" fill="#000000">phone</text>
</g>
<!-- ONT&#45;&gt;phone -->
<g id="edge2" class="edge">
<title>ONT&#45;&gt;phone</title>
<path fill="none" stroke="#000000" d="M105.0116,-418.3388C79.1398,-411.641 43.7573,-400.6609 35.4469,-389 30.8012,-382.4812 29.3115,-374.2076 29.3283,-366.2311"/>
<polygon fill="#000000" stroke="#000000" points="32.8312,-366.3201 30.0794,-356.0889 25.8503,-365.803 32.8312,-366.3201"/>
<text text-anchor="middle" x="122.9469" y="-377.8" font-family="Times,serif" font-size="14.00" fill="#000000">regular old analog phone lines</text>
</g>
<!-- switch1 -->
<g id="node4" class="node">
<title>switch1</title>
<ellipse fill="none" stroke="#000000" cx="232.4469" cy="-338" rx="39.7935" ry="18"/>
<text text-anchor="middle" x="232.4469" y="-334.3" font-family="Times,serif" font-size="14.00" fill="#000000">switch1</text>
</g>
<!-- ONT&#45;&gt;switch1 -->
<g id="edge3" class="edge">
<title>ONT&#45;&gt;switch1</title>
<path fill="none" stroke="#000000" d="M161.3356,-417.4274C177.4398,-411.836 197.0873,-402.7676 210.4469,-389 216.6533,-382.6041 221.2457,-374.1792 224.5808,-366.0238"/>
<polygon fill="#000000" stroke="#000000" points="227.9638,-366.9588 228.049,-356.3643 221.3756,-364.5932 227.9638,-366.9588"/>
<text text-anchor="middle" x="254.9469" y="-377.8" font-family="Times,serif" font-size="14.00" fill="#000000">vlan 34+35</text>
</g>
<!-- isp_router -->
<g id="node5" class="node">
<title>isp_router</title>
<ellipse fill="none" stroke="#000000" cx="185.4469" cy="-251" rx="48.1917" ry="18"/>
<text text-anchor="middle" x="185.4469" y="-247.3" font-family="Times,serif" font-size="14.00" fill="#000000">isp_router</text>
</g>
<!-- switch1&#45;&gt;isp_router -->
<g id="edge4" class="edge">
<title>switch1&#45;&gt;isp_router</title>
<path fill="none" stroke="#000000" d="M222.9358,-320.3943C216.354,-308.211 207.4705,-291.7669 200.0031,-277.9443"/>
<polygon fill="#000000" stroke="#000000" points="202.9377,-276.0128 195.1053,-268.8782 196.779,-279.34 202.9377,-276.0128"/>
<text text-anchor="middle" x="234.4469" y="-290.8" font-family="Times,serif" font-size="14.00" fill="#000000">vlan 34</text>
</g>
<!-- nixos_router -->
<g id="node6" class="node">
<title>nixos_router</title>
<ellipse fill="none" stroke="#000000" cx="309.4469" cy="-251" rx="57.6901" ry="18"/>
<text text-anchor="middle" x="309.4469" y="-247.3" font-family="Times,serif" font-size="14.00" fill="#000000">nixos_router</text>
</g>
<!-- switch1&#45;&gt;nixos_router -->
<g id="edge5" class="edge">
<title>switch1&#45;&gt;nixos_router</title>
<path fill="none" stroke="#000000" d="M247.2933,-321.2255C258.5766,-308.4769 274.2852,-290.7282 287.0869,-276.264"/>
<polygon fill="#000000" stroke="#000000" points="289.8465,-278.4269 293.8533,-268.6188 284.6047,-273.7875 289.8465,-278.4269"/>
<text text-anchor="middle" x="298.4469" y="-290.8" font-family="Times,serif" font-size="14.00" fill="#000000">vlan 35</text>
</g>
<!-- switch2 -->
<g id="node7" class="node">
<title>switch2</title>
<ellipse fill="none" stroke="#000000" cx="309.4469" cy="-178" rx="39.7935" ry="18"/>
<text text-anchor="middle" x="309.4469" y="-174.3" font-family="Times,serif" font-size="14.00" fill="#000000">switch2</text>
</g>
<!-- nixos_router&#45;&gt;switch2 -->
<g id="edge6" class="edge">
<title>nixos_router&#45;&gt;switch2</title>
<path fill="none" stroke="#000000" d="M309.4469,-232.9551C309.4469,-224.8828 309.4469,-215.1764 309.4469,-206.1817"/>
<polygon fill="#000000" stroke="#000000" points="312.947,-206.0903 309.4469,-196.0904 305.947,-206.0904 312.947,-206.0903"/>
</g>
<!-- dlink_ap -->
<g id="node8" class="node">
<title>dlink_ap</title>
<ellipse fill="none" stroke="#000000" cx="184.4469" cy="-105" rx="44.393" ry="18"/>
<text text-anchor="middle" x="184.4469" y="-101.3" font-family="Times,serif" font-size="14.00" fill="#000000">dlink_ap</text>
</g>
<!-- switch2&#45;&gt;dlink_ap -->
<g id="edge7" class="edge">
<title>switch2&#45;&gt;dlink_ap</title>
<path fill="none" stroke="#000000" d="M285.0489,-163.7516C266.1498,-152.7145 239.7343,-137.2878 218.7135,-125.0117"/>
<polygon fill="#000000" stroke="#000000" points="220.4729,-121.986 210.0725,-119.9653 216.9428,-128.0308 220.4729,-121.986"/>
</g>
<!-- nas -->
<g id="node9" class="node">
<title>nas</title>
<ellipse fill="none" stroke="#000000" cx="273.4469" cy="-105" rx="27" ry="18"/>
<text text-anchor="middle" x="273.4469" y="-101.3" font-family="Times,serif" font-size="14.00" fill="#000000">nas</text>
</g>
<!-- switch2&#45;&gt;nas -->
<g id="edge8" class="edge">
<title>switch2&#45;&gt;nas</title>
<path fill="none" stroke="#000000" d="M300.7323,-160.3287C296.4873,-151.7207 291.2934,-141.1886 286.5806,-131.6322"/>
<polygon fill="#000000" stroke="#000000" points="289.6433,-129.9292 282.0813,-122.5085 283.3652,-133.0253 289.6433,-129.9292"/>
</g>
<!-- c2d -->
<g id="node10" class="node">
<title>c2d</title>
<ellipse fill="none" stroke="#000000" cx="345.4469" cy="-105" rx="27" ry="18"/>
<text text-anchor="middle" x="345.4469" y="-101.3" font-family="Times,serif" font-size="14.00" fill="#000000">c2d</text>
</g>
<!-- switch2&#45;&gt;c2d -->
<g id="edge9" class="edge">
<title>switch2&#45;&gt;c2d</title>
<path fill="none" stroke="#000000" d="M318.1615,-160.3287C322.4066,-151.7207 327.6005,-141.1886 332.3132,-131.6322"/>
<polygon fill="#000000" stroke="#000000" points="335.5287,-133.0253 336.8126,-122.5085 329.2506,-129.9292 335.5287,-133.0253"/>
</g>
<!-- switch3 -->
<g id="node11" class="node">
<title>switch3</title>
<ellipse fill="none" stroke="#000000" cx="430.4469" cy="-105" rx="39.7935" ry="18"/>
<text text-anchor="middle" x="430.4469" y="-101.3" font-family="Times,serif" font-size="14.00" fill="#000000">switch3</text>
</g>
<!-- switch2&#45;&gt;switch3 -->
<g id="edge10" class="edge">
<title>switch2&#45;&gt;switch3</title>
<path fill="none" stroke="#000000" d="M333.3526,-163.5775C351.8311,-152.4294 377.605,-136.8798 397.9544,-124.6029"/>
<polygon fill="#000000" stroke="#000000" points="399.8365,-127.5551 406.5909,-119.3925 396.2204,-121.5614 399.8365,-127.5551"/>
</g>
<!-- laptop -->
<g id="node14" class="node">
<title>laptop</title>
<ellipse fill="none" stroke="#000000" cx="85.4469" cy="-18" rx="34.394" ry="18"/>
<text text-anchor="middle" x="85.4469" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">laptop</text>
</g>
<!-- dlink_ap&#45;&gt;laptop -->
<g id="edge13" class="edge">
<title>dlink_ap&#45;&gt;laptop</title>
<path fill="none" stroke="#000000" d="M165.8258,-88.636C150.4226,-75.0999 128.3776,-55.727 111.2692,-40.6923"/>
<polygon fill="#000000" stroke="#000000" points="113.1398,-37.6768 103.3178,-33.7047 108.519,-42.9349 113.1398,-37.6768"/>
<text text-anchor="middle" x="152.9469" y="-57.8" font-family="Times,serif" font-size="14.00" fill="#000000">wifi</text>
</g>
<!-- cellphone -->
<g id="node15" class="node">
<title>cellphone</title>
<ellipse fill="none" stroke="#000000" cx="184.4469" cy="-18" rx="46.5926" ry="18"/>
<text text-anchor="middle" x="184.4469" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">cellphone</text>
</g>
<!-- dlink_ap&#45;&gt;cellphone -->
<g id="edge14" class="edge">
<title>dlink_ap&#45;&gt;cellphone</title>
<path fill="none" stroke="#000000" d="M184.4469,-86.9735C184.4469,-75.1918 184.4469,-59.5607 184.4469,-46.1581"/>
<polygon fill="#000000" stroke="#000000" points="187.947,-46.0033 184.4469,-36.0034 180.947,-46.0034 187.947,-46.0033"/>
<text text-anchor="middle" x="195.9469" y="-57.8" font-family="Times,serif" font-size="14.00" fill="#000000">wifi</text>
</g>
<!-- tablet -->
<g id="node16" class="node">
<title>tablet</title>
<ellipse fill="none" stroke="#000000" cx="279.4469" cy="-18" rx="30.5947" ry="18"/>
<text text-anchor="middle" x="279.4469" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">tablet</text>
</g>
<!-- dlink_ap&#45;&gt;tablet -->
<g id="edge15" class="edge">
<title>dlink_ap&#45;&gt;tablet</title>
<path fill="none" stroke="#000000" d="M202.7639,-88.2255C217.684,-74.5619 238.8758,-55.1546 255.2019,-40.2033"/>
<polygon fill="#000000" stroke="#000000" points="257.7659,-42.6012 262.7769,-33.2663 253.0383,-37.4388 257.7659,-42.6012"/>
<text text-anchor="middle" x="249.9469" y="-57.8" font-family="Times,serif" font-size="14.00" fill="#000000">wifi</text>
</g>
<!-- amd -->
<g id="node12" class="node">
<title>amd</title>
<ellipse fill="none" stroke="#000000" cx="392.4469" cy="-18" rx="27" ry="18"/>
<text text-anchor="middle" x="392.4469" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">amd</text>
</g>
<!-- switch3&#45;&gt;amd -->
<g id="edge11" class="edge">
<title>switch3&#45;&gt;amd</title>
<path fill="none" stroke="#000000" d="M422.5733,-86.9735C417.2554,-74.7983 410.1419,-58.5122 404.1627,-44.8228"/>
<polygon fill="#000000" stroke="#000000" points="407.2613,-43.1727 400.0512,-35.4097 400.8465,-45.9746 407.2613,-43.1727"/>
</g>
<!-- raspberrypi -->
<g id="node13" class="node">
<title>raspberrypi</title>
<ellipse fill="none" stroke="#000000" cx="490.4469" cy="-18" rx="52.7911" ry="18"/>
<text text-anchor="middle" x="490.4469" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">raspberrypi</text>
</g>
<!-- switch3&#45;&gt;raspberrypi -->
<g id="edge12" class="edge">
<title>switch3&#45;&gt;raspberrypi</title>
<path fill="none" stroke="#000000" d="M442.301,-87.8116C450.8988,-75.3448 462.6817,-58.2596 472.4388,-44.1119"/>
<polygon fill="#000000" stroke="#000000" points="475.4094,-45.9692 478.2056,-35.75 469.6469,-41.9951 475.4094,-45.9692"/>
</g>
</g>
</svg>
  systemd.services = {
    network-vlans = {
      description = "network vlan-start";
      before = [ "network-pre.target" ];
      wantedBy = [ "network-pre.target" ];
      unitConfig.ConditionCapability = "CAP_NET_ADMIN";
      serviceConfig.Type = "oneshot";
      serviceConfig.RemainAfterExit = true;
      path = [ pkgs.vlan pkgs.iproute ];
      script = ''
        ip link set ${WANMASTER} address a8:39:44:90:30:3a
        vconfig add ${WANMASTER} 34 || true
        vconfig set_egress_map ${WANMASTER}.34 0 4 || true
        vconfig add ${WANMASTER} 35 || true
        ip link set ${WANMASTER} up
      '';
    };
  };

a custom systemd service to bring up the 2 vlans

iptables -w -t nat -A nixos-nat-post -s 192.168.2.0/24 -o ${WANMASTER}.34 -j MASQUERADE

this was to configure a second NAT on the IPTV uplink, since the OS only supports 1 uplink NAT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment