Monthly Archives: August 2013

Kickstart install Centos 6 using virt-install


virt-install --connect=qemu:///system --network=bridge:virbr0 --initrd-inject=/tmp/centos.ks --extra-args="ks=file:/centos.ks console=tty0 console=ttyS0,115200" \
--name=centos \
--disk /var/lib/libvirt/images/centos.qcow2,size=10,device=disk,bus=virtio,format=qcow2 \
--ram 750 \
--vcpus=1 \
--check-cpu \
--accelerate \
--hvm \
--location=http://mirror.duomenucentras.lt/centos/6/os/x86_64/ \
--nographics

I am using kickstart file:

text
install
lang en_US.UTF-8
keyboard uk
network –bootproto=dhcp –device=eth0
reboot
authconfig –enableshadow –passalgo=sha512
selinux –enforcing
timezone –utc Europe/Vilnius
bootloader –location=mbr –driveorder=vda –append=”crashkernel=auto rhgb quiet”
zerombr
ignoredisk –only-use=vda
clearpart –linux –drives=vda –all –initlabel
rootpw  mypassword
#autopart
part /boot –fstype=ext4 –size=50
part / –fstype=ext4 –size=2000 –grow
part swap –size=500
part /home –fstype=ext4 –size=500
%packages –excludedocs –nobase
@Core
acpid

virt-install install Fedora 19 on server

If you love Fedora and want use it on your server, but don’t like graphical interface. Its not problem, lets download Fedora ISO image like Fedora-Live-LXDE-x86_64-19-1.iso from http://fedoraproject.org/en/get-fedora-options

virt-install –connect qemu:///system -n Fedora19 –disk path=/var/lib/libvirt/images/guest.qcow2,format=qcow2,bus=virtio,cache=none –cdrom /tmp/Fedora-Live-LXDE-x86_64-19-1.iso –video=vga –network=bridge:virbr0,model=e1000 –accelerate –noapic –keymap=en-us –ram 1024

before you should create qcow disk image:

qemu-img create -f qcow2 /var/lib/libvirt/images/guest.qcow2 10G -o preallocation=metadata

I am using bridge networking so can access Fedora using SSH. You should disable LXDE graphical interface, because I guess you don’t need it.

ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target

and reboot your Fedora guest

Mongrel2

What Is Mongrel2?

Mongrel2 is an applicationlanguage, and network architecture agnostic web server that focuses on web applications using modern browser technologies.

Mongrel2 supports 17 languages and platforms, HTTP, Flash sockets, WebSockets, Long Polling, and many ways to deploy and hack on it.

Getting Started

wget https://github.com/zedshaw/mongrel2/tarball/v1.8.0

CentOS CentOS CentOS

I love Centos OS. CentOS is an Enterprise-class Linux Distribution derived from sources freely provided to the public by a prominent North American Enterprise Linux vendor.  CentOS conforms fully with the upstream vendor’s redistribution policy and aims to be 100% binary compatible. (CentOS mainly changes packages to remove upstream vendor branding and artwork.)  CentOS is free.
CentOS is developed by a small but growing team of core developers.  In turn the core developers are supported by an active user community including system administrators, network administrators, enterprise users, managers, core Linux contributors and Linux enthusiasts from around the world.

CentOS has numerous advantages over some of the other clone projects including:  an active and growing user community, quickly rebuilt, tested, and QA’ed errata packages, an extensive mirror network, developers who are contactable and responsive, multiple free support avenues including IRC ChatMailing ListsForums, a dynamic FAQ.

Nameservers are lame

Domain NS records Nameserver records returned by the parent servers are:

ns01.dot.tk.   [‘88.198.132.99’]   [TTL=300]
ns02.dot.tk.   [‘217.68.243.19’]   [TTL=300]
ns03.dot.tk.   [‘85.214.136.249’]   [TTL=300]
ns04.dot.tk.   [‘217.199.176.121’]   [TTL=300]

