Configurate Windows 2008 Server Core

Here are som useful stuff when installing and configurate Windows 2008 Server Core.

Network
Show network interfaces
> netsh interface ipv4 show interfaces

Rename network interface
> netsh interface set interface name = <interface name> newname = <new interface name>

Change static IP-address
> netsh interface ipv4 set adress ”<interface name>” static 192.168.0.1 255.255.25.0 192.168.0.1

Change to DHCP
> netsh interface ipv4 set addresses name=”<interface name>” source=dhcp

Show IP-address
> netsh interface ipv4 show addresses

Add primery DNS server
> netsh interface ipv4 set dnsserver name=”<interface name>” source=static address=<primery dns servers ip-address>

Add secondary DNS server
> netsh interface ipv4 add dnsserver name=”<interface name>” address=<secondary dns servers ip-address>

Enable Remote Administration in firewall
> netsh advfirewall firewall set rule group=”Remote Administration” new enable=yes

Enable Windows Firewall Remote Administration in firewall
> netsh advfirewall firewall set rule group=”Windows Firewall Remote Management” new enable=yes

Disable firewall
> netsh firewall set opmode disable

Enable firewall
> netsh firewall set opmode enable

Show computername
> hostname

Change computername
> netdom renamecomputer <computer name> /newname:<new computer name>

Change name of a domain-joined server
> netdom renamecomputer %computername% /NewName:<new computer name> /userd:<domain\username> /password:*

Join a domain
> netdom join %computername% /domain:<domain> /userd:<username> /passwordd:*

Remove computer from domain
> netdom remove

Enable Remote Desktop. Only support Windows Vista/2008 clients
> Cscript %windir%\system32\SCRegEdit.wsf /ar 0

Enable Remote Desktop. Support Windows XP/2003/Vista/2008 clients
> Cscript %windir%\system32\SCRegEdit.wsf /ar 0
> Cscript %windir%\system32\SCRegEdit.wsf /cs 0

Users, Groups & seciruity
Add a user to the local Administrators group
> net localgroup Administrators /add <domain>\<username>

Remove a user from the local Administrators group
> net localgroup Administrators /delete <domain>\<username>

Change administrator password
> net user administrator *

Show security settings on a folder or file
> cacls <file or folder path>

KMS (
Key Management Service)
Install KMS
> slmgr -ipk <KMS key>

KMS activation
> slmgr -ato

Display KMS license information
> slmgr – dlv

Check for KMS in DNS
> nslookup -type=srv _vlmcs._tcp

Misc
Configure the paging file
>wmic pagefileset where name=”<path/filename>” set InitialSize=<initialsize>,MaximumSize=<maxsize>

Reboot server
> shutdown /r /t 0

Shutdown server
> shutdown /s /t 0

List event logs type
> wevtutil el

List running services
> sc query
> net start

Start a service
sc start <service name> or net start <service name>

Stop a service
> sc stop <service name>

> net stop <service name>

Stop/kill a process
> taskkill /PID <process ID>

Move file
> move “z:\Windows6.0-KB950050-x64.msu” “c:\Windows6.0-KB950050-x64.msu”

Copy file
> copy “z:\Windows6.0-KB950050-x64.msu” “c:\Windows6.0-KB950050-x64.msu”

Roles
Show server roles
> oclist

Install server roles
> ocsetup

example:
> start /w ocsetup Microsoft-Hyper-V

Hyper-V
Install virtual machine integrated components
Mount integrated components cd from action menu.
D:\support\amd64\setup.exe or D:\support\x86\setup.exe

Update Hyper-V
Download and copy Windows6.0-KB950050-x64.msu to your core server.
Example:
Download Windows6.0-KB950050-x64.msu to your fileserver.

From Core server:
> net use z: \\fileserver\share\
> Z:
> copy Windows6.0-KB950050-x64.msu c:\
> C:
> net use z: delete
> Windows6.0-KB950050-x64.msu

Hidden setting in SMS for SMTP 5 (Advanced Attributes)

In Symantec Mail Security for SMTP 5 there is a hidden setting page which allow you to change inbound and outbound SMTP greeting, SPAM notification URL, Email archive x-header name etc.

To acces the hidden setting page in SMS for SMTP Control Center simply do the following:
Click on Settings and then click on the white area just outside to right of the “alert settings” box and then press shift + a (press and hold down shift while pressing a).

Now you get access to the advanced attributes.

www backup script

Here is a simple script that creates a RAR file of /var/www/

1. Create a script folder.
# sudo mkdir /script

2. Create a backup folder and a destnation folder for the www rar file.
# sudo mkdir /backup /backup/www

3. Create a script file.
# sudo nano /script/wwwbackup.sh

Add the following:
#!/bin/bash
/usr/bin/rar a -r /backup/www/www.rar /var/www/

