Friday, February 6, 2015

ifconfig not found,use nmcli d and set the IP Adress on CentOS 7

By default on the core minimal configuration of CentOS Server ifconfig is not present

you have to install net-tools rpm from the dvd under the Packages folder to get ifconfig

use nmcli d to see the available network cards 

from GUI mode(if GUI is available ) use the command

nmtui

to set the ip 

 vi /etc/sysconfig/network-scripts/ifcfg-ens33

 TYPE=Ethernet
 BOOTPROTO=none
 DEFROUTE=yes
 IPV4_FAILURE_FATAL=no
 IPV6INIT=yes
 IPV6_AUTOCONF=yes
 IPV6_DEFROUTE=yes
 IPV6_FAILURE_FATAL=no
 NAME=enp0s17
 UUID=7f1aff2d-b154-4436-9497-e3a4dedddcef
 ONBOOT=no
 HWADDR=00:0C:29:A1:B5:D6
 PEERDNS=yes
 PEERROUTES=yes
 IPV6_PEERDNS=yes
 IPV6_PEERROUTES=yes

For DHCP
 Find the below lines in config File.
BOOTPROTO=none
 ONBOOT=no

and replace with

BOOTPROTO=dhcp
 ONBOOT=yesNow Restart network service by typing below command.

systemctl restart network

For Static IP.
 Find the below lines in config File.
BOOTPROTO=none
 ONBOOT=no

and replace with

BOOTPROTO=static
 ONBOOT=yes

And add the below lines at the end of the file.

IPADDR=192.168.28.51
 NETMASK=255.255.255.0
 GATEWAY=192.168.28.50
 DNS1=192.168.28.50

File will look like below after changes.
TYPE=Ethernet
 BOOTPROTO=static
 DEFROUTE=yes
 IPV4_FAILURE_FATAL=no
 IPV6INIT=yes
 IPV6_AUTOCONF=yes
 IPV6_DEFROUTE=yes
 IPV6_FAILURE_FATAL=no
 NAME=enp0s17
 UUID=f0c5b37d-299a-43cb-b74b-618bb252d129
 ONBOOT=yes
 HWADDR=00:0C:29:B1:C5:BB
 IPV6_PEERDNS=yes
 IPV6_PEERROUTES=yes
 IPADDR=192.168.28.51
 NETMASK=255.255.255.0
 GATEWAY=192.168.28.50
 DNS1=192.168.28.50

Now Restart network service by typing below command.
systemctl restart network

you can use /etc/sysconfig/network file for hostname and DNS .
HOSTNAME=server1.sourav.com
 DNS1=192.168.0.50
 DNS2=4.2.2.2
 SEARCH=sourav.com

DHCP with MAC-Binding on CentOS 7




mount -o loop /dev/cdrom /media

cd /media/Packages

rpm -ivh dhcp.....rpm

nano /etc/dhcp/dhcpd.conf

rpm -ivh


#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example
#   see dhcpd.conf(5) man page

# create new



option domain-name "sourav.com";

option domain-name-servers 192.168.28.150 ;

option subnet-mask 255.255.255.0;

option broadcast-address 192.168.28.255;

option routers 192.168.28.50;







default-lease-time 600;

max-lease-time 7200;




subnet 192.168.28.0



netmask 255.255.255.0
{

range dynamic-bootp 192.168.28.190 192.168.28.195;

}
host client{
option host-name "client.sourav.com";
hardware ethernet 00:0c:29:ff:5b:64;
fixed-address 192.168.28.192;
}
 
save and exit


systemctl start dhcpd

systemctl enable dhcpd

start the client

nano /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=84c05b0f-7a4f-477b-80ca-758fbddf39d9
ONBOOT=yes
HWADDR=00:0C:29:5D:DD:7D


save and exit

systemctl restart network 

go to dhcp server

you should see the leased ip on 

 nano /var/lib/dhcpd/dhcpd.leases
 

and if you type

systemctl status dhcpd

you should see if it is running including the lease information

Tuesday, February 3, 2015

EUI-64 conversion for CCNA





It's a really good video.

Apache with SSL,HTTPS configuration on CentOS 7

sudo yum install httpd
sudo systemctl enable httpd.service
sudo yum install mod_ssl
sudo mkdir /etc/httpd/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt

    openssl: This is the basic command line tool for creating and managing OpenSSL certificates, keys, and other files.
    req -x509: This specifies that we want to use X.509 certificate signing request (CSR) management. The "X.509" is a public key infrastructure standard that SSL and TLS adhere to for key and certificate management.
    -nodes: This tells OpenSSL to skip the option to secure our certificate with a passphrase. We need Apache to be able to read the file, without user intervention, when the server starts up. A passphrase would prevent this from happening, since we would have to enter it after every restart.
    -days 365: This option sets the length of time that the certificate will be considered valid. We set it for one year here.
    -newkey rsa:2048: This specifies that we want to generate a new certificate and a new key at the same time. We did not create the key that is required to sign the certificate in a previous step, so we need to create it along with the certificate. The rsa:2048 portion tells it to make an RSA key that is 2048 bits long.
    -keyout: This line tells OpenSSL where to place the generated private key file that we are creating.
    -out: This tells OpenSSL where to place the certificate that we are creating.

Then you have to fill up like this
Country Name (2 letter code) [XX]:IN
State or Province Name (full name) []:Example
Locality Name (eg, city) [Default City]:Example
Organization Name (eg, company) [Default Company Ltd]:Example Inc
Organizational Unit Name (eg, section) []:Example Dept
Common Name (eg, your name or your server's hostname) []:example.com
Email Address []:webmaster@example.com

Then
sudo nano /etc/httpd/conf.d/ssl.conf
Find the section that begins with . We need to make a few changes here to ensure that our SSL certificate is correctly applied to our site.
First, uncomment the DocumentRoot line and edit the address in quotes to the location of your site's document root. By default, this will be in /var/www/html, and you don't need to change this line if you have not changed the document root for your site. However, if you followed a guide like our Apache virtual hosts setup guide, your site's document root may be different.
DocumentRoot "/var/www/example.com/public_html"

Next, uncomment the ServerName line and replace www.example.com with your domain name or server IP address (whichever one you put as the common name in your certificate):
 ServerName www.example.com:443
Find the SSLCertificateFile and SSLCertificateKeyFile lines and change them to the directory we made at /etc/httpd/ssl:
SSLCertificateFile /etc/httpd/ssl/apache.crt
SSLCertificateKeyFile /etc/httpd/ssl/apache.key

sudo apachectl restart


sudo apachectl restart

Source:https://www.digitalocean.com/community/tutorials/how-to-create-an-ssl-certificate-on-apache-for-centos-7



 

Monday, February 2, 2015

Install Webmin on CentOS 7


nano  /etc/yum.repos.d/webmin.repo
[Webmin]
name=Webmin Distribution Neutral
#baseurl=http://download.webmin.com/download/yum
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
enabled=1

rpm --import http://www.webmin.com/jcameron-key.asc
yum install webmin -y
chkconfig webmin on
service webmin start

firewall-cmd --permanent --add-port=10000/tcp
rom another pc go tohttp://192.168.28.150:10000
log in as root