dnsmasq DNS server and multiple subnets

If you run into a problem where your dnsmasq DNS server is not responding to dns queries from separate subnets than the DNS server’s subnet, try setting the listen-address to the DNS server’s IP (e.g. where you’re running dnsmasq).

On the Ubiquiti EdgeRouter Lite (which is based on mips Debian wheezy) the file to change is:

/etc/dnsmasq.d/local.conf

(make it if it doesn’t exist)

add this to that file:

listen-address=<DNS-SERVER-IP>

Where <DNS-SERVER-IP> is the IP of your machine that’s running dnsmasq.

If you’re running dnsmasq from the command line, without using the conf files, add this parameter

--listen-address <DNS-SERVER-IP>

EdgeRouter Lite Performance Tests

Starting with two laptops connected to one ERL each. ERLs both running 1.5.0.

Laptop A <-> ERL <-> ERL <-> Laptop B
192.168.20.100 <-> 192.168.20.1 192.168.1.2 <-> 192.168.1.1 192.168.10.1 <-> 192.168.10.10020141010_22362

 

I’m using OSPF to expose these two networks to each other for this test. See EdgeRouter Lite Simple OSPF Guide

iperf results from one laptop to the other:

$ iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 64.0 KByte (default)
------------------------------------------------------------
[ 4] local 192.168.10.100 port 5001 connected with 192.168.20.100 port 42797
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 1.10 GBytes 940 Mbits/sec
[ 4] local 192.168.10.100 port 5001 connected with 192.168.20.100 port 42820
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-100.0 sec 11.0 GBytes 941 Mbits/sec

 Near wire. Great!

 Next we’ll remove the OSPF routing and setup an IPSec tunnel between the two an retest.

I used the GUI’s IPSec site-to-site feature to set this up. Here’s what it generated:

vpn {
    ipsec {
        auto-firewall-nat-exclude enable
        esp-group FOO0 {
            compression disable
            lifetime 3600
            mode tunnel
            pfs enable
            proposal 1 {
                encryption aes128
                hash sha1
            }
        }
        ike-group FOO0 {
            lifetime 28800
            proposal 1 {
                dh-group 14
                encryption aes128
                hash sha1
            }
        }
        ipsec-interfaces {
            interface eth0
        }
        nat-networks {
            allowed-network 0.0.0.0/0 {
            }
        }
        nat-traversal enable
        site-to-site {
            peer 192.168.1.2 {
                authentication {
                    mode pre-shared-secret
                    pre-shared-secret ****************
                }
                connection-type initiate
                ike-group FOO0
                local-ip 192.168.1.1
                tunnel 1 {
                    allow-nat-networks disable
                    allow-public-networks disable
                    esp-group FOO0
                    local {
                        subnet 192.168.10.0/24
                    }
                    remote {
                        subnet 192.168.20.0/24
                    }
                }
            }
        }
    }
}

And the results with IPSec hardware offload disabled.

'set system offload ipsec disable'

[ 4] local 192.168.10.100 port 5001 connected with 192.168.20.100 port 44600
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-100.1 sec 718 MBytes 60.2 Mbits/sec
[ 4] local 192.168.10.100 port 5001 connected with 192.168.20.100 port 44601
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 72.5 MBytes 60.5 Mbits/sec

And with IPSec hardware offload enabled.

'set system offload ipsec enable'

[ 4] local 192.168.10.100 port 5001 connected with 192.168.20.100 port 44586
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 180 MBytes 151 Mbits/sec
[ 4] local 192.168.10.100 port 5001 connected with 192.168.20.100 port 44590
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 179 MBytes 150 Mbits/sec
[ 4] local 192.168.10.100 port 5001 connected with 192.168.20.100 port 44596
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-100.0 sec 1.75 GBytes 151 Mbits/sec

Not bad!

However, even with IPSec enabled, load average increases a good bit when pushing max data through the IPSec VPN

jdrews@ERL10:~$ uptime
 10:23:23 up 23 min, 1 user, load average: 0.58, 0.66, 0.47

Compared to without pushing data

jdrews@ERL10:~$ uptime
 20:47:29 up 10:47, 1 user, load average: 0.00, 0.01, 0.05

While this didn’t seem to affect the usage of the router, it is a little worrying. I don’t have any firewalls or other services enabled on the router. What happens when we take this into the real world? It’s worth noting that this is a dual core router, so really that’s only 1/4 of total processing power.

EdgeRouter Lite Simple OSPF Guide

Here’s a really simple OSPF setup on two Ubiquiti Edge Router Lites.

