CentOS 7 cloned XFS to EXT4

In this tutorial we are going to clone a CentOS server created with XFS partitions. Our Backup software r1soft do not support XFS partitions. So we are going to clone the server in a different server with rsync and EXT4 partitions. a) Create all the partions on the new server with cfdisk ( try to keep all the partitions with the same order and the same size) sda 8:0 0 20G 0 disk —-> sda1 8:1 0 517.7M 0 part /boot —-> sda2 8:2 0 19.5G 0 part / sdb 8:16 0 10G 0 disk —-> sdb1 8:17 0 2G 0 part [SWAP] —-> sdb2 8:18 0 8G 0 part /home sr0 11:0 1 1024M 0 rom b) Disable Selinux on the original server and reboot it c) Stop the database on the original machine (in case you have one) d) Create the following path in which we are going to mount out system and give format to the new partitions mkswap /dev/sdb1 mkfs.ext4 /dev/sda1 mkfs.ext4 /dev/sda2 mkfs.ext4 /dev/sdb2 mkdir -p /mnt/centos e) Mount the partitions mount /dev/sda2 /mnt/centos/ mkdir -p {/mnt/centos/boot,/mnt/centos/dev,/mnt/centos/sys,/mnt/centos/proc,/mnt/centos/tmp,/mnt/centos/home} mount /dev/sda1 /mnt/centos/boot mount /dev/sdb2 /mnt/centos/home/ f) Rsync everything from the original sever via ssh. The 192.168.1.115 is Continue reading CentOS 7 cloned XFS to EXT4

Customized Linux CD/USB

Live CD project 1) Step one Set a virtual machine and load the live CD “livedvd-amd64-multilib-20140826.iso” Get the gentoo live cd from # cd ~ # wget https://bouncer.gentoo.org/fetch/gentoo-20140826-livedvd/amd64/wgethttps://ftp.snt.utwente.nl/pub/os/linux/gentoo/releases/amd64/20140826/livedvd-amd64-multilib-20140826.iso Characteristics of my Virtual Machine are below. You can modify those setting according to your host machine resources Load the Virtual Machine using the default option once you are inside of the VM, there are three things that you have to change 1) Active the sshd # sudo /etc/init.d/sshd start 2) Change the roort password # sudo passwd root 3) Get your ip # ifconfig # emerge -av squashfs-tools <—- help to create the Filesystem later *From now, you can access the virtual machine from your favorite terminal (I’m using Debian), if you are in windows, use putty. Once you get inside of your live cd, you can type # lsblk As you can see, I created a 40G HD NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 40G 0 disk <——Here! sr0 11:0 1 2.8G 0 rom /mnt/cdrom loop0 7:0 0 2.6G 1 loop /mnt/livecd Well, in order to access those 40G and build our customized LiveCD, we have to create a partition Continue reading Customized Linux CD/USB

SQUID ( Transparent + SquidGuard + HTTPS filtering) CentOS 6.5

Don’t forget to set your server as router between your networks #sysctl -w net.ipv4.ip_forward=1 #you can find this file under /etc #iptables -t nat -A POSTROUTING -o eth0 -j MASQUERDE #this is going to hide your internal ip address and present all packages as eth0 interface.   INSTALL SQUID # yum install squid INSTALL EPEL Redhat 6 # wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm # sudo rpm -Uvh epel-release-6*.rpm   INSTALL EPEL Redhat 7 # wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-1.noarch.rpm # sudo rpm -Uvh epel-release-7*.rpm Install SquidGuard # yum install squidGuard   iptables configuration #iptables -t nat -A PREROUTING -i eth1 -p tcp –dport 80 -J DNAT –to 192.168.3.1 :8080 #192.168.3.1 is the gatways interface for my LAN ====> eth1 # iptables -t filter -A INPUT -p tcp –dport 8080 -j ACCEPT # netstat -ant Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 192.168.3.1:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 192.168.3.1:8080 0.0.0.0:* LISTEN tcp 0 0 192.168.1.9:22 192.168.3.5:57801 ESTABLISHED tcp 0 64 192.168.1.9:22 192.168.1.149:51888 ESTABLISHED tcp 0 0 192.168.1.9:22 192.168.3.5:57707 ESTABLISHED tcp 0 0 :::22 :::* LISTEN tcp 0 0 ::1:953 Continue reading SQUID ( Transparent + SquidGuard + HTTPS filtering) CentOS 6.5

