Saturday, April 24, 2010

VIRT = SWAP + RES

While investigating some performance problem, I've faced the need to understand exactly what is the memory consumption of process on linux server.
While looking to be simple, it takes a while to figure out how different statistics are calculated.

The first tool to use, is of course, top command.
One should remember that not all flags are enabled by default. So, for example, to enable SWAP statistics, one should run top, press 'f' in order to mark needed fields, then press 'p' and enter.

For user space process, next formula is useful: VIRT = SWAP + RES, means total amount of memory used by process consists of amount of physical memory + amount of swapped memory.
% MEM shows percentage of RES relatively to Mem - total amount of physical memory, not including swap.

Thrashing and paging could be traced through nFLT and nDRT fields of top.

Full report about memory used by process and by included shared libraries one can get using pmam -x `pidof my_process`

Swap can be disabled by commenting out swap line in /etc/fstab file

Useful links:

Good description of top:
http://www.linuxforums.org/articles/using-top-more-efficiently_89.html

Article about pmap:
http://www.cyberciti.biz/tips/howto-find-memory-used-by-program.html

Wednesday, April 14, 2010

Saturday, March 6, 2010

How to configure BGP IPv6

In this chapter I will describe how to configure BGP router on Ubuntu with IPv6 support.
1. Install last version of quagga routing daemon via Synaptic Package Manager.
2. Enable BGP support in quagga:
gedit /etc/quagga/daemons
change bgpd value to 'yes'
bgpd=yes
3. Configure BGP protocol:
4. Restart quagga daemon:
/etc/init.d/quagga restart

Saturday, January 30, 2010

How to configure IPv6 tunnel

Here I will show several methods to configure IPv6 tunnel on Ubuntu machine.

Miredo

The first and the easiest one is to use miredo tool that uses teredo tunneling protocol (RFC 4380).This method works for NATed machines and doesn't require configuration of routers.
Go to System->Administration->Synaptic Packet Manager, search for miredo and install the product. After installation, service should be started automatically. You can use service commands to start/stop it:
service miredo start
service miredo stop

New interface called teredo was created.

teredo Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet6 addr: fe80::ffff:ffff:ffff/64 Scope:Link
inet6 addr: 2001:0:53aa:64c:8e1:636f:b04b:f84d/32 Scope:Global
UP POINTOPOINT RUNNING NOARP MTU:1280 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:96 (96.0 B)

To check that it works:
ping6 ::1 - ping loopback device
ping6 -I teredo fe80::ffff:ffff:ffff - IPv6 address starting with fe80, it's and address of local link, usually derived from MAC
ping6 2001:0:53aa:64c:8e1:636f:b04b:f84d
ping6 ipv6.google.com

ip -6 route - check routing table

Withdraws : teredo allows to have only /128 connection, means to subnet can be created on client side, but single peers only.

Hurricane Electric
Hurricane Electric is an IPv6 broker, offerring IPv6 subnets and IPv6 BGP service as well. First of all it needs to registrate and create account on their site.
I have Sofaware / Check Point router that connects to the internet via ADSL, means there is automatic NAT on all outbound connections. When creating the tunnel on HE site, you need to provide the dynamic IP that router receives as IPv4 client endpoint. Current router's IPV4 address can be checked by services like myIP. IPv4 server endpoint address and IPv6 addresses will be provided automatically when tunnel is created.
To configure tunnel interface, script provided on HE page can be used. The address of IPv4 end point should be local address of the machine and not the router. I use this script to confgire he-ipv6 interface.

#!/bin/bash

# Server's IPv4 IP
ipv4s=216.66.80.26

# Client IPv4 - local
ipv4c=192.168.7.144

# Server's side of point-to-point /64 allocation
ipv6s=2001:470:1f08:6fd::1/64

# User's side of point-to-point /64 allocation
ipv6c=2001:470:1f08:6fd::2/64

echo "Configuring HE connection"
echo "Tunnel on HE site must be configured with updated router IP"
echo "Router should be configured to forward protocol 41 to local IP"
echo "Server IPv4 IP: $ipv4s"
echo "Client IPv4 IP: $ipv4c"
echo "Server IPv4 IP: $ipv6s"
echo "Client IPv4 IP: $ipv6c"

ip tunnel add he-ipv6 mode sit remote $ipv4s local $ipv4c ttl 255
ip link set he-ipv6 up
ip -6 addr add $ipv6c dev he-ipv6
ip -6 route add ::/0 dev he-ipv6

The last step is to configure protocol 41 forwarding on the router. HE uses 6to4 incapsulation.
In Sofaware / Check Point router WebUI, go to Security->Rules.
Press Add Rule button in order to add new rule. The rule should Allow and Forward protocol 41 destinated to the router IP to the machine where he-ipv6 is configured.

Final check - ping6 ipv6.google.com