Skip to main content

Posts

IPTABLES

Under linux OS, we use iptables to secure the machine from any other external attack. In current scenario I am forwarding the packages from local interface to external interface and i have squid configured which will be acting as transparent proxy. Only selective port numbers are open for the network. 1. Save the script to a file. 2. Give permission to execute. chmod +x filename . 3. Execute the file as follows ./filename 4. save the output of the script to system iptables file, by running the command service iptables save 5. You are done, start/restart the iptables service. service iptables restart Script: #!/bin/sh # chmod +x file name to execute # eth0 LAN # eth1 WAN # Local IP range 192.168.0.0/25 # NATing # Transparent proxy 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 FORWARD ACCEPT iptables -P OUTPUT ACCEPT iptables -A INPUT -i lo -j ACCEPT iptables -A...

Install LibreOffice on Fedora

Download the package from LibreOffice.org 1. Unpack the downloaded package. tar -xvf Libxxxx 2. Installing LibreOffice rpm -Uvh RPMS/*.rpm If you get error here saying libgnomevfs2 is missing. Install the package as follows. yum install ruby-gnomevfs 3. Desktop Integration setup for LibreOffice rpm -Uvh RPMS/desktop-integration/libreofficeX.X-freedesktop-menu-XXXXXXXX

Install MRTG and SNMP

The Multi Router Traffic Grapher (MRTG) is a tool to monitor the network traffic load. With this tool you can even monitor router traffic. Before we configure MRTG, we need a working Simple Network Management Protocol (SNMP) server. 1. Install snmp packages yum install snmp net-snmp net-snmp-utils -y 2. Configure SNMP vi /etc/snmp/snmpd.conf Locate line that contains: com2sec notConfigUser default public Add or change to as follows, in case of 192.168.0.0/24, enter your own internal network range: com2sec local localhost public com2sec mynetwork 192.168.0.0/24 public Locate line that contains: group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser Add or change to as follows: group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork ...

List all tables details of a database

To get all the table details of a specific database in MS SQL Server, use the following query. USE [DATABASE-NAME] SELECT * FROM INFORMATION_SCHEMA.COLUMNS After you run the query use can select individual fields as per your requirement. As of me my requirement is as follows. USE [DATABASE-NAME] SELECT TABLE_NAME, COLUMN_NAME,DATA_TYPE,IS_NULLABLE, ISNULL(COLUMN_DEFAULT,'') AS COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS ORDER BY TABLE_NAME To include the length of the column run the following script. USE [DATABSE-NAME] SELECT OBJECT_NAME(c.OBJECT_ID) TableName ,c.name AS ColumnName ,SCHEMA_NAME(t.schema_id) AS SchemaName ,t.name AS TypeName ,t.is_user_defined ,t.is_assembly_type ,c.max_length ,c.PRECISION ,c.scale FROM sys.columns AS c JOIN sys.types AS t ON c.user_type_id=t.user_type_id ORDER BY TableName;

Display uncommented lines of a file

As you must be aware that in any configuration file under Linux OS, there is hundreds of lines, most of them are commented with explanations. Therefore going though such files takes time to locate the line we are looking for. I use the command below to remove all the commented lines and blank lines by combining two commands using pipe '|'. In my case the comments are marked with #. grep -v "^#" main.cf | grep -v "^$" The grep -v "^#" filename will remove the commented line. The grep -v "^$" will remove the blank lines.

Installing VNC in CentOS 5/6

When you are installing make sure the Desktop Environment is already installed. Installing VNC Server in CentOS 6 yum install tigervnc-server vncpasswd #to configure vnc to user To Start vncserver vncserver:2 To Stop vncserver –kill :2 vim /home/root/.vnc/xstartup #twm & exec gnome-session & Display setting vncserver :2 –geometry 800x600 –depth 24 Installing VNC Server in CentOS 5.x yum install vnc-server vim /etc/sysconfig/vncserver #locate and make change as follows. Where 2 is Display Number and root is the user VNCSERVERS="2:root" #uncomment and remove –localhost VNCSERVERARGS[1]="-geometry 1024x768 –nolisten tcp –nohttpd" Now let's assign VNC password to the user root. As I am already logged in as root I will not be switching user. vncpasswd service vncserver start vim /home/root/.vnc/xstartup #comment twm & #twm & #Add to run in gnome exec gnome-session & service vncserver restart chkconfig vncserv...