Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Tikimotel

#1
I have a mini itx motherboard that I use for Opnsense.
It has a intel Avoton (Atom) CPU.
However the powerd settings don't seem to have an effect on CPU temperatures. (remained at ~45°C for all Cores)

I did some investigation and it seems there are just a few settings missing from the GUI and a conf file.

powerd -v (from the command-line)
Quote
powerd: unable to determine AC line status <=== Important for "-n" option of powerd !!!
load  10%, current freq 1200 MHz (13), wanted freq 1200 MHz
load   6%, current freq 1200 MHz (13), wanted freq 1200 MHz
load   8%, current freq 1200 MHz (13), wanted freq 1200 MHz
load  10%, current freq 1200 MHz (13), wanted freq 1200 MHz
load   6%, current freq 1200 MHz (13), wanted freq 1200 MHz
However the normal option is not influenced or changeable from the GUI, but it is stored as "hadp" when empty.
Hiadaptive is not bad, but it could be better (greener).

powerd manpage:
Quote
     -n   mode    Selects the mode to use normally when the AC line state is
       unknown.

So I looked at the C-states of my machine, C1 and C2 are supported.
It always stayed in C1 becasue of the defaults.
The clockspeed would move down, but nothing significant in temperatures.

So I ran a search for powerd, and came across this wiki.
https://wiki.freebsd.org/TuningPowerConsumption

(/etc/rc.conf):
Quote
performance_cx_lowest="Cmax"
economy_cx_lowest="Cmax"

Replace "Cmax" with what is supported by your machine, but the hardware will do what it can to get to the highest C-state possible on your machine.
I tested this, with "Cmax" and "C8" is what is determined by freebsd, but my hardware only supports "C2".
Using "C2" is relatively safe, higher level C-states might not be ideal for more production level environments.
For instance "C3" is turning off cores, "C3" might work might not work or you might loose too much responsiveness, But hey it's router not a laptop. C-state "C2" will do fine.

So I added "/etc/rc.conf" with "C2" to my config and rebooted my machine.

et voilá, CPU core temperatures dropped to ~39°C, a nice drop from 45°C.

Solving the undetermined power state option:

