Changes between Version 5 and Version 6 of FreeBSDXS4ALLFTTH


Ignore:
Timestamp:
06/14/17 20:41:46 (7 years ago)
Author:
Rick van der Zwet
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FreeBSDXS4ALLFTTH

    v5 v6  
    11The Fritz!Box 7390 has issues with VAS and icmp forwarding, secondly I feel like the performance of the router is not meeting it's expections, yet no verification possible yet. Hence the switch to a FreeBSD based router/setup. First of all homework. Read [https://www.xs4all.nl/service/diensten/internet/installeren/modem-instellen/hoe-kan-ik-een-ander-modem-dan-fritzbox-instellen.htm the XS4ALL recommendations] and some good reading of Roel Traag [https://mijnglasvezelverbinding.nl/tv-internet-over-dezelfde-netwerkkabel/ part 1] and [https://mijnglasvezelverbinding.nl/tp-link-tl-sg3210-mac-vlan-configuratie/ part 2]. Cisco examples at [https://kpn.gebruikers.eu/forum/viewthread.php?thread_id=3899 KPN forum]. Improvements; use [https://bsdrp.net/documentation/examples/multicast_with_pim-sm PIM] to make to more clean.
     2
     3file:/etc/dhclient.conf
     4{{{
     5interface "re0vlan4" {
     6        request routers,classless-routes;
     7        send dhcp-class-identifier "IPTV_RG";
     8}
     9}}}
     10
     11
     12file:/etc/rc.conf
     13{{{
     14hostname="routerZW.vanderzwet.net"
     15sshd_enable="YES"
     16
     17gateway_enable="YES"
     18ipv6_gateway_enable="YES"
     19ipv6_cpe_wanif="ng0"
     20
     21
     22ifconfig_re0="up -wol -arp"
     23vlans_re0="re0vlan4 re0vlan6"
     24create_args_re0vlan4="vlan 4"
     25create_args_re0vlan6="vlan 6 -arp"
     26
     27# IPTV VLAN
     28ifconfig_re0vlan4="DHCP"
     29
     30# Internet VLAN
     31ifconfig_re0_ipv6="inet6 ifdisabled -nud -auto_linklocal -accept_rtadv"
     32ifconfig_re0vlan6_ipv6="inet6 ifdisabled -nud -auto_linklocal -accept_rtadv"
     33
     34# Wireless Leiden
     35ifconfig_re1="172.17.107.20/24"
     36
     37# Local Area Network
     38ifconfig_re2="192.168.178.1/24"
     39ifconfig_re2_alias0="80.127.152.25/29"
     40ifconfig_re2_ipv6="inet6 2001:984:ac89:ffff::1"
     41
     42# Routing Wireless Leiden
     43static_routes="wleiden"
     44route_wleiden="-net 172.16.0.0/12 172.17.107.1"
     45
     46# PPPoE Tunnel for INET
     47mpd_enable="YES"
     48
     49# DHCP for IPv6 (started via mpd5 - linkup script)
     50dhcp6c_enable="NO"
     51dhcp6c_interfaces="ng0"
     52
     53# IPv6 on LAN
     54rtadvd_enable="YES"
     55rtadvd_interfaces="re2"
     56
     57# IPv6 on WAN
     58rtsold_enable="YES"
     59
     60# IPv4 on LAN
     61dhcpd_enable="YES"
     62dhcpd_ifaces="re2"
     63
     64# Firewall ACL
     65firewall_type="open"
     66firewall_enable="YES"
     67firewall_script="/etc/firewall.sh"
     68
     69# NAT for LAN
     70natd_enable="YES"
     71natd_flags="-f /etc/natd.conf"
     72
     73# IPTV Multicast proxy
     74igmpproxy_enable="YES"
     75
     76# Caching DNS Server
     77unbound_enable="YES"
     78}}}
     79
     80
     81file:/boot/loader.conf
     82{{{
     83# Force output to run trough the comconsole, no exceptions
     84console="comconsole"
     85
     86# PC Engines Alix APU board default serial settings cannot changed so 115200 it is.
     87comconsole_speed="115200"
     88
     89ip_mroute_load="YES"
     90}}}
     91
     92file:/usr/local/etc/mpd5/linkup.sh
     93{{{
     94#!/bin/sh
     95#
     96
     97test -z "$1" && exit 1
     98
     99if [ "$2" = "inet" ]
     100then
     101        /usr/bin/renice -n -5 $PPID
     102fi
     103
     104if [ "$2" = "inet6" ]
     105then
     106        /sbin/ifconfig "$1" inet6 accept_rtadv -nud -no_radr
     107        (sleep 3; /usr/local/etc/rc.d/dhcp6c onerestart) &
     108
     109
     110fi
     111
     112exit 0
     113}}}
     114
     115file:/usr/local/etc/mpd5/linkdown.sh
     116{{{
     117#!/bin/sh
     118#
     119
     120test -z "$1" && exit 1
     121
     122if [ "$2" = "inet" ]
     123then
     124        /usr/bin/renice -n +5 $PPID
     125fi
     126
     127if [ "$2" = "inet6" ]
     128then
     129        /usr/local/etc/rc.d/dhcp6c stop
     130fi
     131}}}
     132
     133file:/usr/local/etc/mpd5/mpd.conf
     134{{{
     135startup:
     136        # configure mpd users
     137        set user foo bar admin
     138        set user foo1 bar1
     139        # configure the console
     140        set console self 127.0.0.1 5005
     141        set console open
     142        # configure the web server
     143        set web self 0.0.0.0 5006
     144        set web open
     145
     146#
     147# Default configuration is "dialup"
     148
     149default:
     150        load pppoe_client
     151
     152pppoe_client:
     153#
     154# PPPoE client: only outgoing calls, auto reconnect,
     155# ipcp-negotiated address, one-sided authentication,
     156# default route points on ISP's end
     157#
     158
     159        create bundle static B1
     160        set iface   up-script /usr/local/etc/mpd5/linkup.sh
     161        set iface down-script /usr/local/etc/mpd5/linkdown.sh
     162        set ipcp ranges 0.0.0.0/0 0.0.0.0/0
     163        set bundle enable ipv6cp
     164        set iface route default
     165        load nat
     166
     167
     168        create link static P1 pppoe
     169        set link action bundle B1
     170        set link latency 1200
     171        set link bandwidth 100000000
     172        set link max-redial 0
     173        set link keep-alive 10 60
     174        #set link mtu 1492
     175        #set ppooe max-payload 1500
     176
     177        set auth authname FB7490@xs4all.nl
     178        set auth password FB7490
     179
     180        set pppoe iface re0vlan6
     181        set pppoe service ""
     182        open
     183}}}
     184
     185file:/etc/rtadvd.conf
     186{{{
     187re2:\
     188        :addr="2001:984:ac89:ffff::":prefixlen#64:\
     189        :rdnss="2001:984:ac89:ffff::1":\
     190        :dnssl="vanderzwet.net":
     191}}}
     192
     193file:/usr/local/etc/dhcpd.conf
     194{{{
     195default-lease-time 600;
     196max-lease-time 7200;
     197
     198authoritative;
     199
     200log-facility local7;
     201
     202subnet 192.168.178.0 netmask 255.255.255.0 {
     203  range 192.168.178.50 192.168.178.200;
     204  option routers 192.168.178.1;
     205  option domain-name "thuis.vanderzwet.net";
     206  option domain-name-servers 192.168.178.1;
     207  option vendor-class-identifier "IPTV_RG";
     208  option broadcast-address 192.168.178.255;
     209}
     210}}}
     211
     212file:/usr/local/etc/unbound.conf
     213{{{
     214
     215server:
     216
     217        verbosity: 1
     218
     219        interface: 127.0.0.1
     220        interface: ::1
     221        interface: 192.168.178.1
     222        interface: 2001:984:ac89:ffff::1
     223        interface: 172.17.107.20
     224
     225        access-control: 192.168.178.0/24 allow
     226        access-control: 172.16.0.0/12 allow
     227        access-control: 2001:984:ac89::/48 allow
     228
     229       
     230
     231python:
     232
     233remote-control:
     234
     235include: /usr/local/etc/unbound/forward.conf
     236include: /usr/local/etc/unbound/lan-zones.conf
     237
     238}}}
     239
     240file:/etc/resolv.conf
     241{{{
     242search vanderzwet.net
     243nameserver 127.0.0.1
     244
     245nameserver 194.109.6.66
     246nameserver 194.109.9.99
     247nameserver 194.109.104.104
     248nameserver 2001:888:0:6::66
     249nameserver 2001:888:0:9::99
     250}}}
     251
     252file:/etc/firewall.sh
     253{{{
     254case ${firewall_type} in
     255[Oo][Pp][Ee][Nn]|[Cc][Ll][Ii][Ee][Nn][Tt])
     256        case ${natd_enable} in
     257        [Yy][Ee][Ss])
     258                ${fwcmd} add 50 divert natd ip4 from not 80.127.152.25/29 to not 80.127.152.25/29 via ng0
     259
     260                ${fwcmd} add 51 divert 8669 ip4 from 10.201.184.0/22 to me via re0vlan4
     261                ${fwcmd} add 51 divert 8669 ip4 from 192.168.178.0/24 to 10.201.184.0/22 via re0vlan4
     262
     263                ${fwcmd} add 51 divert 8669 ip4 from 192.168.178.0/24 to 213.75.112.0/21 via re0vlan4
     264                ${fwcmd} add 51 divert 8669 ip4 from 213.75.112.0/21 to me via re0vlan4
     265
     266                ${fwcmd} add 52 divert 8670 ip4 from 192.168.178.0/24 to 172.16.0.0/12 out via re1
     267                ${fwcmd} add 52 divert 8670 ip4 from 172.16.0.0/12 to me in via re1
     268
     269                ;;
     270        esac
     271
     272        # Allow DHCPv6
     273        ${fwcmd} add pass udp from fe80::/10 to me 546
     274
     275        # Allow TCP through if setup succeeded
     276        ${fwcmd} add pass tcp from any to any established
     277        ${fwcmd} add pass ipv6 from any to any established
     278
     279        # Allow IP fragments to pass through
     280        ${fwcmd} add pass all from any to any frag
     281
     282        # Wireless Leiden Special
     283        ${fwcmd} add pass tcp from any to 80.127.152.27/32 dst-port 9000-9100 in via ng0 setup
     284
     285        # Allow setup of incoming TCP stuff to VAS
     286        for i in 25 53 80 443 465 993 1022; do
     287                ${fwcmd} add pass tcp from any to 80.127.152.24/29 dst-port ${i} in via ng0 setup
     288                ${fwcmd} add pass ip6 from any to 2001:984:ac89::/48 dst-port ${i} in via ng0 setup proto tcp
     289        done
     290        # Allow setup of incoming UDP stuff to VAS
     291        for i in 53 123; do
     292                ${fwcmd} add pass udp from any to 80.127.152.24/29 dst-port ${i} in via ng0
     293                ${fwcmd} add pass ip6 from any to 2001:984:ac89::/48 dst-port ${i} in via ng0 proto udp
     294        done
     295
     296        # TCP Access to Router
     297        for i in 1022; do
     298                ${fwcmd} add pass tcp from any to me dst-port ${i} in via ng0 setup
     299                ${fwcmd} add pass ip6 from any to me dst-port ${i} in via ng0 setup proto tcp
     300        done
     301
     302        # Allow UDP on VAS
     303        ${fwcmd} add check-state
     304        ${fwcmd} add pass udp from 80.127.152.24/29 to any out via ng0 proto udp keep-state
     305        ${fwcmd} add pass ip6 from 2001:984:ac89::/48 to any out via ng0 proto udp keep-state
     306
     307        # Allow UDP on Router
     308        ${fwcmd} add pass udp from me to any out via ng0 proto udp keep-state
     309        ${fwcmd} add pass ip6 from me to any out via ng0 proto udp keep-state
     310
     311        # Reject&Log all setup of incoming connections from the outside
     312        ${fwcmd} add deny log ip4 from any to 80.127.152.24/29 in via ng0 setup proto tcp
     313        ${fwcmd} add deny log ip4 from any to 80.127.152.24/29 in via ng0 proto udp
     314        ${fwcmd} add deny log ip6 from any to 2001:984:ac89::/48 in via ng0 setup proto tcp
     315        ${fwcmd} add deny log ip6 from any to 2001:984:ac89::/48 in via ng0 proto udp
     316
     317        # Access limit to Router
     318        ${fwcmd} add deny log ip4 from any to me in via ng0 setup proto tcp
     319        ${fwcmd} add deny log ip4 from any to me in via ng0 proto udp
     320        ${fwcmd} add deny log ip6 from any to me in via ng0 setup proto tcp
     321        ${fwcmd} add deny log ip6 from any to me in via ng0 proto udp
     322
     323        # Allow setup of any other TCP connection
     324        ${fwcmd} add pass tcp from any to any setup
     325
     326        # Allow DNS queries out in the world
     327        #${fwcmd} add pass udp from me to any 53 keep-state
     328
     329        # Allow NTP queries out in the world
     330        #${fwcmd} add pass udp from me to any 123 keep-state
     331
     332        # Everything else is denied by default, unless the
     333        # IPFIREWALL_DEFAULT_TO_ACCEPT option is set in your kernel
     334        # config file.
     335        case ${firewall_nat_enable} in
     336        [Yy][Ee][Ss])
     337                if [ -n "${firewall_nat_interface}" ]; then
     338                        if echo "${firewall_nat_interface}" | \
     339                                grep -q -E '^[0-9]+(\.[0-9]+){0,3}$'; then
     340                                firewall_nat_flags="ip ${firewall_nat_interface} ${firewall_nat_flags}"
     341                        else
     342                                firewall_nat_flags="if ${firewall_nat_interface} ${firewall_nat_flags}"
     343                        fi
     344                        ${fwcmd} nat 123 config log ${firewall_nat_flags}
     345                        ${fwcmd} add 50 nat 123 ip4 from any to any via ${firewall_nat_interface}
     346                fi
     347                ;;
     348        esac
     349esac
     350}}}