DDNS & DHCPD CENTOS 6.5

Installing Packages # yum install bind* -y Install dhcpd # yum install dhcp –y   Configuring BIND Edit the file /etc/named.conf Add the following lines ++++++++++++++++++++++++++++++++++++++++++++++++++++ options { listen-on port 53 { 192.168.3.1; }; # You also can listen in all network interfaces or only on the interface connected to your LAN directory “/var/named”; dump-file “/var/named/data/cache_dump.db”; statistics-file “/var/named/data/named_stats.txt”; memstatistics-file “/var/named/data/named_mem_stats.txt”; allow-query { localhost; 192.168.3.0/24; }; # you can allow everybody or only an specific subnet recursion yes; forwarders { 216.19.176.6; 216.19.176.7; 8.8.8.8; }; # add the DNSs you want logging { channel default_debug { file “data/named.run”; severity dynamic; }; }; #Zones zone “.” IN { type hint; file “named.ca”; }; zone “mrobp.com” IN { # Add the name of the domain in my case is mrobp.com type master; file “dynamic/db.mrobp.com”; #Add the name of the file under the directory /var/named/dynamic allow-update { key rndc-key; }; # This is the Key that Allow update the DNS records notify yes; }; zone “3.168.192.in-addr.arpa” { # This line will help you to add reverse records on your DNS-server type master; file “dynamic/db.192.168.3”; allow-update { key rndc-key; }; # This is the Key that Allow update the DNS records notify yes; }; include “/etc/named.rfc1912.zones”; Continue reading DDNS & DHCPD CENTOS 6.5

Diskless Machines (iPXE &iSCSI)

  We have done some work about creating iSCSI targets (disks) on FreeBSD 10. If you haven’t checked my tutorial go ahead and click here. So now we are going to learn how to simplify things by using the FreeNAS interface in order to create targets. We are going to need a few things: Portal: It is the socket in which FreeNAS is going to be receiving all connections from the clients Extent: It is the dataset that you are going to share. You also need to specify the size Initiators: add permissions to your sharing Target: name your target (name, ip, port, Lun) Target/ Extents: You are going to associate your dataset to you target. So let me create a target as an example. 1. – Once you get access to your FreeNAS interface, go to the following path     Services àiSCSIàPortalà Add Portal          2. – Create an Extent by clicking on “Add Extent” (Even if you did not create “centos” directory previously, don’t worry FreeNAS will create the dataset for you automatically.   3. – It is time to set our initiator (you might want to add your network address or you might also want to add “ALL” Continue reading Diskless Machines (iPXE &iSCSI)

iSCSI on FreeBSD

iSCSI Create a dataset on my zfs pool # sudo zfs create -V 30G tank/windows   If you want to delete a dataset for any circumstances you can run the following command # sudo zfs destroy tank/windows   Alternatively you can create a disk image if you are not using ZFS as file system with the following command Note: This step is not necessary if you have created a zfs dataset. Also if you decided to create a disk image, do not forget to change the path on you istgt.conf configuration file # sudo dd if=/dev/zero of=/home/windows.img bs=1M count=30000 # count is the size in megabytes   Install iSCSi software on the FreeBSD server # cd /usr/ports/net/istgt # sudo make install clean (everything by default)   As a root run the following command in order to enable the service # echo ‘istgt_enable=”YES”‘ >> /etc/rc.conf   Let’s create our configurations files # cd /usr/local/etc/istgt/   There are three configuration files that we have to create   istgt.conf auth.conf istgtcontrol.conf We create the first file under the path /usr/local/etc/istgt # sudo vi istgt.conf   Copy and paste the following lines into the file # cat istgt.conf [Global] Comment “Global section” NodeBase “vhostfbsd.2014-04.mrwhitebp.com” Continue reading iSCSI on FreeBSD