/usr/local/www/system_advanced_misc.php
first part is to define the default state of the three powerd options.

  • powerd_ac_mode (tidy this a bit, to be nearer to it's own code, with some remarks added)
  • powerd_battery_mode
  • powerd_normal_mode (missing!!!, and needed for when AC can not be determined)
OLD  @ ~ line 105

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    $pconfig = array();
    $pconfig['powerd_enable'] = isset($config['system']['powerd_enable']);
    $pconfig['crypto_hardware'] = !empty($config['system']['crypto_hardware']) ? $config['system']['crypto_hardware'] : null;
    $pconfig['cryptodev_enable'] = isset($config['system']['cryptodev_enable']);
    $pconfig['thermal_hardware'] = !empty($config['system']['thermal_hardware']) ? $config['system']['thermal_hardware'] : null;
    $pconfig['use_mfs_tmpvar'] = isset($config['system']['use_mfs_tmpvar']);
    $pconfig['use_mfs_tmp'] = isset($config['system']['use_mfs_tmp']);
    $pconfig['powerd_ac_mode'] = "hadp";
    $pconfig['rrdbackup'] = !empty($config['system']['rrdbackup']) ? $config['system']['rrdbackup'] : null;
    $pconfig['dhcpbackup'] = !empty($config['system']['dhcpbackup']) ? $config['system']['dhcpbackup'] : null;
    $pconfig['netflowbackup'] = !empty($config['system']['netflowbackup']) ? $config['system']['netflowbackup'] : null;
    if (!empty($config['system']['powerd_ac_mode'])) {
        $pconfig['powerd_ac_mode'] = $config['system']['powerd_ac_mode'];
    }
    $pconfig['powerd_battery_mode'] = "hadp";
    if (!empty($config['system']['powerd_battery_mode'])) {
        $pconfig['powerd_battery_mode'] = $config['system']['powerd_battery_mode'];
    }

NEW

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    $pconfig = array();
    $pconfig['powerd_enable'] = isset($config['system']['powerd_enable']);
    $pconfig['crypto_hardware'] = !empty($config['system']['crypto_hardware']) ? $config['system']['crypto_hardware'] : null;
    $pconfig['cryptodev_enable'] = isset($config['system']['cryptodev_enable']);
    $pconfig['thermal_hardware'] = !empty($config['system']['thermal_hardware']) ? $config['system']['thermal_hardware'] : null;
    $pconfig['use_mfs_tmpvar'] = isset($config['system']['use_mfs_tmpvar']);
    $pconfig['use_mfs_tmp'] = isset($config['system']['use_mfs_tmp']);
    $pconfig['rrdbackup'] = !empty($config['system']['rrdbackup']) ? $config['system']['rrdbackup'] : null;
    $pconfig['dhcpbackup'] = !empty($config['system']['dhcpbackup']) ? $config['system']['dhcpbackup'] : null;
    $pconfig['netflowbackup'] = !empty($config['system']['netflowbackup']) ? $config['system']['netflowbackup'] : null;
// define powerd default or saved state(s) from the systemconfig
    $pconfig['powerd_ac_mode'] = "hadp";
    if (!empty($config['system']['powerd_ac_mode'])) {
        $pconfig['powerd_ac_mode'] = $config['system']['powerd_ac_mode'];
    }
    $pconfig['powerd_battery_mode'] = "hadp";
    if (!empty($config['system']['powerd_battery_mode'])) {
        $pconfig['powerd_battery_mode'] = $config['system']['powerd_battery_mode'];
    }
    $pconfig['powerd_normal_mode'] = "hadp";
    if (!empty($config['system']['powerd_normal_mode'])) {
        $pconfig['powerd_battery_mode'] = $config['system']['powerd_normal_mode'];
    }

The second parts are to create a copy of the normal state option for the three powerd options in the GUI.
And add a help text, for when normal mode is used by powerd.
OLD @ ~ line 111

    if (count($input_errors) == 0) {
        if (!empty($pconfig['powerd_enable'])) {
            $config['system']['powerd_enable'] = true;
        } elseif (isset($config['system']['powerd_enable'])) {
            unset($config['system']['powerd_enable']);
        }

        $config['system']['powerd_ac_mode'] = $pconfig['powerd_ac_mode'];
        $config['system']['powerd_battery_mode'] = $pconfig['powerd_battery_mode'];

NEW

    if (count($input_errors) == 0) {
        if (!empty($pconfig['powerd_enable'])) {
            $config['system']['powerd_enable'] = true;
        } elseif (isset($config['system']['powerd_enable'])) {
            unset($config['system']['powerd_enable']);
        }

        $config['system']['powerd_ac_mode'] = $pconfig['powerd_ac_mode'];
        $config['system']['powerd_battery_mode'] = $pconfig['powerd_battery_mode'];
        $config['system']['powerd_normal_mode'] = $pconfig['powerd_normal_mode'];


OLD @ ~ line 339

              <tr>
                <td><a id="help_for_powerd_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Use PowerD"); ?></td>
                <td>
                  <input name="powerd_enable" type="checkbox" id="powerd_enable" value="yes" <?=!empty($pconfig['powerd_enable']) ? "checked=\"checked\"" : "";?> />
                  <div class="hidden" for="help_for_powerd_enable">
                    <?=gettext("The powerd utility monitors the system state and sets various power control " .
                                        "options accordingly. It offers four modes (maximum, minimum, adaptive " .
                                        "and hiadaptive) that can be individually selected while on AC power or batteries. " .
                                        "The modes maximum, minimum, adaptive and hiadaptive may be abbreviated max, " .
                                        "min, adp, hadp. Maximum mode chooses the highest performance values. Minimum " .
                                        "mode selects the lowest performance values to get the most power savings. " .
                                        "Adaptive mode attempts to strike a balance by degrading performance when " .
                                        "the system appears idle and increasing it when the system is busy. It " .
                                        "offers a good balance between a small performance loss for greatly " .
                                        "increased power savings. Hiadaptive mode is alike adaptive mode, but " .
                                        "tuned for systems where performance and interactivity are more important " .
                                        "than power consumption. It raises frequency faster, drops slower and " .
                                        "keeps twice lower CPU load."); ?>
                  </div>
                </td>
              </tr>
              <tr>
                <td><i class="fa fa-info-circle text-muted"></i>  <?=gettext('On AC Power Mode') ?></td>
                <td>
                  <select name="powerd_ac_mode" class="selectpicker" data-style="btn-default" data-width="auto">
                    <option value="hadp" <?=$pconfig['powerd_ac_mode']=="hadp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Hiadaptive");?>
                    </option>
                    <option value="adp" <?=$pconfig['powerd_ac_mode']=="adp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Adaptive");?>
                    </option>
                    <option value="min" <?=$pconfig['powerd_ac_mode']=="min" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Minimum");?>
                    </option>
                    <option value="max" <?=$pconfig['powerd_ac_mode']=="max" ? " selected=\"selected\"" : "";?>>
                      <?=gettext("Maximum");?>
                    </option>
                  </select>
                </td>
              <tr>
                <td><i class="fa fa-info-circle text-muted"></i>  <?=gettext('On Battery Power Mode') ?></td>
                <td>
                  <select name="powerd_battery_mode" class="selectpicker" data-style="btn-default" data-width="auto">
                    <option value="hadp"<?=$pconfig['powerd_battery_mode']=="hadp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Hiadaptive");?>
                    </option>
                    <option value="adp" <?=$pconfig['powerd_battery_mode']=="adp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Adaptive");?>
                    </option>
                    <option value="min" <?=$pconfig['powerd_battery_mode']=="min" ? "selected=\"selected\"" :"";?>>
                      <?=gettext("Minimum");?>
                    </option>
                    <option value="max" <?=$pconfig['powerd_battery_mode']=="max" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Maximum");?>
                    </option>
                  </select>
                </td>
              </tr>