Two ERLs hooked together via eth0.

ERL20 <-> ERL10
192.168.20.1 192.168.1.2 <-> 192.168.1.1 192.168.10.1

20141010_22362

on ERL20 get into configure and run the following:

# give this router an id. 
set protocols ospf parameters router-id 192.168.20.1

# 0.0.0.0 is backbone. Add in networks to advertise. 
set protocols ospf area 0.0.0.0 network 192.168.1.0/24
set protocols ospf area 0.0.0.0 network 192.168.20.0/24

# enable ospf on eth0 interface (going to ERL10) 
set interfaces ethernet eth0 ip ospf

on ERL10 get into configure and run the following.

# give this router an id. 
set protocols ospf parameters router-id 192.168.10.1

# 0.0.0.0 is backbone. Add in networks to advertise. 
set protocols ospf area 0.0.0.0 network 192.168.1.0/24
set protocols ospf area 0.0.0.0 network 192.168.10.0/24

# enable ospf on eth0 interface (going to ERL20) 
set interfaces ethernet eth0 ip ospf

run ‘commit’ on both them, (‘save’ if you want to) and ‘exit’ to prompt.

Now watch ospf work it’s magic.

jdrews@ERL10:~$ show ip ospf neighbor

 Neighbor ID Pri State Dead Time Address Interface RXmtL RqstL DBsmL
192.168.20.1 1 2-Way/DROther 34.213s 192.168.1.2 eth0:192.168.1.1 0 0 0

jdrews@ERL20:~$ show ip ospf neighbor

 Neighbor ID Pri State Dead Time Address Interface RXmtL RqstL DBsmL
192.168.10.1 1 2-Way/DROther 36.422s 192.168.1.1 eth0:192.168.1.2 0 0 0

jdrews@ERL10:~$ show ip ospf neighbor

 Neighbor ID Pri State Dead Time Address Interface RXmtL RqstL DBsmL
192.168.20.1 1 ExStart/DR 30.837s 192.168.1.2 eth0:192.168.1.1 0 0 0

jdrews@ERL20:~$ show ip ospf neighbor

 Neighbor ID Pri State Dead Time Address Interface RXmtL RqstL DBsmL
192.168.10.1 1 Full/Backup 39.764s 192.168.1.1 eth0:192.168.1.2 2 0 0

jdrews@ERL10:~$ show ip ospf neighbor

 Neighbor ID Pri State Dead Time Address Interface RXmtL RqstL DBsmL
192.168.20.1 1 Full/DR 39.674s 192.168.1.2 eth0:192.168.1.1 1 0 0

Now you should have routes

jdrews@ERL10:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
 I - ISIS, B - BGP, > - selected route, * - FIB route

C>* 127.0.0.0/8 is directly connected, lo
O 192.168.1.0/24 [110/10] is directly connected, eth0, 00:11:40
C>* 192.168.1.0/24 is directly connected, eth0
O 192.168.10.0/24 [110/10] is directly connected, eth1, 00:11:39
C>* 192.168.10.0/24 is directly connected, eth1
O>* 192.168.20.0/24 [110/20] via 192.168.1.2, eth0, 00:10:58

jdrews@ERL20:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
 I - ISIS, B - BGP, > - selected route, * - FIB route

C>* 127.0.0.0/8 is directly connected, lo
O 192.168.1.0/24 [110/10] is directly connected, eth0, 00:11:34
C>* 192.168.1.0/24 is directly connected, eth0
O>* 192.168.10.0/24 [110/20] via 192.168.1.1, eth0, 00:10:44
O 192.168.20.0/24 [110/10] is directly connected, eth1, 00:11:33
C>* 192.168.20.0/24 is directly connected, eth1

 

Swann HD-820CAM

I picked up a Swann HD-820CAM (NHD-820)

SWANN SWNHD-820CAM-US 1080p HD Network Security Camera for Swann’s 1080p NVRs

Manufacturer Link: http://www.swann.com/us/swnhd-820cam

You don’t need a Swann receiver to use it.

Plug it into a switch that supports PoE. I’m using this one and can confirm it will run the IP Camera:

TP-LINK TL-SF1008P 10/100Mbps 8-Port PoE Switch, 4 POE ports, IEEE 802.3af, 53W

Set your computer to an IP in 192.0.0.0/24 (i.e. 192.168.0.200) and go to 192.0.0.64 in your browser. That’s the default IP of the camera.
Username is admin
Password is 12345

You can change it’s IP in the web management to whatever you want.

To stream via VLC use RTSP:

Media->Open Network Stream
type in one of the following:

