root@opn:/usr/local/etc/suricata/rules # ls *.rulesOPNsense.rules emerging-icmp_info.rulesabuse.ch.feodotracker.rules emerging-imap.rulesabuse.ch.sslblacklist.rules emerging-info.rulesabuse.ch.sslipblacklist.rules emerging-malware.rulesabuse.ch.urlhaus.rules emerging-misc.rulesbotcc.portgrouped.rules emerging-mobile_malware.rulesbotcc.rules emerging-rpc.rulesciarmy.rules emerging-scan.rulescompromised.rules emerging-shellcode.rulesdrop.rules emerging-smtp.rulesdshield.rules emerging-sql.rulesemerging-activex.rules emerging-trojan.rulesemerging-attack_response.rules emerging-user_agents.rulesemerging-current_events.rules emerging-web_client.rulesemerging-deleted.rules emerging-web_server.rulesemerging-dns.rules emerging-web_specific_apps.rulesemerging-dos.rules emerging-worm.rulesemerging-exploit.rules opnsense.test.rulesemerging-ftp.rules opnsense.uncategorized.rulesemerging-icmp.rulesroot@opn:/usr/local/etc/suricata/rules # cat *.rules | sed 's/^ *#.*//' | sed '/^ *$/d' | wc -l 41614
### loader.conf.local# Flow Control (FC): 0 = Disabled, 1 = Rx Pause, 2 = Tx Pause, 3 = Full FChw.igb.0.fc=0hw.igb.1.fc=0hw.igb.2.fc=0hw.igb.3.fc=0# Set number of queues to number of cores divided by number of ports, 0 lets FreeBSD decide (should be default)hw.igb.num_queues=0# Increase packet descriptors (set as 1024, 2048 or 4096 ONLY)hw.igb.rxd="4096" # Default = 1024hw.igb.txd="4096"net.link.ifqmaxlen="8192" # Sum of above two (default = 50)# Increase network efficiency (Adaptive Interrupt Moderation, should be default)hw.igb.enable_aim=1# Increase interrupt rate # Default = 8000hw.igb.max_interrupt_rate="64000"# Fast interrupt handling, allows NIC to process packets as fast as they are received (should be default)hw.igb.enable_msix=1hw.pci.enable_msix=1# Unlimited packet processinghw.igb.rx_process_limit="-1"hw.igb.tx_process_limit="-1"### WebGUI > System > Settings > Tunables# Disable Energy Efficient Ethernetdev.igb.0.eee_disabled=1dev.igb.1.eee_disabled=1dev.igb.2.eee_disabled=1dev.igb.3.eee_disabled=1# Set Flow Controlhw.igb.0.fc=0hw.igb.1.fc=0hw.igb.2.fc=0hw.igb.3.fc=0dev.igb.0.fc=0dev.igb.1.fc=0dev.igb.2.fc=0dev.igb.3.fc=0# Do not accept IPv4 fragmentsnet.inet.ip.maxfragpackets=0net.inet.ip.maxfragsperpacket=0
$ iperf -c vps1 -p 4712 -u -t 60 -i 10 -b 1000M------------------------------------------------------------Client connecting to vps1, UDP port 4712Sending 1470 byte datagrams, IPG target: 11.22 us (kalman adjust)UDP buffer size: 9.00 KByte (default)------------------------------------------------------------[ ID] Interval Transfer Bandwidth[ 5] 0.0-10.0 sec 1.11 GBytes 954 Mbits/sec[ 5] 10.0-20.0 sec 1.11 GBytes 952 Mbits/sec[ 5] 20.0-30.0 sec 1.11 GBytes 954 Mbits/sec[ 5] 30.0-40.0 sec 1.11 GBytes 953 Mbits/sec[ 5] 40.0-50.0 sec 1.11 GBytes 955 Mbits/sec[ 5] 0.0-60.0 sec 6.66 GBytes 953 Mbits/sec[ 5] Sent 4864635 datagrams
iperf -p 5201 -c 192.168.1.99 -u -b 10m -P 100 -d -t 60
Tracing command kernel pid 0 tid 100162 td 0xfffff8001ffb1560sched_switch() at sched_switch+0x4aa/frame 0xfffffe0467a1daa0mi_switch() at mi_switch+0xe5/frame 0xfffffe0467a1dad0sleepq_wait() at sleepq_wait+0x3a/frame 0xfffffe0467a1db00_sleep() at _sleep+0x255/frame 0xfffffe0467a1db80taskqueue_thread_loop() at taskqueue_thread_loop+0x121/frame 0xfffffe0467a1dbb0fork_exit() at fork_exit+0x85/frame 0xfffffe0467a1dbf0fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe0467a1dbf0--- trap 0, rip = 0, rsp = 0, rbp = 0 ---Tracing command kernel pid 0 tid 100173 td 0xfffff800099dd000sched_switch() at sched_switch+0x4aa/frame 0xfffffe0467a54aa0mi_switch() at mi_switch+0xe5/frame 0xfffffe0467a54ad0sleepq_wait() at sleepq_wait+0x3a/frame 0xfffffe0467a54b00_sleep() at _sleep+0x255/frame 0xfffffe0467a54b80taskqueue_thread_loop() at taskqueue_thread_loop+0x121/frame 0xfffffe0467a54bb0fork_exit() at fork_exit+0x85/frame 0xfffffe0467a54bf0fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe0467a54bf0--- trap 0, rip = 0, rsp = 0, rbp = 0 ---db:0:kdb.enter.default> capture offdb:0:kdb.enter.default> call doadump= 0x6db:0:kdb.enter.default> resetcpu_reset: Restarting BSPcpu_reset_proxy: Stopped CPU 7
To followup, Brent Cowing of Protectli sent me a i3-7100U based box and my speeds are back to 910/949.see also:https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237072https://github.com/HardenedBSD/hardenedBSD/issues/376I will also have a 2nd E3845 box here this week (thanks Brent), and will able to play and not affect my internet connection.
Quote from: lrosenman on April 09, 2019, 04:40:33 amTo followup, Brent Cowing of Protectli sent me a i3-7100U based box and my speeds are back to 910/949.see also:https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237072https://github.com/HardenedBSD/hardenedBSD/issues/376I will also have a 2nd E3845 box here this week (thanks Brent), and will able to play and not affect my internet connection. Is this with IPS/IDS turned on? I get 870/950 with the igbX tunables and no IPS/IDS. When I turn on IPS/IDS, the speedtest.net download speed starts at 800-900 mbps and slowly levels off at 100-200 mbps. The upload speed starts at 10 mbps and then the test errors out. I wonder if this has something to do with netgraph ...
I have researched and tested tunables because I have experienced too many down links and poor performance when using IPS/Inline on the WAN interface that could no longer be ignored. This file, loader.conf.local along with adding some system tunables in the WebGUI, has fixed this for me so I thought I would share with the OPNsense community. Sharing is what makes on open-source project successful. Share your experiences using the info in this post. You may or may not see much performance improvement depending on your hardware, but you will see less dropped connections. If you have any other tunable recommendations, please share and post those experiences here. This thread is for performance tuning ideas.The biggest impact was from the Flow Control (FC) setting. FC is a level 1 layer adding pause frames before the data is transmitted. My assumption is Netmap has issues with FC which causes the dropped connections. Recommendations from many sources, including Cisco, suggest disabling FC altogether and let the higher levels handle the flow. There are exceptions, but these usually involve ESXi, VMware and other special applications.I have done all my testing using an Intel i350T4 and i340T4, common NICs used for firewalls, in 4 different systems and, by the way, neither NIC had any performance advantage. I have tested these system for 5 days without any down links experienced after the changes were made. Without these changes every system was plagued with down WAN links and poor performance using the default settings.Do not use this file if you are not using an igb driver. igb combined with other drivers is ok as long as you have at least one igb NIC, and I recommend you use the igb for all WAN interfaces.Add the file below in the '/boot' folder and call it 'loader.conf.local' right besides 'loader.conf'. I use WinSCP, in a Windows environment, as a file manager to get easy access to the folders. Don't forget to Enable Secure Shell. I have tried using the 'System Tunables' in the WebGUI to add these settings. Some worked and some didn't using that method. Not sure why. Better to just add this file. If you're a Linux guru, I am not, then use your own methods to add this file.The two most IMPORTANT things to insure is that power management be disabled in the OPNsense settings and also in the BIOS settings of the system (thanks wefinet). And the second is to disable flow control (IEEE 802.3x) on all ports. It is advisable to not connect an IPS interface to any device which has flow control on. Flow control should be turned off to allow the congestion to be managed higher up in the stackPlease test all tunables in a test environment before you apply to a production system.# File starts below this line, use Copy/Paste ###################### Check for interface specific settings and add accordingly.# These ae tunables to improve network performance on Intel igb driver NICs# Flow Control (FC) 0=Disabled 1=Rx Pause 2=Tx Pause 3=Full FC# This tunable must be set according to your configuration. VERY IMPORTANT!# Set FC to 0 (<x>) on all interfaceshw.igb.<x>.fc=0 #Also put this in System Tunables hw.igb.<x>.fc: value=0# Set number of queues to number of cores divided by number of ports. 0 lets FreeBSD decidehw.igb.num_queues=0# Increase packet descriptors (set as 1024,2048, or 4096) ONLY!# Allows a larger number of packets to be processed.# Use "netstat -ihw 1" in the shell and make sure the idrops are zero# If the NIC has constant disconnects, lower this value# if not zero then lower this value.hw.igb.rxd="4096" # For i340/i350 use 2048hw.igb.txd="4096" # For i340/i350 use 2048net.link.ifqmaxlen="8192" # value here equal sum of above values. For i340/i350 use 4096# Increase Network efficiencyhw.igb.enable_aim=1# Increase interuppt ratehw.igb.max_interrupt_rate="64000"# Network memory buffers# run "netstat -m" in the shell and if the 'mbufs denied' and 'mbufs delayed' are 0/0/0 then this is not needed# if not zero then keep adding 400000 until mbufs are zerokern.ipc.nmbclusters="1000000"# Fast interrupt handling# Normally set by default. Use these settings to insure it is on.# Allows NIC to process packets as fast as they are receivedhw.igb.enable_msix=1hw.pci.enable_msix=1# Unlimited packet processing# Use this only if you are sure that the NICs have dedicated IRQs# View the IRQ assignments by executing this in the shell "vmstat -i"# A value of "-1" means unlimited packet processinghw.igb.rx_process_limit="-1"hw.igb.tx_process_limit="-1"#################################################### File ends above this line ####################################UPDATE 12/12/2017##After testing I have realized that some of these settings are NOT applied via loader.conf.local and must be added via the WebGUI in System>Settings>Tunables. I have moved these from the file above to this list.Add to TunablesDisable Energy Efficiency - set for each igb port in your systemThis setting can cause Link flap errors if not disabledSet for every igb interface in the system as per these examplesdev.igb.0.eee_disabled: value=1dev.igb.1.eee_disabled: value=1dev.igb.2.eee_disabled: value=1dev.igb.3.eee_disabled: value=1IPv4 Fragments - 0=Do not accept fragmentsThis is mainly need for security. Fragmentation can be used to evade packet inspectionnet.inet.ip.maxfragpackets: value=0net.inet.ip.maxfragsperpacket: value=0Set to 0 (<x>) for every port used by IPSdev.igb.<x>.fc: value=0##UPDATE 1/16/2018##Although the tuning in this thread so far just deals with the tunables, there are other settings that can impact IPS performance. Here are a few...In the Intrusion Detection Settings Tab. Promiscuous mode- To be used only when multiple interfaces or VLAN's are selected in the Interfaces setting.This is used so that IPS will capture data on all the selected interfaces. Do not enable if you have just one interface selected. It will help with performance.Pattern matcher: This setting can select the best algorithm to use when pattern matching. This setting is best set by testing. Hyperscan seems to work well with Intel NIC's. Try different ones and test the bandwidth with an internet speed test.Home networks (under advanced menu.Make sure the interfaces fall within the actual local networks. You may want to change the generic 192.168.0.0/16 to your actual local network ie 192.168.1.1/24###################################################USEFUL SHELL COMMANDSsysctl net.inet.tcp.hostcache.list # View the current host cache statsvmstat -i # Query total interrupts per queuetop -H -S # Watch CPU usagedmesg | grep -i msi # Verify MSI-X is being used by the NICnetstat -ihw 1 # Look for idrops to determine hw.igb.txd and rxdgrep <interface> /var/run/dmesg.boot # Shows useful info like netmap queue/slotssysctl -A # Shows system variables###################################################
### loader.conf.local# Flow Control (FC): 0 = Disabled, 1 = Rx Pause, 2 = Tx Pause, 3 = Full FChw.igb.0.fc=0hw.igb.1.fc=0dev.igb.0.fc=0dev.igb.1.fc=0# Set number of queues to number of cores divided by number of ports, 0 lets FreeBSD decide (should be default)hw.igb.num_queues=0# Increase packet descriptors (set as 1024, 2048 or 4096 ONLY)hw.igb.rxd="2048" # Default = 1024hw.igb.txd="2048"net.link.ifqmaxlen="4096" # Sum of above two (default = 50)# Increase network efficiency (Adaptive Interrupt Moderation, should be default)hw.igb.enable_aim=1# Increase interrupt rate # Default = 8000hw.igb.max_interrupt_rate="64000"# Fast interrupt handling, allows NIC to process packets as fast as they are received (should be default)hw.igb.enable_msix=1hw.pci.enable_msix=1# Unlimited packet processinghw.igb.rx_process_limit="-1"hw.igb.tx_process_limit="-1"
...net.inet.ip.redirect="0"net.inet.icmp.drop_redirect="1"hw.igb.1.fc="0"dev.igb.1.fc="0"hw.igb.0.fc="0"dev.igb.0.fc="0"# dynamically generated console settings follow#comconsole_speed#boot_multicons#boot_serial#kern.vtyconsole="vidconsole"