Syed Jahanzaib Personnel Blog to Share Knowledge !

June 23, 2011

Ubuntu: Howto restart Networking + Delete ROUTE + Disable ipv6 + Service Startup Controller

To restart Networking , issue the following command.

sudo initctl restart network-manager

OR

sudo initctl restart network-interface INTERFACE=eth0

Howto disable ipv6 in ubuntu.  [10.4 LUCID  LYNX]

Open up terminal and issue following commands.

echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf

Howto disable IPV6 in Ubuntu.  [Alternate Way]

Edit /etc/default/grub file by . . .

nano /etc/default/grub

Change The following line

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”

to

GRUB_CMDLINE_LINUX_DEFAULT=”ipv6.disable=1 quiet splash”

Save and exit the file Update the grub from the command line

sudo update-grub

 

 

Ubuntu / Debian Linux: Services Configuration Tool to Start / Stop System Services

apt-get install sysv-rc-conf sysv-rc-conf

Howto to ADD / DELETE Route

Adding default Gateway

route add default gw 192.168.2.1 dev eth1

Add Route for Local Network using Gateway

route add -net 172.16.0.0 netmask 255.255.0.0 gw 192.168.2.1 dev eth0

Delete Route

route del -net 172.16.0.0 netmask 255.255.0.0 gw 192.168.2.1 dev eth0

 

Ubuntu: Howto change Screen Resolution via CLI

Filed under: Linux Related — Syed Jahanzaib / Pinochio~:) @ 6:03 AM

You can change screen resolution size via CLI , use following cmd:

xrandr
(It will show you current screen resolution and available modes.
Now you can change the size by issuing this cmd:

xrandr --output VGA-0 --mode 1024x768

(change the VGA-0 according to what xrandr shows vga syntax for your card, in my example it shows VGA-0)

June 20, 2011

DOS Batch File: Backup Organized by Date

Filed under: General IT Related, Microsoft Related — Syed Jahanzaib / Pinochio~:) @ 8:11 AM

Salam to All,

Few days back, a new oracle server was added in our IT dept. It is an oracle database server which serves many users request in our company. There was an annoying manual backup task that we have to perform on it on daily basis , the :@ task was to run 2 shortcut which creates backup dump files in E: drive, and then we have to manually rename the 2 dump files according to current date and then move them in other date-wise folder.
Quite annoying , isn’t it ? I mean still do we have to perform simple tasks like taking backup manually where every task is being done Automatically ?
Stupid enough ! :P

It was quite easy to do this task automatically in LINUX environment, but as currently i am working in MS (Microshit or Microsoft environemnt) I manage to done it with built-in DOS commands. Following is the complete dos batch file or call it the Backup script ;) , I just added in Schedule task, Now it runs daily and saves my time.

zxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxz

@echo off
cls
Echo Oracle Backup Organizer Script.
Echo Developed by Syed Jahanzaib / aacable@hotmail.com
Echo.
Echo.
rem C:\windows\ping.exe 127.0.0.1 > null -n 10
Echo Creating current date backup Directory in E:\backup
C:\windows\ping.exe 127.0.0.1 > null -n 4
set dt=%date:~-4,4%%date:~-10,2%%date:~-7,2%

Echo Copying dump files into remote file server fs\home\cic
C:\windows\ping.exe 127.0.0.1 > null -n 5
C:\windows\system32\net use \\192.168.2.2\f$\home\cic /USER:zaib@kdc.local immi0
copy e:\backup\Cic_final.Dmp \\192.168.2.2\f$\home\cic\cic-backup.%dt%.dmp
copy e:\backup\nae_final.dmp \\192.168.2.2\f$\home\cic\nae-backup.%dt%.dmp

Echo Renaming dump files to current date for the date wise backup
ren e:\backup\Cic_final.Dmp cic-backup.%dt%.dmp
ren e:\backup\nae_final.dmp nae-backup.%dt%.dmp
rem C:\windows\ping.exe 127.0.0.1 > null -n 5

REM Moving dump files to e:\backup\CIC-backup\ & e:\backup\NAE-backup\
move e:\backup\cic*.dmp e:\backup\CIC-backup\
move e:\backup\nae*.dmp e:\backup\NAE-backup\

echo.
echo.
echo All Backup done. Allah Hafiz
C:\windows\ping.exe 127.0.0.1 > null -n 10

 

June 14, 2011

XP installation via USB

Filed under: General IT Related, Microsoft Related — Syed Jahanzaib / Pinochio~:) @ 7:22 AM

XP installation via USB
=======================

http://komku.blogspot.com/2008/11/install-windows-xp-using-usb-flash-disk.html

Also check USB_MULTIBOOT.cmd , it works for me very well.

http://www.msfn.org/board/topic/112627-usb-drive-target-error/