a.ns.tk was kind enough to give us that information.

Error Nameservers are lame ERROR: looks like you have lame nameservers. The following nameservers are lame:
217.68.243.19
217.199.176.121
85.214.136.249

It seems .TK DNS name servers really have some problems:

[vit@localhost ~]$ host linux4you.tk
Host linux4you.tk not found: 2(SERVFAIL)

After 5 minutes:

[vit@localhost ~]$ host linux4you.tk
linux4you.tk has address 31.170.167.238
linux4you.tk mail is handled by 0 ASPMX.L.GOOGLE.COM.

 

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.

With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks.

The physical volumes are combined into logical volumes, with the exception of the /boot/ partition. The /boot/ partition cannot be on a logical volume group because the boot loader cannot read it. If the root (/) partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group.

Since a physical volume cannot span over multiple drives, to span over more than one drive, create one or more physical volumes per drive.

lvg

The volume groups can be divided into logical volumes, which are assigned mount points, such as /home and / and file system types, such as ext2 or ext3. When “partitions” reach their full capacity, free space from the volume group can be added to the logical volume to increase the size of the partition. When a new hard drive is added to the system, it can be added to the volume group, and partitions that are logical volumes can be increased in size.

Read more http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-lvm.html

linux socets

ss command is used to show socket statistics. It can display stats for PACKET sockets, TCP sockets, UDP sockets, DCCP sockets, RAW sockets, Unix domain sockets, and much more. It allows showing information similar to netstatcommand. It can display more TCP and state information than other tools. It is a new, incredibly useful and faster (as compare to netstat) tool for tracking TCP connections and sockets. SS can provide information about:

  • All TCP sockets.
  • All UDP sockets.
  • All established ssh / ftp / http / https connections.
  • All local processes connected to X server.
  • Filtering by state (such as connected, synchronized, SYN-RECV, SYN-SENT,TIME-WAIT), addresses and ports.
  • All the tcp sockets in state FIN-WAIT-1 and much more.

cidr ip block

This is very useful if you can't remember netmask or how much IP's are usable and belongs IP block.