NEW

              <tr>
                <td><a id="help_for_powerd_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Use PowerD"); ?></td>
                <td>
                  <input name="powerd_enable" type="checkbox" id="powerd_enable" value="yes" <?=!empty($pconfig['powerd_enable']) ? "checked=\"checked\"" : "";?> />
                  <div class="hidden" for="help_for_powerd_enable">
                    <?=gettext("The powerd utility monitors the system state and sets various power control " .
                                        "options accordingly. It offers four modes (maximum, minimum, adaptive " .
                                        "and hiadaptive) that can be individually selected while on AC power or batteries. " .
                                        "The modes maximum, minimum, adaptive and hiadaptive may be abbreviated max, " .
                                        "min, adp, hadp. Maximum mode chooses the highest performance values. Minimum " .
                                        "mode selects the lowest performance values to get the most power savings. " .
                                        "Adaptive mode attempts to strike a balance by degrading performance when " .
                                        "the system appears idle and increasing it when the system is busy. It " .
                                        "offers a good balance between a small performance loss for greatly " .
                                        "increased power savings. Hiadaptive mode is alike adaptive mode, but " .
                                        "tuned for systems where performance and interactivity are more important " .
                                        "than power consumption. It raises frequency faster, drops slower and " .
                                        "keeps twice lower CPU load."); ?>
                  </div>
                </td>
              </tr>
              <tr>
                <td><i class="fa fa-info-circle text-muted"></i>  <?=gettext('On AC Power Mode') ?></td>
                <td>
                  <select name="powerd_ac_mode" class="selectpicker" data-style="btn-default" data-width="auto">
                    <option value="hadp" <?=$pconfig['powerd_ac_mode']=="hadp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Hiadaptive");?>
                    </option>
                    <option value="adp" <?=$pconfig['powerd_ac_mode']=="adp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Adaptive");?>
                    </option>
                    <option value="min" <?=$pconfig['powerd_ac_mode']=="min" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Minimum");?>
                    </option>
                    <option value="max" <?=$pconfig['powerd_ac_mode']=="max" ? " selected=\"selected\"" : "";?>>
                      <?=gettext("Maximum");?>
                    </option>
                  </select>
                </td>
              <tr>
                <td><i class="fa fa-info-circle text-muted"></i>  <?=gettext('On Battery Power Mode') ?></td>
                <td>
                  <select name="powerd_battery_mode" class="selectpicker" data-style="btn-default" data-width="auto">
                    <option value="hadp"<?=$pconfig['powerd_battery_mode']=="hadp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Hiadaptive");?>
                    </option>
                    <option value="adp" <?=$pconfig['powerd_battery_mode']=="adp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Adaptive");?>
                    </option>
                    <option value="min" <?=$pconfig['powerd_battery_mode']=="min" ? "selected=\"selected\"" :"";?>>
                      <?=gettext("Minimum");?>
                    </option>
                    <option value="max" <?=$pconfig['powerd_battery_mode']=="max" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Maximum");?>
                    </option>
                  </select>
                </td>
              </tr>
                <td><a id="help_for_powerd_normal_mode" href="#" class="showhelp"><i class="fa fa-info-circle text-circle"></i></a>  <?=gettext('On Normal Power Mode'); ?></td>
                <td>
                  <select name="powerd_normal_mode" class="selectpicker" data-style="btn-default" data-width="auto">
                    <option value="hadp"<?=$pconfig['powerd_normal_mode']=="hadp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Hiadaptive");?>
                    </option>
                    <option value="adp" <?=$pconfig['powerd_normal_mode']=="adp" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Adaptive");?>
                    </option>
                    <option value="min" <?=$pconfig['powerd_normal_mode']=="min" ? "selected=\"selected\"" :"";?>>
                      <?=gettext("Minimum");?>
                    </option>
                    <option value="max" <?=$pconfig['powerd_normal_mode']=="max" ? "selected=\"selected\"" : "";?>>
                      <?=gettext("Maximum");?>
                    </option>
                  </select>