June 13, 2011

Ubuntu : A sample share for sharing your Folder with others.

Filed under: General IT Related — Syed Jahanzaib / Pinochio~:) @ 9:15 AM

# A sample share for sharing your Folder with others.
[zaib]
comment = zaib folder
read only = yes
locking = no
path = /zaib
guest ok = yes

UBUNTU: Howto boot into Text Mode :)

Filed under: General IT Related — Syed Jahanzaib / Pinochio~:) @ 8:58 AM

UBUNTU: Howto boot into Text Mode :)

How to launch Ubuntu in Text Mode like FEDORA does it in a cool way by displaying all spices? There are few ways to do it.

I had make ubuntu boot into text mode by changing /etc/default/grub file:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to
GRUB_CMDLINE_LINUX_DEFAULT="text"

Then run update-grub

Ubuntu : Persistent DNS Caching with pdnsd.

Filed under: Linux Related — Syed Jahanzaib / Pinochio~:) @ 8:30 AM

When I setup Squid on Ubutu, there was one problem that I faced frequently, is the slow DNS look-up performance, especially compared with the same hardware running Windows. I found one way of improving performance is to provide DNS caching on the local machine and to disable ipv6.
First to disable ipv6 on ubuntu, Add
net.ipv6.conf.all.disable_ipv6=1
to /etc/sysctl.conf and run sysctl -p

Now install pdnsd by
apt-get install pdnsd

now edit its config file
ano /etc/pdnsd.conf
and paste the following config, its mine, u can edit accordingly.


global {
perm_cache=1024;
cache_dir="/var/cache/pdnsd";
run_as="pdnsd";
#server_ip = 127.0.0.1;
#server_port=53;
status_ctl = on;
paranoid=on;
query_method=udp_tcp;
max_ttl=1w; # One week.
timeout=10;
}

server {
label=Lan;
ip=129.168.2.1;
timeout=30;
uptest=ping;
interval=30;
ping_timeout=300;
purge_cache=off;
caching=on;
preset=off;
}
server {
label=OpenDNS;
ip=221.132.112.8;
ip=221.132.112.9;
timeout=30;
uptest=ping;
interval=30;
ping_timeout=300;
purge_cache=off;
caching=on;
preset=off;
}

source {
owner=localhost;
serve_aliases=on;
file=”/etc/hosts”;
}

rr {
name=localhost;
reverse=on;
a=127.0.0.1;
owner=localhost;
soa=localhost,root.localhost,42,86400,900,86400,86400;
}

Now in /etc/resolv.conf , replace your nameserver with this
nameserver 127.0.0.1

restart pdnsd , and enjoy fast websites response due to local DNS caching :) , also dont forget to add dns_nameservers 127.0.0.1 in squid.conf

June 5, 2011

Linux Few Tips n Tricks ! Unmanaged Post, Will edit later . . .

Filed under: Linux Related — Syed Jahanzaib / Pinochio~:) @ 2:58 PM

Fedora 10 update GDM config to allow root login on GUI Mode
===========================================================

Open /etc/pam.d/gdm using gedit or vi text editor, enter:
gedit /etc/pam.d/gdm

Find line that read as follows:

auth required pam_succeed_if.so user != root quiet

Remove or comment out line by prefixing #.

# auth required pam_succeed_if.so user != root quiet

==============================================
CONFIGURING LAN IP ADDRESS:

You can determine your IP by running:

/sbin/ifconfig -a

Look at the entry for eth0

To change your IP edit the file /etc/systconfig/network-scripts/ifcfg-eth0

then run

service network restart

==============================================
CONFIGURING WEBMIN via YUM:

Using the Webmin YUM repository

If you like to install and update Webmin via RPM, create the /etc/yum.repos.d/webmin.repo file containing :

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

You should also fetch and install my GPG key with which the packages are signed, with the command :

rpm –import http://www.webmin.com/jcameron-key.asc

You will now be able to install with the command :

yum install webmin

All dependencies should be resolved automatically

============================================

mysqladmin command to change root password

If you have never set a root password for MySQL server, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:
$ mysqladmin -u root password NEWPASSWORD

============================================
CLEAR IPTABLES RULES

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
============================================

June 4, 2011

Mikrotik Routing Youtube to another WAN Link !

Filed under: Mikrotik Related — Tags: , , , , , , , — Syed Jahanzaib / Pinochio~:) @ 3:44 PM

If you have two DSL links, and you want to dedicate one link for the YOUTUBE and FACEBOOK traffic only, you can do it with Mikrotik in few simple steps.

First understand the logic, Main idea is to first create Address list with YOUTUBE ip addresses. (u can get them from goggling) then , in mangle, create rule to mark packets with the above created address list, name it
youtube
-addresses, then in route create rule to route youtube address list to go via DSL 2 .