IP/CIDR Δ to last IP addr Mask Hosts (*) Size Notes
a.b.c.d/32 +0.0.0.0 255.255.255.255 1 1/256 C
a.b.c.d/31 +0.0.0.1 255.255.255.254 2 1/128 C d = 0 … (2n) … 254
a.b.c.d/30 +0.0.0.3 255.255.255.252 4 1/64 C d = 0 … (4n) … 252
a.b.c.d/29 +0.0.0.7 255.255.255.248 8 1/32 C d = 0 … (8n) … 248
a.b.c.d/28 +0.0.0.15 255.255.255.240 16 1/16 C d = 0 … (16n) … 240
a.b.c.d/27 +0.0.0.31 255.255.255.224 32 ⅛ C d = 0 … (32n) … 224
a.b.c.d/26 +0.0.0.63 255.255.255.192 64 ¼ C d = 0, 64, 128, 192
a.b.c.d/25 +0.0.0.127 255.255.255.128 128 ½ C d = 0, 128
a.b.c.0/24 +0.0.0.255 255.255.255.000 256 1 C
a.b.c.0/23 +0.0.1.255 255.255.254.000 512 2 C c = 0 … (2n) … 254
a.b.c.0/22 +0.0.3.255 255.255.252.000 1,024 4 C c = 0 … (4n) … 252
a.b.c.0/21 +0.0.7.255 255.255.248.000 2,048 8 C c = 0 … (8n) … 248
a.b.c.0/20 +0.0.15.255 255.255.240.000 4,096 16 C c = 0 … (16n) … 240
a.b.c.0/19 +0.0.31.255 255.255.224.000 8,192 32 C c = 0 … (32n) … 224
a.b.c.0/18 +0.0.63.255 255.255.192.000 16,384 64 C c = 0, 64, 128, 192
a.b.c.0/17 +0.0.127.255 255.255.128.000 32,768 128 C c = 0, 128
a.b.0.0/16 +0.0.255.255 255.255.000.000 65,536 256 C = 1 B
a.b.0.0/15 +0.1.255.255 255.254.000.000 131,072 2 B b = 0 … (2n) … 254
a.b.0.0/14 +0.3.255.255 255.252.000.000 262,144 4 B b = 0 … (4n) … 252
a.b.0.0/13 +0.7.255.255 255.248.000.000 524,288 8 B b = 0 … (8n) … 248
a.b.0.0/12 +0.15.255.255 255.240.000.000 1,048,576 16 B b = 0 … (16n) … 240
a.b.0.0/11 +0.31.255.255 255.224.000.000 2,097,152 32 B b = 0 … (32n) … 224
a.b.0.0/10 +0.63.255.255 255.192.000.000 4,194,304 64 B b = 0, 64, 128, 192
a.b.0.0/9 +0.127.255.255 255.128.000.000 8,388,608 128 B b = 0, 128
a.0.0.0/8 +0.255.255.255 255.000.000.000 16,777,216 256 B = 1 A
a.0.0.0/7 +1.255.255.255 254.000.000.000 33,554,432 2 A a = 0 … (2n) … 254
a.0.0.0/6 +3.255.255.255 252.000.000.000 67,108,864 4 A a = 0 … (4n) … 252
a.0.0.0/5 +7.255.255.255 248.000.000.000 134,217,728 8 A a = 0 … (8n) … 248
a.0.0.0/4 +15.255.255.255 240.000.000.000 268,435,456 16 A a = 0 … (16n) … 240
a.0.0.0/3 +31.255.255.255 224.000.000.000 536,870,912 32 A a = 0 … (32n) … 224
a.0.0.0/2 +63.255.255.255 192.000.000.000 1,073,741,824 64 A a = 0, 64, 128, 192
a.0.0.0/1 +127.255.255.255 128.000.000.000 2,147,483,648 128 A a = 0, 128
0.0.0.0/0 +255.255.255.255 000.000.000.000 4,294,967,296 256 A
Also please look there:


Netmask              Netmask (binary)                 CIDR     Notes    
_____________________________________________________________________________
255.255.255.255  11111111.11111111.11111111.11111111  /32  Host (single addr)
255.255.255.254  11111111.11111111.11111111.11111110  /31  Unuseable
255.255.255.252  11111111.11111111.11111111.11111100  /30    2  useable
255.255.255.248  11111111.11111111.11111111.11111000  /29    6  useable
255.255.255.240  11111111.11111111.11111111.11110000  /28   14  useable
255.255.255.224  11111111.11111111.11111111.11100000  /27   30  useable
255.255.255.192  11111111.11111111.11111111.11000000  /26   62  useable
255.255.255.128  11111111.11111111.11111111.10000000  /25  126  useable
255.255.255.0    11111111.11111111.11111111.00000000  /24 "Class C" 254 useable

255.255.254.0    11111111.11111111.11111110.00000000  /23    2  Class C's
255.255.252.0    11111111.11111111.11111100.00000000  /22    4  Class C's
255.255.248.0    11111111.11111111.11111000.00000000  /21    8  Class C's
255.255.240.0    11111111.11111111.11110000.00000000  /20   16  Class C's
255.255.224.0    11111111.11111111.11100000.00000000  /19   32  Class C's
255.255.192.0    11111111.11111111.11000000.00000000  /18   64  Class C's
255.255.128.0    11111111.11111111.10000000.00000000  /17  128  Class C's
255.255.0.0      11111111.11111111.00000000.00000000  /16  "Class B"