<div class="hidden" for="help_for_powerd_normal_mode">
                <?=gettext("If the powerd utility can not determine the power state it uses \"normal\" for control."); ?>
                </div>
                </td>
              </tr>

#2
I Follow the TechSNAP show on jupiterbroadcasting/youtube.
http://www.jupiterbroadcasting.com/100526/apple-pretend-filesystem-techsnap-271/

news story:
http://news.softpedia.com/news/badtunnel-bug-hijacks-network-traffic-affects-all-windows-versions-505294.shtml

Quote"Exploitation points remain open for non-supported Windows operating systems such as XP, Windows Server 2003, and others, for which patches have not been released. For these operating systems, and for those that can't be updated just yet, system administrators should disable NetBIOS."

Most windows machines are setup as "default", so if DHCP query sets nothing the NetBIOS is interpreted as "enabled".


So this started me tinkering around (services.inc), what do you need to setup in "DHCPD.conf" to disable NetBIOS from the DHCP service.

So I did some google searches and found this code example for Linux (ICS DHCP).
http://www.bakarasse.de/pages/en/linux/disable-netbios-via-dhcp.php?lang=EN

I only got the single host example to work with my static DHCP leases, adding the code in the "pool" didn't work.
Maybe the wrong location? Or it does not work in a "pool".

Partial "dhcpd.conf" after tinkering.


option domain-name "home";
option ldap-server code 95 = text;
option domain-search-list code 119 = text;
option arch code 93 = unsigned integer 16; # RFC4578

# to save the vendor id in the lease db:
set vendor-id = option vendor-class-identifier;

# specifying the option space name:
option space MSFT;
option MSFT.nbt                 code 1 = unsigned integer 32;


default-lease-time 7200;
etc...



host s_lan_0 {
        hardware ethernet 00:11:22:aa:bb:cc;
  fixed-address 192.168.0.20;
  option host-name "EXAMPLE";
    if substring ( option vendor-class-identifier, 0, 8 ) = "MSFT 5.0"
    {
     vendor-option-space MSFT;
     # 1 = enable, 2 = disable NetBIOS over TCP/IP:
     option MSFT.nbt 2;
    }
}


It would be nice if the NetBIOS option would become a slider (on/off) in a future update  ;)
#3
Currently (16.1.7) unbound does not generate the host and domain itself inside the "host_entries.conf" file.
My current work around was setting a host override.

Without it hostname lookups in windows look like so:

nslookup <enter>
Default Server:  Unkown
Address:  192.168.0.1

> Anduril
Server:  Unkown
Address:  192.168.0.1

Name:    Anduril.home
Address:  192.168.0.51

> exit


It was because the "host_entries.conf" only added localhost.
"host_entries.conf"
local-zone: "home" transparent
local-data-ptr: "127.0.0.1 localhost"
local-data: "localhost A 127.0.0.1"
local-data: "localhost.home A 127.0.0.1"
local-data-ptr: "::1 localhost"
local-data: "localhost AAAA ::1"
local-data: "localhost.home AAAA ::1"


To fix this the reference to the 'interface' needs to be changed to 'active_interface'.
Part of "unbound.inc"