Some examples . . .

/ip firewall mangle chain=prerouting action=mark-routing new-routing-mark=youtube passthrough=yes src-address=0.0.0.0/0 dst-address=208.65.152.0/21
(or destination address list you created in starting, U have to create Several IP address lists)

then create ROUTE for this list.

/ip route add comment=”" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=youtube scope=255 target-scope=10

Its amazing, you can route any Website/traffic to specific WAN link, for example dedicated DSL link for streaming media sites or FB. its kewl ;)

For more info and ideas, please visit following link.
http://wiki.mikrotik.com/wiki/Per-Traffic_Load_Balancing

zaiB !

Mikrotik 4 WAN Load Balancing using PCC method. Complete Script ! by zaiB

Following is a complete script for Mikrotik to combine/Load Balance 4 WAN links OR DSL links , and the script idea is taken from
http://wiki.mikrotik.com/wiki/Manual:PCC#Example

In this example I have used MikrotikT RB750 5 ports router. 4 ports were connected with Four DSL Routers, and 5th port was connected with User LAN. All DSL lines have un-equal speed. Also don’t forget to rename the interface names accordingly.

In my personnel experience , If users request are directly hitting Mikrotik configured with PCC , then you will get good load balancing. Use src-address as classifier, this way you will get rid of problems like https/broken link, streaming issues etc. Load balancing using this PCC technique (src-address) will be effective and balanced approach when more and more connections (from clients) that occurred. I also recommend to use SQUID proxy server along with mikrotik , either parallel or in front or backend , for better response time and it will also increase good browsing experience to users.

If somehow you are not satisfied with the src-address approach,play with the PCC-Classifier,
Try both addresses and ports as the classifier. While this will randomize things the most and in theory give you the most fair allocation of bandwidth, BUT there is also a good chance that it will break certain things like banking web sites and some forums. This is because often times a HTTP requests will generate several connections, so there is a chance that some requests may go out a different route than the initial one, and that will break secure web sites. For that reason I usually stick with src-address PCC load balancing.

Result of this script is as follows on screenshots.
[Thanks to sam @ fastmesh for the screenshots :) ]

Syed Jahanzaib


/ip address
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local
add address=192.168.1.2/24 network=192.168.1.0 broadcast=192.168.1.255 interface=WAN1
add address=192.168.2.2/24 network=192.168.2.0 broadcast=192.168.2.255 interface=WAN2
add address=192.168.3.2/24 network=192.168.3.0 broadcast=192.168.3.255 interface=WAN3
add address=192.168.4.2/24 network=192.168.4.0 broadcast=192.168.4.255 interface=WAN4

/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=input in-interface=WAN3 action=mark-connection new-connection-mark=WAN3_conn
add chain=input in-interface=WAN4 action=mark-connection new-connection-mark=WAN4_conn

add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
add chain=output connection-mark=WAN3_conn action=mark-routing new-routing-mark=to_WAN3
add chain=output connection-mark=WAN4_conn action=mark-routing new-routing-mark=to_WAN4

add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.3.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.4.0/24 action=accept in-interface=Local

add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/0 action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/1 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/2 action=mark-connection new-connection-mark=WAN3_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/3 action=mark-connection new-connection-mark=WAN4_conn passthrough=yes
add chain=prerouting connection-mark=WAN1_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN1
add chain=prerouting connection-mark=WAN2_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting connection-mark=WAN3_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN3
add chain=prerouting connection-mark=WAN4_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN4

/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.3.1 routing-mark=to_WAN3 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.4.1 routing-mark=to_WAN4 check-gateway=ping

add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.3.1 distance=3 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.4.1 distance=4 check-gateway=ping

/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
add chain=srcnat out-interface=WAN3 action=masquerade
add chain=srcnat out-interface=WAN4 action=masquerade

Now Configure DNS server so users can resolve hostnames,

/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=221.132.112.8,8.8.8.8

All Done ! Now Test the link by putting user load, the more multiple users load you put on it, the better Load Balance result you will get :)

PCC WITH UN-EQUAL WAN LINKS

If you have Un-Equal WAN Links, for example WAN,1,2,3 are of 4MB and WAN,4 is of 8 Mb, and you want to force MT to use WAN4 link more then other because of its capacity, Then you have to Add more PCC rules assigning the same two marks to a specific link i.e WAN4 , something like

Code:

add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/0 action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/1 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/2 action=mark-connection new-connection-mark=WAN3_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/3 action=mark-connection new-connection-mark=WAN4_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/4 action=mark-connection new-connection-mark=WAN4_conn passthrough=yes

٩(●̮̮̃•̃)۶   ZaiB   ٩(●̮̮̃•̃)۶

Older Posts »

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 250 other followers