Main (1st) Stream (720p or 1080p)
rtsp://YOUR_CAMERA_IP/Streaming/channels/1

Sub (2nd) Stream (240p or 480p)
rtsp://YOUR_CAMERA_IP/Streaming/channels/2

I can also confirm that Wowza Streaming Engine will read in the RTSP streams above and properly converts them to RTMP (which is what Flash requires).

Here’s all the screens in the web management:

Dell Vostro 3560: Removing Base Cover

Removing the Base Cover on the Dell Vostro 3560 is quite tricky.

Here’s what the manual says to do:

Screenshot_100513_104405_PM.jpg

 

Seems easy enough. In actuality it’s much harder. The cover won’t slide. You have to work your way around the edges with a small screw driver. Be very careful since the base cover is plastic.

Your goal is to get each one of these plastic lips out.

20130920_200109

 

There are 13 of them as seen below.

20130920_200026

Another view of these annoying little bastards.

20130920_200037

 

Here’s what the 3560 looks like with the base cover removed.

20130920_200240

 

Good luck!

 

Autosave untitled/new Notepad++ files

I often type random notes into a Notepad++ new file (AKA untitled). Sometimes these are important notes that I don’t want to loose. Most of the time I remember to save these somewhere, or at least I remember when closing Notepad++. But on one occasion I forgot the save it, and then accidentally clicked ‘No’ when it asked me if I wanted to save the file. Arg. Important notes lost…

But I found the answer. The plugin called Autosave will save these new (AKA untitled) files every X minutes, or when Notepad++ looses focus, or both.

You can get Autosave here:
http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Plugin_Central#A
or here:
https://sites.google.com/site/fstellari/nppplugins

Then figure out if you’re using the Unicode or ASCII version of Notepad++ by navigating to the menu bar in Notepad++, clicking the “?” and then going to “About Notepad++”. Most likely you’ll be running the Unicode version. In that case you’ll use the AutoSaveU.dll.

After you know your Notepad++ flavor, grab the respective dll and place it in your plugins folder under the Notepad++ folder. For me this is:
C:\Program Files (x86)\Notepad++\plugins

Then restart Notepad++ and modify the options by going to the Notepad++ menu bar and navigating to Plugins->AutoSave->Options.

I like my AutoSave configured to the following:autosave

Bash: Run command after another

What many of you probably know is that you can chain commands together with the semicolon. Like so:

unixbench ; echo "unixbench finished" >> unixbench.log

So here we’re running a unixbench, and then directly after, we’re appending “unixbench finished” to unixbench.log.

But what you might not know about is the ‘&&’ replacement for ‘;’. This will only do the next command if the first command returns 0, meaning clean finish.

unixbench && echo "unixbench finished cleanly" >> unixbench.log

And taking it a step further, there’s ‘||’ which does the opposite of ‘&&’. If the first command fails, then the next command happens.

unixbench || echo "unixbench failed" >> unixbench.log

 

Ubuntu 12.04 x86_64 Poor Performance on Hyper-V in Windows 8

As of the Hyper-V Version: 6.2.9200.16384, Ubuntu 12.04 x86_64 performs very slow as a guest os. I switched to CentOS 6.2 x86_64 and performance was dramatically increased. It should be noted that “Linux Integration Services Version 3.4 for Hyper-V” was installed on the CentOS system, but not the Ubuntu system. I’ll investigate this at a later date.

I’ll post a unixbench of both VMs when I get a maintenance window. But for now, examine these load averages. Both running a minecraft server (Bukkit 1.4.6-R0.1) of the same world with the same amount of people. Both had 4GB of ram and 4 CPUs.

Ubuntu 12.04 x86_64: load average: 2.65, 2.92, 2.47

CentOS 6.2 x86_64: load average: 0.14, 0.11, 0.09

—————————–

EDIT 12/27/2012

UnixBench Ubuntu 12.04

   
BYTE UNIX Benchmarks (Version 5.1.3)

   System: u1204vm: GNU/Linux
   OS: GNU/Linux -- 3.2.0-35-generic -- #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (6799.9 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   CPU 1: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (6801.6 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   CPU 2: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (6801.7 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   CPU 3: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (6801.4 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   12:26:39 up 3 days, 10:50,  1 user,  load average: 0.31, 0.14, 0.08; runlevel 2

