Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Wednesday, 18 September 2013

checking the status of a service in linux

In this example I want to see if SMB is running

Check the status:
/etc/init.d/smb status

I can restart a service with
/etc/init.d/smb stop
/etc/init.d/smb start

or simply
/etc/init.d/smb restart

Check if the service is set to start on boot up
chkconfig --list | grep smb

SELinux

SElinux can stop samba (and other things) from working. You can turn it off by running the following command as root
"setenforce 0"
This is not recommended as it disables other security features but no one seems to know how to create exceptions for SElinux. SElinux will start again after a reboot. To stop it starting on reboot
sudo vi /etc/selinux/config
change the line SELINUX=enforcing to SELINUX=permissive
Save your changes and that should be it.

Monday, 22 July 2013

How long does DNS take to propagate and short bash script to test after changing DNS entries

I was changing a customer's DNS to point at a new public IPs. They were concerned about how long it would take to switch over. The DNS provider told me they usually tell customers it will be complete in their network within 24 hours and they can't control outside of that. They said normally the DNS change will take effect immediately and should have propagated out across the internet within 24 hours so this covers them with customers.

Wrote a short bash script to do an nslookup so we could see the new public IP's and a curl to show the website was up.


echo "**********************************************"
echo "nslookup on my.customer.com"
echo "**********************************************"
echo " "
nslookup my.customer.com
echo " "
echo "**********************************************"
echo "curl on my.customer.com, expecting http 200 OK"
echo "**********************************************"
echo " "
curl -IL my.customer.com
echo " "

Friday, 28 December 2012

bash code snippet to ping a public IP range in Linux

I was having an issue where traffic was not making it to the public interface of an ASA firewall that I was working on. I created this simple script to ping the public IP range. I was listening on the ASA side to see if the traffic made it through. This helped me track down that the issue was somewhere in the service providers equipment. Clearing the arp table on their equipment resolved the issue temporarily but it would re-appear. I believe we hit a bug in the equipment. The service providers equipment was replaced and the issue was resolved. I'm sure there is a smarter,cleaner or cooler way of doing this but I was in a hurry :)

First I made a file called "ping_list" and entered the IP addresses in the public range

xxx.xxx.xxx.69
xxx.xxx.xxx.70
xxx.xxx.xxx.71
xxx.xxx.xxx.72
xxx.xxx.xxx.73
xxx.xxx.xxx.74
xxx.xxx.xxx.75
xxx.xxx.xxx.76
xxx.xxx.xxx.77
xxx.xxx.xxx.78

Then I made a second file "ping-ip-range.sh" and entered the following code which just pings each IP only once then moves onto the next one.

for i in `cat ping_list`; do ping -c1 $i; done
Now I could ping the range by just running

./ping-ip-range.sh

You may need to chmod the .sh file to make it executable

chmod u+x ping-ip-range.sh