Asterisk@Home Modified to Act as a Firewall, Router, Gateway, DHCP Server and DNS Server

  1. General Information
    1. Minimum Requirements
      1. Two Ethernet cards
      2. Ethernet Switch or Hub
    2. Based On
      1. WAN (Internet connection)
        1. Interface = eth0
        2. Dynamic IP (DHCP)
      2. LAN
        1. Interface = eth1
        2. Firewall (Asterisk Box) IP = 192.168.1.254
        3. DHCP Server
        4. DHCP Clients Range = From 192.168.1.100 To 192.168.1.199
      3. NAT
        1. One to Many
    3. Legend
      1.             Code / Command
      2.             File
      3.             rpm Package
      4. RED TEXT    User specific
  2. Packages Added to the Original Distribution
    1. DNS Server - bind (bind-9.2.4-2.i386.rpm )
      1. Changes to conf files
        1. /etc/named.conf
          1. Added
            1. zone "asterisk.local" {
            2.   type master;
            3.   file "/var/named/asterisk.local.hosts";
            4. };
        2. Added file /var/named/asterisk.local.hosts
    2. Firewall (iptables add-on) -  Shorewall (shorewall-3.0.6-1.noarch.rpm)
      1. Changes to conf files (/etc/shorewall)
        1. policy
          1. Change to ACCEPT and remove info
            1. loc   $FW   REJECT   info
            2. loc   all   REJECT   info
            3. $FW   net   REJECT   info
            4. $FW   loc   REJECT   info
            5. $FW   all   REJECT   info
        2. rules
          1. Added
            1. # Asterisk
            2. # Allow IAX2, SIP and RTP To Firewall
            3. ACCEPT:info       net   $FW   udp   4569,5060:5061,10000:20000
        3. shorewall.conf
          1. Change STARTUP_ENABLED=No to STARTUP_ENABLED=Yes
        4. tcdevices
          1. Added
            1. eth0   5500kbit   550kbit
        5. tcclasses
          1. Added
            1. eth0   1   full        full        1   tos-minimize-delay
            2. eth0   2   full        full        2
            3. eth0   3   9*full/10   9*full/10   3   default
            4. eth0   4   8*full/10   8*full/10   4
            5. eth0   5   4kbit       4kbit       5
        6. tcrules
          1. Added
            1. 1:P   0.0.0.0/0 0.0.0.0/0   icmp   echo-request
            2. 1:P   0.0.0.0/0 0.0.0.0/0   icmp   echo-reply
            3. # VOIP Ports
            4. 1:P   0.0.0.0/0 0.0.0.0/0   udp    4569,5060:5061,10000:20000
            5. # Low priority Destination Ports
            6. 4     0.0.0.0/0 0.0.0.0/0   tcp    25,22,110,143,943
            7. 4     0.0.0.0/0 0.0.0.0/0   udp    25,22,110,143,943
            8. # Low priority Source Ports
            9. 4     0.0.0.0/0 0.0.0.0/0   tcp    -      25,22,110,143,943
            10. 4     0.0.0.0/0 0.0.0.0/0   udp    -      25,22,110,143,943
    3. syslog Enhancemet - syslog-ng (syslog-ng-1.6.9-1.el4.kb.i386.rpm)
      1. Changes to etc/syslog-ng/syslog-ng.conf
        1. create_dirs (yes)
        2. Added to filter f_filter2
          1. and not (program("syslog-ng") and match("STATS: dropped 0"))
          2. and not program("php")
          3. and not program("named")
          4. and not program("ntpd")
          5. and not program("dhcpd")
          6. and not program("dhclient")
          7. and not program("shorewall")
          8. and not program("S-1shorewall")
          9. and not match("kernel: Shorewall")
          10. and not program("sshd")
        3. Added
          1. # Asterisk
          2. # PHP
          3. destination d_php { file("/var/log/php/$YEAR/$MONTH/$YEAR-$MONTH-$DAY"); };
          4. filter f_filter9 { program("php"); };
          5. log { source(s_sys); filter(f_filter9); destination(d_php); };
          6. # DHCP
          7. destination d_dhcp { file("/var/log/dhcp/$YEAR/$MONTH/$YEAR-$MONTH-$DAY"); };
          8. filter f_filter10 { program("dhcpd") or program("dhclient"); };
          9. log { source(s_sys); filter(f_filter10); destination(d_dhcp); };
          10. # Shorewall
          11. destination d_swapp { file("/var/log/shorewall/shorewall/$YEAR/$MONTH/$YEAR-$MONTH-$DAY"); };
          12. destination d_swtrfc { file("/var/log/shorewall/traffic/$YEAR/$MONTH/$YEAR-$MONTH-$DAY"); };
          13. filter f_filter11 { program("shorewall") and program("S-1shorewall"); };
          14. filter f_filter12 { match("kernel: Shorewall"); };
          15. log { source(s_sys); filter(f_filter11); destination(d_swapp); };
          16. log { source(s_sys); filter(f_filter12); destination(d_swtrfc); };
          17. # SSH
          18. destination d_ssh { file("/var/log/ssh/$YEAR/$MONTH/$YEAR-$MONTH-$DAY"); };
          19. filter f_filter13 { program("sshd"); };
          20. log { source(s_sys); filter(f_filter13); destination(d_ssh); };
          21. # ntpd
          22. destination d_ntpd { file("/var/log/ntpd/$YEAR/$MONTH/$YEAR-$MONTH-$DAY"); };
          23. filter f_filter14 { program("ntpd"); };
          24. log { source(s_sys); filter(f_filter14); destination(d_ntpd); };
          25. # Named
          26. destination d_named { file("/var/log/named/$YEAR/$MONTH/$YEAR-$MONTH-$DAY"); };
          27. filter f_filter15 { program("named"); };
          28. log { source(s_sys); filter(f_filter15); destination(d_named); };
  3. Packages installed from the original distribution
    1. DHCP Server (installed via setup-dhcp)
      1. Changes to /etc/dhcpd.conf
        1. option routers 192.168.1.254;
        2. option domain-name-servers 192.168.1.254;
        3. range dynamic-bootp 192.168.1.100 192.168.1.199;
        4. option time-offset -28800; # Pacific Standard Time
        5. option ntp-servers 192.168.1.254;
        6. option tftp-server-name "192.168.1.254";
  4. Original Package Modifications (asteriskathome.tar.gz
    1. install_parts.sh and install_parts_sme.sh
      1. Added Befor Post Install Section
        1. echo "*******************************************"
        2. echo "** Install Gateway ************************"
        3. echo "*******************************************"
        4. GWFiles=/var/aah_load/gw
        5. echo "-------------------------------------------"
        6. echo "Setup Network Cards"
        7. echo "-------------------------------------------"
        8. netconfig --device=eth0 --bootproto=dhcp
        9. netconfig --device=eth1 --ip=192.168.1.254 --netmask=255.255.255.0
        10. echo "-------------------------------------------"
        11. echo "Installing DNS Server (bind - named)"
        12. echo "-------------------------------------------"
        13. cd $GWFiles/bind
        14. rpm -vih bind-9.2.4-2.i386.rpm
        15. mv -vf asterisk.local.hosts /var/named
        16. mv -vf named.conf /etc
        17. chkconfig named on
        18. echo "-------------------------------------------"
        19. echo "Installing Shorewall"
        20. echo "-------------------------------------------"
        21. cd $GWFiles/shorewall
        22. rpm -vih shorewall-3.0.6-1.noarch.rpm
        23. mv -vf /usr/share/doc/packages/shorewall/Samples/two-interfaces/* /etc/shorewall
        24. rm -vf shorewall-3.0.6-1.noarch.rpm
        25. mv -vf * /etc/shorewall
        26. echo "-------------------------------------------"
        27. echo "Installing syslog-ng"
        28. echo "-------------------------------------------"
        29. cd $GWFiles/syslog-ng
        30. rpm -vih syslog-ng-1.6.9-1.el4.kb.i386.rpm
        31. chkconfig syslog off
        32. chkconfig syslog-ng on
        33. mv -vf syslog-ng.conf /etc/syslog-ng
        34. echo "-------------------------------------------"
        35. echo "Installing DHCP Server"
        36. echo "-------------------------------------------"
        37. cd $GWFiles/dhcp
        38. setup-dhcp
        39. mv -vf dhcpd.conf /etc
        40. echo "*******************************************"
        41. echo "** Finish Gateway Installation ************"
        42. echo "*******************************************"
  5. User Modification