519    if (isset($config['unbound']['interface'])) {
520        $interfaces = explode(",", $config['unbound']['interface']);


519    if (isset($config['unbound']['active_interface'])) {
520        $interfaces = explode(",", $config['unbound']['active_interface']);

After saving the config again the "host_entries.conf" does save for LAN interface the hostname of opnsense.
(a bit further in the code "$if" is used a variable for testing real interfaces, reading "if" and "$if" not nice...and should be changed)

local-zone: "home" transparent
local-data-ptr: "127.0.0.1 localhost"
local-data: "localhost A 127.0.0.1"
local-data: "localhost.home A 127.0.0.1"
local-data-ptr: "::1 localhost"
local-data: "localhost AAAA ::1"
local-data: "localhost.home AAAA ::1"
local-data-ptr: "192.168.0.1 OPNsense.home"
local-data: "OPNsense.home A 192.168.0.1"
local-data: "OPNsense A 192.168.0.1"


After this fix hostname lookups in windows look like so:

nslookup <enter>
Default Server:  OPNsense.home
Address:  192.168.0.1

> Anduril
Server:  OPNsense.home
Address:  192.168.0.1

Name:    Anduril.home
Address:  192.168.0.51

> exit

#4
15.7 Legacy Series / Unbound updated already to 1.5.6
October 20, 2015, 05:40:54 PM
Hi,

I just updated to 15.7.17 today (20th of October)

And checked the release announcement info.
Unbound has already been updated again, to higher version than 1.5.5 to 1.5.6

Copy-past from unbound.net website:

Download: unbound-1.5.6.tar.gz
SHA1 checksum: b1e521669d6e5a3c1baf8b71dad070e38887162b
SHA256 checksum: ad3823f5895f59da9e408ea273fcf81d8a76914c18864fba256d7f140b83e404
PGP signature: unbound-1.5.6.tar.gz.asc
Date: 20 October, 2015

Features
Default for ssl-port is port 853, the temporary port assignment for secure domain name system traffic. If you used to rely on the older default of port 443, you have to put a clause in unbound.conf for that. The new value is likely going to be the standardised port number for this traffic.
ANY responses include DNAME records if present, as per Evan Hunt's remark in dnsop.

Bug Fixes
Fix segfault in the dns64 module in the formaterror error path.
Fix manpage to suggest using SIGTERM to terminate the server.
iana portlist update.
#5
Perhaps I'm a bit paranoid but I always update the unbound settings to include the non-internet-rout-able address space to be set as private addresses.
Maybe it is overzealous to think that (the mighty) PF and the bogon + bogonv6 rules will not protect you enough.

After each update I manually update "/usr/local/etc/inc/unbound.inc".
I  replace the default private-address rules with this setup (code blob below), this is based upon RFC standards for private address spaces.

# For DNS Rebinding prevention
#
# All these addresses are either private or should not be routable in the global IPv4 or IPv6 internet.
#
# IPv4 Addresses
#
private-address: 0.0.0.0/8       # Broadcast address
private-address: 10.0.0.0/8
private-address: 100.64.0.0/10
private-address: 127.0.0.0/8     # Loopback Localhost
private-address: 172.16.0.0/12
private-address: 192.0.0.0/24    # IANA IPv4 special purpose net
private-address: 192.0.2.0/24    # Documentation network TEST-NET
private-address: 192.168.0.0/16
private-address: 192.254.0.0/16
private-address: 198.18.0.0/15   # Used for testing inter-network communications
private-address: 198.51.100.0/24 # Documentation network TEST-NET-2
private-address: 203.0.113.0/24  # Documentation network TEST-NET-3
private-address: 233.252.0.0/24  # Documentation network MCAST-TEST-NET
#
# IPv6 Addresses
#
private-address: ::1/128         # Loopback Localhost
private-address: 2001:db8::/32   # Documentation network IPv6
private-address: fc00::/8        # Unique local address (ULA) part of "fc00::/7", not defined yet
private-address: fd00::/8        # Unique local address (ULA) part of "fc00::/7", "/48" prefix group
private-address: fe80::/10       # Link-local address (LLA)

EOF;


Afterwards I re-save (reload) DNS resolver settings and test with the DNSBench tool made available by Gibson research "https://www.grc.com/dns/benchmark.htm"
You (I) should see a fully filled outer circle in the DNSBench tool for my current DNS resolver.
You can comment out the localhost/loopback address (127.0.0.1) than you see a ¾ filled circle with DNSBench.