------------------------------------------------------------------------
Benchmark Run: Thu Dec 27 2012 12:26:39 - 12:56:13
4 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       44781167.7 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     3176.1 MWIPS (16.1 s, 7 samples)
Execl Throughput                               2053.4 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1451068.7 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          179747.9 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1079491.1 KBps  (30.0 s, 2 samples)
Pipe Throughput                              889723.3 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 147545.5 lps   (10.0 s, 7 samples)
Process Creation                               4040.6 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   4485.5 lpm   (60.1 s, 2 samples)
Shell Scripts (8 concurrent)                   2245.5 lpm   (60.0 s, 2 samples)
System Call Overhead                        1961736.6 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   44781167.7   3837.3
Double-Precision Whetstone                       55.0       3176.1    577.5
Execl Throughput                                 43.0       2053.4    477.5
File Copy 1024 bufsize 2000 maxblocks          3960.0    1451068.7   3664.3
File Copy 256 bufsize 500 maxblocks            1655.0     179747.9   1086.1
File Copy 4096 bufsize 8000 maxblocks          5800.0    1079491.1   1861.2
Pipe Throughput                               12440.0     889723.3    715.2
Pipe-based Context Switching                   4000.0     147545.5    368.9
Process Creation                                126.0       4040.6    320.7
Shell Scripts (1 concurrent)                     42.4       4485.5   1057.9
Shell Scripts (8 concurrent)                      6.0       2245.5   3742.6
System Call Overhead                          15000.0    1961736.6   1307.8
                                                                   ========
System Benchmarks Index Score                                        1108.3

------------------------------------------------------------------------
Benchmark Run: Thu Dec 27 2012 12:56:13 - 13:25:45
4 CPUs in system; running 4 parallel copies of tests