255.254.0.0      11111111.11111110.00000000.00000000  /15    2  Class B's
255.252.0.0      11111111.11111100.00000000.00000000  /14    4  Class B's
255.248.0.0      11111111.11111000.00000000.00000000  /13    8  Class B's
255.240.0.0      11111111.11110000.00000000.00000000  /12   16  Class B's
255.224.0.0      11111111.11100000.00000000.00000000  /11   32  Class B's
255.192.0.0      11111111.11000000.00000000.00000000  /10   64  Class B's
255.128.0.0      11111111.10000000.00000000.00000000  /9   128  Class B's
255.0.0.0        11111111.00000000.00000000.00000000  /8   "Class A"

254.0.0.0        11111110.00000000.00000000.00000000  /7
252.0.0.0        11111100.00000000.00000000.00000000  /6
248.0.0.0        11111000.00000000.00000000.00000000  /5
240.0.0.0        11110000.00000000.00000000.00000000  /4
224.0.0.0        11100000.00000000.00000000.00000000  /3
192.0.0.0        11000000.00000000.00000000.00000000  /2
128.0.0.0        10000000.00000000.00000000.00000000  /1
0.0.0.0          00000000.00000000.00000000.00000000  /0   IP space

                                   Net     Host    Total
Net      Addr                      Addr    Addr    Number
Class   Range      NetMask         Bits    Bits   of hosts
----------------------------------------------------------
A        0-127    255.0.0.0         8      24     16777216   (i.e. 114.0.0.0)
B      128-191    255.255.0.0      16      16        65536   (i.e. 150.0.0.0)
C      192-254    255.255.255.0    24       8          256   (i.e. 199.0.0.0)
D      224-239    (multicast)
E      240-255    (reserved)
F      208-215    255.255.255.240  28       4           16
G      216/8      ARIN - North America
G      217/8      RIPE NCC - Europe
G      218-219/8  APNIC
H      220-221    255.255.255.248  29       3            8   (reserved)
K      222-223    255.255.255.254  31       1            2   (reserved)
(ref: RFC1375 & http://www.iana.org/assignments/ipv4-address-space )
(               http://www.iana.org/numbers.htm                    )
----------------------------------------------------------

The current list of special use prefixes:
	0.0.0.0/8	
	127.0.0.0/8
	192.0.2.0/24
	10.0.0.0/8
	172.16.0.0/12
	192.168.0.0/16
	169.254.0.0/16
	all D/E space
(ref: RFC1918 http://www.rfc-editor.org/rfc/rfc1918.txt   )
(       or     ftp://ftp.isi.edu/in-notes/rfc1918.txt     )
(rfc search:   http://www.rfc-editor.org/rfcsearch.html   )
(              http://www.ietf.org/ietf/1id-abstracts.txt )
(              http://www.ietf.org/shadow.html            )

Martians: (updates at: www.iana.org/assignments/ipv4-address-space )
 no ip source-route
 access-list 100 deny   ip host 0.0.0.0 any
  deny ip 0.0.0.0         0.255.255.255  any log  ! antispoof
  deny ip 0.0.0.0 0.255.255.255  0.0.0.0 255.255.255.255 ! antispoof
  deny ip any             255.255.255.128 0.0.0.127 ! antispoof
  deny ip host            0.0.0.0        any log  ! antispoof
  deny ip host            [router intf]  [router intf] ! antispoof
  deny ip xxx.xxx.xxx.0   0.0.0.255      any log  ! lan area
  deny ip 0/8             0.255.255.255  any log  ! IANA - Reserved
  deny ip 1/8             0.255.255.255  any log  ! IANA - Reserved
  deny ip 2/8             0.255.255.255  any log  ! IANA - Reserved
  deny ip 5/8             0.255.255.255  any log  ! IANA - Reserved
  deny ip 7/8             0.255.255.255  any log  ! IANA - Reserved
  deny ip 10.0.0.0        0.255.255.255  any log  ! IANA - Private Use
  deny ip 23/8            0.255.255.255  any log  ! IANA - Reserved
  deny ip 27/8            0.255.255.255  any log  ! IANA - Reserved
  deny ip 31/8            0.255.255.255  any log  ! IANA - Reserved
  deny ip 36-37/8         0.255.255.255  any log  ! IANA - Reserved
  deny ip 39/8            0.255.255.255  any log  ! IANA - Reserved
  deny ip 41-42/8         0.255.255.255  any log  ! IANA - Reserved
  deny ip 50/8            0.255.255.255  any log  ! IANA - Reserved
  deny ip 58-60/8         0.255.255.255  any log  ! IANA - Reserved
  deny ip 69-79/8         0.255.255.255  any log  ! IANA - Reserved
  deny ip 82-95/8         0.255.255.255  any log  ! IANA - Reserved
  deny ip 96-126/8        0.255.255.255  any log  ! IANA - Reserved
  deny ip 127/8           0.255.255.255  any log  ! IANA - Reserved
  deny ip 169.254.0.0     0.0.255.255    any log  ! link-local network
  deny ip 172.16.0.0      0.15.255.255   any log  ! reserved
  deny ip 192.168.0.0     0.0.255.255    any log  ! reserved
  deny ip 192.0.2.0       0.0.0.255      any log  ! test network
  deny ip 197/8           0.255.255.255  any log  ! IANA - Reserved
  deny ip 220/8           0.255.255.255  any log  ! IANA - Reserved
  deny ip 222-223/8       0.255.255.255  any log  ! IANA - Reserved
  deny ip 224.0.0.0       31.255.255.255 any log  ! multicast
  deny ip 224.0.0.0       15.255.255.255 any log  ! unless MBGP-learned routes
  deny ip 224-239/8       0.255.255.255  any log  ! IANA - Multicast
  deny ip 240-255/8       0.255.255.255  any log  ! IANA - Reserved

filtered source addresses
  0/8                 ! broadcast
  10/8                ! RFC 1918 private
  127/8               ! loopback
  169.254.0/16        ! link local
  172.16.0.0/12       ! RFC 1918 private
  192.0.2.0/24        ! TEST-NET
  192.168.0/16        ! RFC 1918 private
  224.0.0.0/4         ! class D multicast
  240.0.0.0/5         ! class E reserved
  248.0.0.0/5         ! reserved
  255.255.255.255/32  ! broadcast

ARIN administrated blocks: (http://www.arin.net/regserv/IPStats.html)
   24.0.0.0/8 (portions of)
   63.0.0.0/8
   64.0.0.0/8
   65.0.0.0/8
   66.0.0.0/8
  196.0.0.0/8
  198.0.0.0/8
  199.0.0.0/8
  200.0.0.0/8
  204.0.0.0/8
  205.0.0.0/8
  206.0.0.0/8
  207.0.0.0/8
  208.0.0.0/8
  209.0.0.0/8
  216.0.0.0/8
----------------------------------------------------------

well known ports: (rfc1700.txt)
 www.iana.org/assignments/port-numbers

protocol numbers:
 www.iana.org/assignments/protocol-numbers
 www.iana.org/numbers.htm

ICMP(Types/Codes)
 Testing Destination Reachability & Status
  (0/0)  Echo-Reply
  (8/0)  Echo
 Unreachable Destinations
  (3/0)  Network Unreachable
  (3/1)  Host Unreachable
  (3/2)  Protocol Unreachable
  (3/3)  Port Unreachable
  (3/4)  Fragmentaion Needed and DF set (Pkt too big)
  (3/5)  Source Route Failed
  (3/6)  Network Unknown
  (3/7)  Host Unknown
  (3/9)  DOD Net Prohibited
  (3/10) DOD Host Prohibited
  (3/11) Net TOS Unreachable
  (3/12) Host TOS Unreachable
  (3/13) Administratively Prohibited
  (3/14) Host Precedence Unreachable
  (3/15) Precedence Unreachable
 Flow Control
  (4/0)  Source-Quench [RFC 1016]
 Route Change Requests from Gateways
  (5/0)  Redirect Datagrams for the Net
  (5/1)  Redirect Datagrams for the Host
  (5/2)  Redirect Datagrams for the TOS and Net
  (5/3)  Redirect Datagrams for the TOS and Host
 Router
  (6/-)  Alternate-Address
  (9/0)  Router-Advertisement
  (10/0) Router-Solicitation
 Detecting Circular or Excessively Long Routes
  (11/0) Time to Live Count Exceeded
  (11/1) Fragment Reassembly Time Exceeded
 Reporting Incorrect Datagram Headers
  (12/0) Parameter-Problem
  (12/1) Option Missing
  (12/2) No Room for Option
 Clock Synchronization and Transit Time Estimation
  (13/0) Timestamp-Request
  (14/0) Timestamp-Reply
 Obtaining a Network Address (RARP Alternative)
  (15/0) Information-Request
  (16/0) Information-Reply
 Obtaining a Subnet Mask [RFC 950]
  (17/0) Address Mask-Request
  (18/0) Address Mask-Reply
 Other
  (30/0) Traceroute
  (31/0) Conversion-Error
  (32/0) Mobile-Redirect

Ref: [RFC 792] [RFC 896] [RFC 950] [RFC 1016]
  www.cisco.com/univercd/cc/td/doc/product/lan/cat6000/sw_5_3/cofigide/qos.htm#19774

Decimal system Prefix's
              Factor               Exponent  Prefix
---------------------------------------------------
 1 000 000 000 000 000 000 000 000...10^24....yotta
     1 000 000 000 000 000 000 000...10^21....zetta
         1 000 000 000 000 000 000...10^18....exa
             1 000 000 000 000 000...10^15....peta
                 1 000 000 000 000...10^12....tera
                     1 000 000 000...10^9.....giga
                         1 000 000...10^6.....mega
                             1 000...10^3.....kilo
                               100...10^2.....hecto
                                10...10^1.....deka
                               0.1...10^-1....deci
                              0.01...10^-2....centi
                             0.001...10^-3....milli
                         0.000 001...10^-6....micro
                     0.000 000 001...10^-9....nano
                 0.000 000 000 001...10^-12...pico
             0.000 000 000 000 001...10^-15...femto
         0.000 000 000 000 000 001...10^-18...atto
     0.000 000 000 000 000 000 001...10^-21...zepto
 0.000 000 000 000 000 000 000 001...10^-24...yocto
---------------------------------------------------

Convert Fahrenheit <> Celsius:
 Celsius = (Fahrenheit - 32) / 1.8
 Fahrenheit = (Celsius * 1.8) + 32

bootable ISO

The syntax for using the mkisofs command for creating an empty ISO image ismkisofs -o . assuming you are currently in an empty directory. E.g. mkisofs -o test.iso . will create an empty ISO image called test.iso.

The syntax for copying a file to an already created ISO image is growisofs -M -graft-points =. E.g. growisofs -M test.iso -graft-points /folder/new.txt=old.txt will copy the file old.txt to the test.iso image, place it under the directory “folder” and rename it to new.txt.

The command to mount the ISO image is mount -t iso9660 -o loop. E.g.mount -t iso9660 -o loop test.iso /mnt/cd will mount test.iso ISO image to the directory /mnt/cd.

To unmount: umount /mnt/cd

Using ISOLINUX

http://syslinux.zytor.com/wiki/index.php/ISOLINUX

mkdir CD_root
cd CD_root
mkdir isolinux
cp /usr/lib/syslinux/isolinux.bin isolinux/
vi isolinux/isolinux.cfg

cd ..
mkdir images
mkdir kernel
cp /usr/lib/syslinux/memdisk kernel/

cd ..
mkisofs -o output.iso 
    -b isolinux/isolinux.bin -c isolinux/boot.cat 
    -no-emul-boot -boot-load-size 4 -boot-info-table CD_root

The ISO file can be burned to create a bootable CD.