Some personnel notes /references for CENTOS 6.x command line.
CENTOS 6.6 <32 bit> DOWNLOAD LINK …
http://mirrors.nayatel.com/centos/6.6/isos/i386/CentOS-6.6-i386-minimal.iso
Kill all DEFUNCT processes automatically
ps -ef | grep defunct | grep -v grep | cut -b8-20 | xargs kill -9
Enable SNMP in CENTOS , tested with 6.x
To enable SNMP in CENTOS quickly, copy paste following. it will add ‘public’ community as Read Only.
yum -y install net-snmp net-snmp-utils > /etc/snmp/snmpd.conf # Add following echo "rocommunity public" > /etc/snmp/snmpd.conf echo "syslocation "Karachi NOC, Paksitan" >> /etc/snmp/snmpd.conf echo "syscontact aacable_at_hotmail_com" >> /etc/snmp/snmpd.conf service snmpd restart chkconfig snmpd on snmpwalk -v1 -c public 127.0.0.1
Configuring Static IP address in CENTOS [6.x]
If you want to configure static IP address in CENTOS, then edit following file
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Use following as sample
DEVICE=eth0 HWADDR=00:0C:29:73:0A:5A TYPE=Ethernet UUID=d34531a1-3c76-4527-8e50-448857568abc ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static IPADDR=192.168.10.2 # IP Address you want to fix NETMAST=255.255.255.0 # Netmask as per network # or if netmask dont work, use PREFIX=24 (change 24 as per network like /8 or whatever) GATEWAY=192.168.10.1 # Your Router/DLS Gateway DNS1=8.8.8.8 # Your ISP DNS or standard Google dns
Note: set following for sure
NM_CONTROLLED=no
BOOTPROTO=static
ONBOOT=yes
Save & Exit, and restart the network service or interface to take effect
service network restart
OR
ifdown eth0
ifup eth0
Issue IFCONFIG command to verify the result.
centos7 is a mess 😦 so better to stick with 6
Change/Clone MAC address
To change mac address in CENTOS , edit your required ethernet network config file , Example …
nano /etc/sysconfig/network-scripts/ifcfg-eth0
here you will see HWADDR line with current mac address, dont modify it, just add another line above it, like following
MACADDR=00:11:11:11:11:11 < Add this line with your required mac address
HWADDR=00:22:22:22:22:22 < Your current mac address
An example of full cfg file for eth0
DEVICE=eth0 MACADDR=00:11:11:11:11:11 HWADDR=00:22:22:22:22:22 TYPE=Ethernet UUID=d34531a1-3c76-4527-8e50-448857568abc ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static IPADDR=192.168.1.2 NETMAST=255.255.255.0 GATEWAY=192.168.1.1 DNS1=8.8.8.8
Save & Exit, and restart the network service or interface to take effect
service network restart
OR
ifdown eth0
ifup eth0
Issue IFCONFIG command to verify the result.
OR
use the sed shortcut 😉
sed -i -e ‘1iHere is my new top line\’ filename
Disabling CENTOS default firewall ‘SELINUX’
To disable SELINUX temporary for the current session, use following…
echo 0 > /selinux/enforce
To disable builtin firewall permanently in centos, edit following
vi /etc/selinux/config
and change the
SELINUX=enforcing
to
SELINUX=disabled
Save & Exit & reboot to take effect.
Or use the SED shortcut to replace the string within cli 😉 # Zaib
sed -i "s/=enforcing/=disabled/g" /etc/selinux/config
Disable IPTABLES
To disable iptables services
service iptables stop chkconfig iptables off
You can check the status with following
service iptables status
and you can also use following command to clear the current iptables (for the current session only)
iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t mangle -F iptables -t mangle -X iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT
Some must-have tools
yum install -y nano wget curl net-tools lsof
SERVICES Related
service --status-all
To disable service on startup , use
chkconfig httpd off
To always start any service on boot, use
chkconfig --add httpd on
Excluding slow mirrors
When I was installing some packages in Centos and the YUm was doing it at painfully slow speed, I figured the mirror (indian and bangladeshi mirror sites) were very slow. So I disabled two mirrors domain it was selecting in start which were .in and .bd
use following file
nano /etc/yum/pluginconf.d/fastestmirror.conf
and add the slow mirror (to be excluded) like
exclude=.in, .bd, xyz.com
or use the cli command to add it in the file
echo "exclude=.gov, .in, .vn, mirror-fpt-telecom.fpt.net" >> //etc/yum/pluginconf.d/fastestmirror.conf
How to Check CentOS Version / kernel Number
Centos Version
cat /etc/centos-release
32bit/64bit check
uname -a
Howto Disable IPV6 in CENTOS [Tested on 6.x versions]
First edit sysctl.conf file in any editor , e.g:
nano /etc/sysctl.conf
and add following lines in the end
# IPv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
OR
Use following to add them directly to file using echo command
echo >> /etc/sysctl.conf net.ipv6.conf.all.disable_ipv6 = 1 echo >> /etc/sysctl.conf net.ipv6.conf.default.disable_ipv6 = 1 echo >> /etc/sysctl.conf net.ipv6.conf.lo.disable_ipv6 = 1
Save and Exit and execute following to activate changes 🙂
sysctl -p
Howto install PHPMYADMIN in centos 6.x
To install PHPMYAMDIN which is a good tool to manage your mysql via GUI in centos, use following…
cd /tmp wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm rpm -ivh epel-release-6-8.noarch.rpm yum search phpmyadmin yum -y install phpmyadmin
Now You need to edit /etc/httpd/conf.d/phpMyAdmin.conf file, enter:
vi /etc/httpd/conf.d/phpMyAdmin.conf
Replace your ip in
Require ip 127.0.0.1 Allow from 127.0.0.1
Change 127.0.0.1 to your management pc ip from where you want to access phpmyadmin
after saving, restart the httpd service.
service httpd restart
Or use the SED shortcut to replace the string within cli 😉 # Zaib
sed -i "s/127.0.0.1/10.0.0.1/g" /etc/selinux/config[replace 10.0.0.1 with your management pc ip]
Solving WGET hangs/sleep problem when internet link break or with poor connectivity
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0
Adding Virtual NIC
Quick and dirty way (it will add the nic temporary for the session, you can also add these commands in startup as well.
ip link add link eth0 address 11:22:33:44:55:66 eth0.10 type macvlan ifconfig eth0.1 up ifconfig eth0.1 10.0.0.2
Adding Virtual NIC permanently.
http://linuxconfig.org/configuring-virtual-network-interfaces-in-linux
Adding simple VPN Server (in view f connecting radius with nas)
https://www.digitalocean.com/community/tutorials/how-to-setup-your-own-vpn-with-pptp
On CentOS 6 x64:
rpm -i http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm yum -y install pptpd
Now you should edit /etc/pptpd.conf and add the following lines:
localip 10.0.0.1 remoteip 10.0.0.100-200
Where localip is IP address of your server and remoteip are IPs that will be assigned to clients that connect to it.
Next, you should setup authentication for PPTP by adding users and passwords. Simply add them to /etc/ppp/chap-secrets :
(example of id pass)
zaib pptdp zaibpass *
service pptpd restart
Add PPPOE dialer setup in centos 6.x [Nov,2017]
to add pppoe dialer in centos, use
yum install ppp rp-pppoe
This will install few additional commands that you can use to manage example. to add dialer via setup use
pppo-setup
> To start pppoe dialer use,
pppoe-start
> to stop already dialed pppoe dialer use
pppoe-stop
use ppoe-status command to query the status
ZAIB
Adding Static Routes in separate file [Nov,2017]
Note: 192.168.100.2 is Gateway
[root@gtradius network-scripts]# cat route-eth0 192.168.0.0/16 via 192.168.100.2 dev eth0 10.0.0.0/8 via 192.168.100.2 dev eth0
Adding IP configuration file for newly added interface
Example: eth0 is already running, now you have added new interface eth1 but there is no file present in /etc/sysconfig/network-scripts
Copy file from previous running file like,
cp ifcfg-eth0 ifcfg-eth1
Now edit and make necessary changes example file is attached below …
[root@gtradius network-scripts]# cat ifcfg-eth1 DEVICE=eth1 NM_CONTROLLED="no" ONBOOT=yes # [VMware commented] HWADDR=18:A9:05:32:45:1F # REMOVE HWADDR TYPE=Ethernet BOOTPROTO=none IPADDR=1.1.1.2 PREFIX=29 GATEWAY=1.1.1.1 DNS1=8.8.8.8 #DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth1" #UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 # REMOVE UUID
To be continued …
SYED.JAHANZAIB
Leave a Reply