This will will create a rar file of the www directory. The file patch will be /backup/www/www.rar

When done exit Nano and save he script file.

4. Verify that the script file is correct.
# sudo cat /script/wwwbackup.sh

5.  Give the script execution rights.
# sudo chmod +x /script/wwwbackup.sh

6. Instal Cron (Same as schedule tasks in Windows)
# sudo aptitude install cron

7. Edit crontab.
# crontab -e

Add the following t crontab:
15 23 * * * /script/wwwbackup.sh

This means that wwwbackup.sh will start every day 23.15.

8. Verify crontab.
# crontab -l

9. Verify the next day that the backup file exists in /backup/www/.

Run the wwwbackup script manually:
# /script/./wwwbackup.sh

MySQL backup script

1. Create a script folder.
# sudo mkdir /script

2. Create a backup folder and a destnation folder for the MySQL files.
# sudo mkdir /backup /backup/mysql

3. Create a script file.
# sudo nano /script/mysqlbackup.sh

At the start of the file add:
#!/bin/bash

On the next row write your script.

Here are a few script examples. In the examples the MySQL user is  root and the password is Qwerty12.

Example 1. Will backup alla databases into one single file.
#!/bin/bash
/usr/bin/mysqldump –u root pQwerty12 –all-databases > /backup/mysql/all-databases.sql

Example 2. Will backup the database named mysite.
#!/bin/bash
/usr/bin/mysqldump –u root pQwerty12 –databases mysite > /backup/mysql/mysite.sql

When done exit Nano and save he script file.

4. Verify that the script file is correct.
# sudo cat /script/mysqlbackup.sh

5. Give the script execution rights.
# sudo chmod +x /script/mysqlbackup.sh

6. Instal Cron (Same as schedule tasks in Windows)
# sudo aptitude install cron

7. Edit crontab.
# crontab -e

Add the following t crontab:
01 23 * * * /script/mysqlbackup.sh

This means that mysqlbackup.sh will start every day 23.01.

8. Verify crontab.
# crontab -l

9. Verify the next day that the backup file exists in /backup/mysql/.

Run the mysqlbackup script manually:
# /script/./mysqlbackup.sh

Configurate the network interface

1. Configurate the IP-address
# sudo nano /etc/network/interfaces/

config example:
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
gateway192.168.0.1

After the configuration is done restart the network interface:
# sudo /etc/init.d/networking restart

2. Configurate the DNS
# sudo nano /etc/reslov.conf

config example:
nameserver 192.168.0.2
nameserver 192.168.0.3

Installing a LAMP-server (LinuxApacheMysqlPHP)

Here are som useful things to install and config when running a LAMP-server under Ubuntu JeOS.

1. Install Ubuntu JeOS.

2. Update aptitudes packetlist.
# sudo aptitude update

3. Update/Upgrade the system.
# sudo aptitude full-upgrade -y

4. If the kernel was updated, restart the system.
# sudo reboot

5.  Install SSH
# sudo aptitude install openssh-server -y

6. Install firewall
# sudo aptitude install ufw  -y

7. Install the text editor Nano
# sudo aptitude install nano -y

8. Install LAMP (LinuxApacheMysqlPHP)
# sudo tasksel install lamp-server

9.  Instal PHPMyAdmin
# sudo aptitude install phpmyadmin -y

10. Install RAR and UNRAR (can be useful if your moving a site to this server)
# sudo aptitude install rar unrar -y

11. Install FTP (can be useful if your moving a site to this server)
# sudo aptitude install ftp -y

12. Install Sendmail (I use sendmail when using Joomla)
# sudo aptitude install sendmail -y

13. Configurate the firewall
# sudo ufw enable && sudo ufw allow 22
# sudo ufw default deny
# sudo ufw allow 80

14. Configurate Apache

Virtual host config

15. Configurate the network interface

Configurate the network interface

16. Configurate LAMP-server backup script
MySQL backup script: https://headadmin.net/?p=14
WWW backup script: https://headadmin.net/?p=19

Virtual host config

Virtual hosts in Apache are the same thing as host headers in Windows IIS, allowing the admin to have multiple websites on one webserver with one IP-address.

1. Create a folder for the new virtual host.
# sudo mkdir /var/www/www.mysite.com

2. Change owner on the virtual host folder. www-data is the same as IUSR under Windows.
# sudo chown -R www-data /var/www/www.mysite.com

3. Edit the Apache configuration file.
# sudo vi /etc/apache2/sites-enabled/000-defualt

4. Add the following text at the end of the file.
<VirtualHost *>
DocumentRoot /var/www/www.mysite.com
ServerName www.mysite.com
ServerAlias mysite.com
</VirtualHost>

5. Restart Apache to use the new configuration.
# sudo /etc/init.d/apache2 restart

http://httpd.apache.org/docs/1.3/vhosts/

1 9 10 11