Windows 8.1/Server 2012 Set Network Location

Since I have started using Windows more I have run into this problem a few times. Sometimes it can be a driver issue but that has never been the case for me. It is usually I didn’t pay attention during the install and selected Public by accident or Windows is acting weird and switched an existing network to Public. This will fix the problem if nothing else works and you think your system is sane.

Start up Powershell
Just search for it if you don’t know where to find it under the start menu.

Check the current adapter settings
run > Get-NetConnectionProfile

Name : This will vary depending on how the network is configured
InterfaceAlias : Ethernet
InterfaceIndex : 3
NetworkCategory : Public/Private/DomainAuthenticated depends on current Category
IPv4Connectivity : Internet
IPv6Connectivity : LocalNetwork

You need to remember the InterfaceIndex for the network you want to modify.

Change the current NetworkCategory
run > Set-NetConnectionProfile -InterfaceIndex 3 -NetworkCategory Private

This command will change the NetworkCategory to Private or any category you want.

Building lsi mpt fusion drivers in centos 5

DO NOT TRY THIS YOU HAVE BEEN WARNED!!!

In trying to test a set of SAS cables recently I had to build the lsi mpt fusion driver in Centos 5.9.  I really don’t recommend you do this on a production machine or a machine you care much about.  I was seeing errors while trying to uses disks in a JBOD disk array. This worked for me in CentOS 5.9. The documentation that lsi gives for doing this in the readme with the drivers is for old kernels. My instructions work for a 2.6 kernel.

Packages
kernel-devel usual gcc glib and make packages I might be missing some packages here but again I expect you to know how to setup the kernel source so that this works. If the commands start failing most likely you missed a package.

Preparing kernel source
Download the lsi mpt linux driver bundle. It should contain a directory with the kernel source.
message/fusion
cd /usr/src/kernels
Now cd into the directory for your current kernel uname -r
Something like 2.6.18-348.1.1.el5-x86_64
cd 2.6.18-348.1.1.el5-x86_64/drivers/message
Backup the current driver source.
tar -cvf fusion_orig.tar fusion
rm -rf fusion
mkdir fusion
pwd to get the current working directory
change into the directory where you uncompressed the lsi driver.
cd message/fusion
find . -print |cpio -pdvm directory from pwd above
find . -print |cpio -pdvm /usr/src/kernels/2.6.18-348.1.1.el5-x86_64/drivers/message/fusion
Your source should be setup now.

Building module
In the kernel source directory /usr/src/kernels/2.6.18-348.1.1.el5-x86_64
make oldconfig
make prepare
make modules_pepare
make M=drivers/message/fusion
cd drivers/message/fusion
cp *.ko /lib/modules/`uname-r`/drivers/message/fusion
depmod -a

Finally reboot the machine. After reboot run modprobe -l |grep mpt to get the path to the mpt driver. Then run modinfo /lib/modules/2.6.18-348.1.1.el5/kernel/drivers/message/fusion/mptbase.ko (change this to output from modprobe). This should show the version of the driver you downloaded.

Setting up denyhosts in centos 6

Denyhosts is a script that checks logs for brute force login attacks. If an IP goes over a certain number of failures denyhosts will add the IP to /etc/hosts.deny blocking that host from accessing the server.

Installation
yum install denyhosts

Configuration
If you have a static IP or one that doesn’t change very often you should add it to /etc/hosts.allow. This prevents denyhosts from blocking that IP if you fail to login. To find out what your external IP address is go to a site like whatismyip. Your IP will be displayed on the page. Add a line like: sshd:123.123.123.123 to /etc/hosts.allow. Replace 123.123.123.123 with the IP you received.

The denyhosts config file is located in /etc/denyhosts/denyhosts.cfg. The config file explains all the settings. You can set it up to send out email reports. Also thresholds for failed logins can be changed. I usually just leave it alone.

Setting up MySQL in CentOS

This setup is fairly basic and is for CentOS 6.

Packages

mysql, mysql-server

First time setup

Start the database service mysqld start

Run /usr/bin/mysql_secure_installation

This script will walk you through the basic securing of mysql.  It will also set the root password for mysql.  The defaults should be fine here.

Hardware

This part is for users who want to run mysql on a separate disk from the OS.  You will need to have created a filesystem and mounted it some place else on the system to do this.  I mount my mysql partition at /mysql1 for example.  I’m not including partitioning or filesystem creation here because you really should know that if you are reading and doing this.   Also I realize my.cnf can be changed to point to this new location but it’s easier to just use a symlink from the default location.

service mysqld stop to stop the database.

Now copy all the files from the default mysql location to the new mount point.

find /usr/lib/mysql -print |cpio -pdvm /mysql1/mysql

Move old files to a different location in case we break something.

cd /var/lib

mv mysql mysql.os

Now create a symlink to the new location.

cd /var/lib

ln -s /mysql1/mysql

service mysqld start

Configuration

I’m not going to put specifics here.  Configuring mysql depends a lot on your hardware and how large your database is.  I set mine up to use innodb.  For a small database I setup a single data file set to autoextend.  For a larger database I use the file per table setting.  Most other settings depend on how much ram you want to give mysql.  On my server I have it setup to use about 1GB of ram.  Typically mysql will use less than what you configure it for if it doesn’t need it.

/etc/my.cnf

This is an example of my mysql config file.  My database is about 1GB in size.  The server has a lot of ram so I give MySQL a decent amount to use.

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql

key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
read_buffer_size = 256K
read_rnd_buffer_size = 512K

innodb_data_file_path = ibdata1:4096M:autoextend
innodb_buffer_pool_size = 512M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 128M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

 

Upgrading

Before doing this backup your databases using mysqldump.

service mysqld stop

yum update I usually update the entire system at the same time.

service mysqld start

/usr/bin/mysql_upgrade  This script updates all of the mysql internal tables.  It is not always needed but it is good to run after an update.

Setting up webalizer in centos 6

I am building this from source.  I realize the package comes with cent but I want to keep it up to date.  If you build your own from source make sure yum doesn’t stomp on it.

Packages needed

gcc, gcc-c++, gd-devel

Download

webalizer source from http://www.webalizer.org

GeoIP source from http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz

Compile

tar zxvf GeoIP.tar.gz

cd into the directory created

./configure

make && make install

tar zxvf webalizer.tar.gz file

cd into directory created

./configure –prefix=/usr/local/webalizer –sysconfdir=/usr/local/etc/webalizer –enable-geoip

make && make install

Setup ld properly

This step prevents this error “error while loading shared libraries: libGeoIP.so.1: cannot open shared object file: No such file or directory” when running webalizer.

cd /etc/ld.so.conf.d

vi geoip.conf  (This can be named anything.conf)

add “/usr/local/lib” to the file and save it.

Run ldconfig

Update GeoIP database

Download from http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

gunzip GeoIP.dat.gz

mv GeoIP.dat /usr/local/share/GeoIP/GeoIP.dat

Configure webalizer

cd /usr/local/etc/webalizer

cp webalizer.conf.sample yourdomain.com.conf

vi yourdomain.com.conf and change the following lines

LogFile /var/log/httpd/yourdomain.com-access_log point to your access_log file

OutputDir  /var/www/yourdomain.com/webalizer point to where you want to serve your stats from.  Usually some place under your web root.  You might want to protect it with an htaccess file.

HostName       yourdomain.com

GeoIP yes

GeoIPDatabase /usr/local/share/GeoIP/GeoIP.dat

Run webalizer

/usr/local/webalizer/bin/webalizer -c /usr/local/etc/webalizer/yourdomain.com.conf

If it runs fine add to run in your crontab.