Dhrystone 2 using register variables      154446771.7 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                    15728.0 MWIPS (13.0 s, 7 samples)
Execl Throughput                               5584.7 lps   (29.6 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1143792.2 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          349687.8 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       3281852.5 KBps  (30.0 s, 2 samples)
Pipe Throughput                             8111911.1 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                1301692.0 lps   (10.0 s, 7 samples)
Process Creation                              53932.0 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  14498.0 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   2048.2 lpm   (60.1 s, 2 samples)
System Call Overhead                       11535804.1 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0  154446771.7  13234.5
Double-Precision Whetstone                       55.0      15728.0   2859.6
Execl Throughput                                 43.0       5584.7   1298.8
File Copy 1024 bufsize 2000 maxblocks          3960.0    1143792.2   2888.4
File Copy 256 bufsize 500 maxblocks            1655.0     349687.8   2112.9
File Copy 4096 bufsize 8000 maxblocks          5800.0    3281852.5   5658.4
Pipe Throughput                               12440.0    8111911.1   6520.8
Pipe-based Context Switching                   4000.0    1301692.0   3254.2
Process Creation                                126.0      53932.0   4280.3
Shell Scripts (1 concurrent)                     42.4      14498.0   3419.3
Shell Scripts (8 concurrent)                      6.0       2048.2   3413.6
System Call Overhead                          15000.0   11535804.1   7690.5
                                                                   ========
System Benchmarks Index Score                                        3936.3

UnixBench CentOS 6.2

   
BYTE UNIX Benchmarks (Version 5.1.3)

   System: x1CenVM: GNU/Linux
   OS: GNU/Linux -- 2.6.32-279.19.1.el6.x86_64 -- #1 SMP Wed Dec 19 07:05:20 UTC 2012
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (6799.8 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSCALL/SYSRET
   CPU 1: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (6799.8 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSCALL/SYSRET
   CPU 2: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (6799.8 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSCALL/SYSRET
   CPU 3: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (6799.8 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSCALL/SYSRET
   02:14:07 up 1 day,  4:57,  2 users,  load average: 0.47, 0.37, 0.21; runlevel 5

------------------------------------------------------------------------
Benchmark Run: Thu Dec 27 2012 02:14:07 - 02:42:36
4 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       43284217.6 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     4547.3 MWIPS (10.3 s, 7 samples)
Execl Throughput                               2993.4 lps   (29.3 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1326530.8 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          359629.5 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       3116962.1 KBps  (30.2 s, 2 samples)
Pipe Throughput                             2331204.6 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 471082.1 lps   (10.0 s, 7 samples)
Process Creation                              15342.5 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   8163.5 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   2658.5 lpm   (60.0 s, 2 samples)
System Call Overhead                        3028768.3 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   43284217.6   3709.0
Double-Precision Whetstone                       55.0       4547.3    826.8
Execl Throughput                                 43.0       2993.4    696.1
File Copy 1024 bufsize 2000 maxblocks          3960.0    1326530.8   3349.8
File Copy 256 bufsize 500 maxblocks            1655.0     359629.5   2173.0
File Copy 4096 bufsize 8000 maxblocks          5800.0    3116962.1   5374.1
Pipe Throughput                               12440.0    2331204.6   1874.0
Pipe-based Context Switching                   4000.0     471082.1   1177.7
Process Creation                                126.0      15342.5   1217.7
Shell Scripts (1 concurrent)                     42.4       8163.5   1925.4
Shell Scripts (8 concurrent)                      6.0       2658.5   4430.8
System Call Overhead                          15000.0    3028768.3   2019.2
                                                                   ========
System Benchmarks Index Score                                        1990.4

------------------------------------------------------------------------
Benchmark Run: Thu Dec 27 2012 02:42:36 - 03:11:13
4 CPUs in system; running 4 parallel copies of tests

Dhrystone 2 using register variables      172485744.7 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                    18251.3 MWIPS (10.1 s, 7 samples)
Execl Throughput                              10103.2 lps   (29.5 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1593889.0 KBps  (30.3 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          159649.9 KBps  (30.3 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1614353.2 KBps  (30.0 s, 2 samples)
Pipe Throughput                             2882042.9 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 609999.5 lps   (10.0 s, 7 samples)
Process Creation                              24230.7 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  11881.5 lpm   (60.2 s, 2 samples)
Shell Scripts (8 concurrent)                   1626.7 lpm   (60.3 s, 2 samples)
System Call Overhead                        3597376.4 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0  172485744.7  14780.3
Double-Precision Whetstone                       55.0      18251.3   3318.4
Execl Throughput                                 43.0      10103.2   2349.6
File Copy 1024 bufsize 2000 maxblocks          3960.0    1593889.0   4025.0
File Copy 256 bufsize 500 maxblocks            1655.0     159649.9    964.7
File Copy 4096 bufsize 8000 maxblocks          5800.0    1614353.2   2783.4
Pipe Throughput                               12440.0    2882042.9   2316.8
Pipe-based Context Switching                   4000.0     609999.5   1525.0
Process Creation                                126.0      24230.7   1923.1
Shell Scripts (1 concurrent)                     42.4      11881.5   2802.3
Shell Scripts (8 concurrent)                      6.0       1626.7   2711.2
System Call Overhead                          15000.0    3597376.4   2398.3
                                                                   ========
System Benchmarks Index Score                                        2706.0

rc.local and sudo on CentOS

If you have a sudo command you’re trying to run at startup in your /etc/rc.local on a CentOS system, it might not work. The reason is the following error that’s buried in the /var/log/boot.log file:

sudo: sorry, you must have a tty to run sudo

It might be hard to find, but you can always add a ‘sleep 30’ before your sudo command in your /etc/rc.local. This way, the message will show up at the end of the boot.log

Anyhow the reason this is happening is for security. To allow sudo on boot, run ‘visudo’ as root and comment out ‘Defaults requiretty’ as seen below:

# Disable "ssh hostname sudo <cmd>", because it will show the password in clear.
#         You have to run "ssh -t hostname sudo <cmd>".
#
#Defaults    requiretty

Now your sudo command should run just fine at boot time.

——————————

Here’s an example of why you might want to run sudo at boot.

sudo -u minesrv -i /home/minesrv/scripts/startMinecraft

In the above command, I’m running the script startMinecraft, as the user minesrv. startMinecraft has some screen magic, and I want it tied to the minesrv user.

Startup script for GNU screen

Here’s how you start up a GNU screen session at startup and give it a command to run.

#!/bin/bash
cd /home/minesrv/minecraft_server/
screen -dmS minesrv java -server -Xincgc -Xmx3G -jar minecraft_server.jar nogui

So in this case we’re starting a minecraft server in a screen session.

Per the man page -dm does the following:

-d -m   Start screen in "detached" mode. This creates a new session but
               doesn't  attach  to  it.  This  is  useful  for  system startup
               scripts.

the -S gives the screen session a name so it’s easier to find later on.

Then it runs the command, java, with its parameters.

———————————————————————————

Another useful tool is sudo, so we can run our above startup script as a different user than root.

#!/bin/bash
sudo -u minesrv -i /home/minesrv/scripts/startMinecraft

startMinecraft is the first bash script above. Here we’re using sudo to run it as the user ‘minesrv’.

The -i makes sudo perform all the standard login processes before running the script.

—————————————————————-

And finally, you can just reference the startup script inside /etc/rc.local for most linux distros. That will make the script run at startup.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/minesrv/scripts/startAtBoottimeMinecraft
exit 0