Thursday 16 October 2014

Wordpress on Ubuntu 14.04

Wordpress is a free to use tool to create easy and fast your own website or blog. This entry shows how to easily install it on your own PC to use it as a webserver.
The installation is done on an Ubuntu 14.04LTS system. The installation is split in 3 steps and can be done in a few minutes.

Installation of the Server

Apache 2 is the most common web server application and is widely supported. Together with PHP and MySQL it provides a full capable web server. To install it with all the needed packages can be done with the following command.
$ sudo apt-get install lamp-server^
Download the latest version of wordpress from its server or get it with
$ wget https://wordpress.org/latest.tar.gz
and unzip it and into the directory /var/www/html/
sudo tar -xvzf latest.tar.gz -C /var/www/html/

Allow Wordpress to use your MySQL Server

Set up your MySQL Server so wordpress can access its database. I'd recommend to create new user with its independent database for wordpress to keep it separated from any other projects you might be running.
The MySQL Server can be updated using its own shell.
$ mysql -u root -p
There you can manage your databases and users. To create a wordpress user with its database we need the following 4 commands.
CREATE DATABASE wordpress;
CREATE USER 'wordpressUser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress . * TO 'wordpressUser'@'localhost';
FLUSH PRIVILEGES;
Quit the MySQL Shell with the command
quit

Install Wordpress

We are now ready to run the installation of wordpress. For this call your website in the browser at localhost/wordpress. Follow the instructions to complete the installation.
It might be possible that installation is not able to load the content when you try to access the web site from another server. In this case access the websites admin tool from your local host. On the page Settings you can change the web sites location from localhost to its actual address. This should solve the problem.

Sources:

Wednesday 7 May 2014

Simple Router

For a simple router without IP forwarding a DHCP Server and a Ethernet Bridge are needed. In a first step the Bridge gets installed. Afterwards the DHCP Server is added to the Bridge.

The router will provide a network on the Ethernet interfaces eth2, eth3, eth4 and eth5 with the basic address 192.168.1.0.

Installation Bridge

First install the bridge utils

apt-get install bridge-utils

To configure a bridge, the file /etc/network/interfaces needs to be adapted. The bridge itself can be reached on the address 192.168.1.1 for all clients.

auto br0
iface br0 inet static
address 192.168.1.1
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.1.255
bridge-ports eth2 eth3 eth4 eth5

Configuration of the DHCP Server

At first define the interfaced to be used in the file /etc/default/isc-dhcp3-server

INTERFACES="br0"

In a second step the subnet need to be defined. For this, the interface and the address range needs to be defined for each net. All this settings are to be done in the file /etc/dhcp/dhcpd.conf.

authoritative;

default-lease-time 600;
max-lease-time 7200;


subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.10 192.168.1.250;
  interface br0;
  option broadcast-address 192.168.1.255;
}

Start and Stop of the service

sudo service isc-dhcp-server restart
sudo service isc-dhcp-server start
sudo service isc-dhcp-server stop

Enable Multicast

To enable multicast groups to be routed over the bridge, the system needs to be able to manage multicast groups. A possible group manager is the pimd.

apt-get install pimd

The configuration file for pimd is /etc/pimd.conf. With pimd -l it's possible to reload the config file and adapt the changes. By default the service is activated for all interfaces. For this use I limited its activity to the bridge by excluding all other interfaces. The current mutlicast groups managed and the interfaces accessed can be shown with pimd -r.

Setup Gateway

To be able to access the internet from the created switch, the hosting computer needs to work as a gateway. With the following commands it's possible to forward the traffic. In my case the eth0 is connected to the internet. Therefore the br0 bridge interface needs to be forwarded to the eth0.

sudo iptables -A FORWARD -o eth0 -i br0 -s 192.168.1.0/24 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -F POSTROUTING
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

The commands need to be executed everytime after boot up since the iptables are rewritten everytime. This could be realized with a startup script or another approach would be to save the current iptable and reload it after boot up.

Source

Tuesday 6 May 2014

DHCP Server

How to install a DHCP Server on Ubuntu 12.04

The setup is a Ubuntu PC with 4 Ethernet ports.

eth2, eth3, eth4, eth5

Each port is in a separate subnet.

Install the DHCP-Server

apt-get install isc-dhcp-server

Configuration of the DHCP Server

At first define the interfaced to be used in the file /etc/default/isc-dhcp3-server

INTERFACES="eth2 eth3 eth4 eth5"

In a second step the subnets need to be defined. For this, the interface and the address range needs to be defined for each net. The lease times can be defined global for all nets. To prevent any other DHCP Server to interract with your subnet, the Server is set in authoritative mode.  All this settings are to be done in the file /etc/dhcp/dhcpd.conf.

authoritative;

default-lease-time 600;
max-lease-time 7200;


subnet 192.168.150.0 netmask 255.255.255.0 {
  range 192.168.150.10 192.168.150.250;
  interface eth2;
  option broadcast-address 192.168.150.255;
}


subnet 192.168.151.0 netmask 255.255.255.0 {
  range 192.168.151.10 192.168.151.250;
  interface eth3;
  option broadcast-address 192.168.151.200;
}

subnet 192.168.152.0 netmask 255.255.255.0 {
  range 192.168.152.10 192.168.152.250;
  interface eth4;
  option broadcast-address 192.168.152.255;
}

subnet 192.168.153.0 netmask 255.255.255.0 {
  range 192.168.153.10 192.168.153.250;
  interface eth5;
  option broadcast-address 192.168.153.255;
}

At last the interfaces need to be added to the subnets itself. Therefore just define the interfaces in the file /etc/network/interfaces by adding this lines.

auto eth2
iface eth2 inet static
address 192.168.150.1
netmask 255.255.255.0

auto eth3
iface eth3 inet static
address 192.168.151.1
netmask 255.255.255.0

auto eth4
iface eth4 inet static
address 192.168.152.1
netmask 255.255.255.0

auto eth5
iface eth5 inet static
address 192.168.153.1
netmask 255.255.255.0  

The following commands help to control the DHCP Server when trying out the changes

sudo service isc-dhcp-server restart
sudo service isc-dhcp-server start
sudo service isc-dhcp-server stop

Source:

http://askubuntu.com/questions/201746/dhcp-server-with-multiple-interfaces-on-ubuntu-destroys-default-gateway