Thursday, February 02, 2012

update with select on same table

http://the-stickman.com/uncategorized/mysql-update-with-select-on-the-same-table-in-the-same-query/

update euser set `parentID` = (SELECT user_id from (SELECT `user_id` FROM euser WHERE `usernameid` = `usrname`) as userid ) - not working

http://www.daniweb.com/web-development/databases/mysql/threads/300670

this works:
update euser inner join euser2 on euser.`usernameid`=euser2.usrname set euser.`parentID` = euser2.user_id

Monday, January 30, 2012

DHCP Server (Vista Compatible)

ref: http://www.russellconsultants.com/information/how-to-mainmenu-15/21-networking/43-dhcp-and-windows-vista.html

this is my own version. this setting like normal wireless router and works on my windows vistaa.


option domain-name "server.domain.com";
option domain-name-servers 8.8.8.8;
option netbios-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style ad-hoc; ## Centos needs this
subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.150 192.168.1.252;
    option broadcast-address 192.168.1.255;
    option routers 192.168.1.1;
}

Other reading:
http://www.mail-archive.com/gnhlug-discuss@mail.gnhlug.org/msg27563.html
and: http://www.bravecobra.com/2008/6/18/windows-vista-not-accepting-ip-address-from-a-linux-dhcpd/

PXE setup centos

http://wiki.centos.org/HowTos/PXE/PXE_Setup

Guide: Install Debian using PXE

Simple Menu


/tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local

MENU TITLE PXE Menu

LABEL Pmajic
        MENU LABEL Pmajic
        kernel images/pmagic/bzImage
        append noapic initrd=images/pmagic/initrd.gz root=/dev/ram0 init=/linuxrc ramdisk_size=100000

label Dos Bootdisk
        MENU LABEL ^Dos bootdisk
        kernel memdisk
        append initrd=images/622c.img

LABEL CentOS 5 x86 NO KS eth0
        MENU LABEL CentOS 5 x86 NO KS eth0
        KERNEL images/centos/5/x86/vmlinuz
        APPEND ks initrd=images/centos/5/x86_64/initrd.img ramdisk_size=100000 ksdevice=eth1 ip=dhcp url --url http://xxx.xxx.xxx.xxx/mirrors/CentOS-5-i386/

LABEL CentOS 5 x86_64 NO KS eth0
        MENU LABEL CentOS 5 x86_64 NO KS eth0
        KERNEL images/centos/5/x86_64/vmlinuz
        APPEND ks initrd=images/centos/5/x86_64/initrd.img ramdisk_size=100000 ksdevice=eth1 ip=dhcp url --url http://xxx.xxx.xxx.xxx/mirrors/CentOS-5-x86_64/

windows vista DHCP fix

http://www.reviewingit.com/index.php/content/view/29/2/


WARNING: Only apply this patch if you are having problems do not apply it to all your network interfaces. 
Registry Tweaks for Vista DHCP Problems
HKLM\SYSTEM\CURRENTCONTROLSET\SERVICES\TCPIP\PARAMETERS\INTERFACES\{GUID}
Change
DhcpConnForceBroadcastFlag = 0
ADD DWORD
DhcpConnDisableBcastFlagToggle = 1
Also to disable IP V6

HKLM\SYSTEM\CURRENTCONTROLSET\SERVICES\TCPIP6\PARAMETERS\
ADD DWORD
DisabledComponents = FF (hex)

OR Download it HERE

monitor dhcp request

#tcpdump portrange 67-68

ref: http://danielmiessler.com/study/tcpdump/

Sunday, January 29, 2012

FTP on squid

i have a problem listing files on remote server
using squid

firstly make sure to load ip_nat_ftp on squid kernel !important!


# Module required for active an FTP server using NAT
modprobe ip_nat_ftp


then
# iptables -A FORWARD -j ACCEPT

if this failed: enable ftp bypass on squid
http://labtestproject.com/linux_network/step_by_step_enable_ftp_on_squid_proxy_in_linux_fedora_10.html


acl FTP proto FTP
always_direct allow FTP


reload squid server and you're done

make sure to uncheck PASV transfer on your ftp client (see ref 1)

good reources to read more:
1. http://enterprisedt.com/products/edtftpjssl/doc/manual/html/howtoftpthroughafilewall.html
2. http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch14_:_Linux_Firewalls_Using_iptables

Thursday, January 26, 2012

configuring DHCP server

http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch08_:_Configuring_the_DHCP_Server


dhcpd.conf File

You can define your server configuration parameters in the dhcpd.conf file which may be located in the /etc the /etc/dhcpd or /etc/dhcp3 directories depending on your version of Linux.
Note: The skeleton dhcp.conf file that is created when you install the package may vary in its completeness. In Ubuntu / Debian, the skeleton dhcpd.conf file is extensive with most of the commands deactivated with a # sign at the beginning. In Fedora / RedHat / CentOS an extensive sample is also created with activated commands. It is found in the following location which you can always use as a guide.
/usr/share/doc/dhcp*/dhcpd.conf.sample
Note: The dhcpd.conf configuration file formats in Debian / Ubuntu and Redhat / Fedora are identical.
Here is a quick explanation of the dhcpd.conf file: Most importantly, there must be a subnet section for each interface on your Linux box.
ddns-update-style interim
ignore client-updates
 
subnet 192.168.1.0 netmask 255.255.255.0 {
 
   # The range of IP addresses the server
   # will issue to DHCP enabled PC clients
   # booting up on the network
 
   range 192.168.1.201 192.168.1.220;
 
   # Set the amount of time in seconds that
   # a client may keep the IP address

  default-lease-time 86400;
  max-lease-time 86400;
 
   # Set the default gateway to be used by
   # the PC clients
 
   option routers 192.168.1.1;
   # Don't forward DHCP requests from this
   # NIC interface to any other NIC
   # interfaces
 
   option ip-forwarding off;
 
   # Set the broadcast address and subnet mask
   # to be used by the DHCP clients
 
  option broadcast-address 192.168.1.255;
  option subnet-mask 255.255.255.0;
  
   # Set the NTP server to be used by the
   # DHCP clients

  option ntp-servers 192.168.1.100;

   # Set the DNS server to be used by the
   # DHCP clients

  option domain-name-servers 192.168.1.100;
 
   # If you specify a WINS server for your Windows clients,
   # you need to include the following option in the dhcpd.conf file:

  option netbios-name-servers 192.168.1.100;
 
   # You can also assign specific IP addresses based on the clients'
   # ethernet MAC address as follows (Host's name is "laser-printer":

  host laser-printer {
      hardware ethernet 08:00:2b:4c:59:23;
     fixed-address 192.168.1.222;
   }
}
#
# List an unused interface here
#
subnet 192.168.2.0 netmask 255.255.255.0 {
}

squid redirection [setting]


#!/bin/sh
# chkconfig: 2345 99 00

case "$1" in
'start')
#---------------------------------------------------------------
# Load the NAT module
#
# Note: It is best to use the /etc/rc.local example in this
#       chapter. This value will not be retained in the
#       /etc/sysconfig/iptables file. Included only as a reminder.
#---------------------------------------------------------------

modprobe iptable_nat

#---------------------------------------------------------------
# Enable routing by modifying the ip_forward /proc filesystem file
#
# Note: It is best to use the /etc/sysctl.conf example in this
#       chapter. This value will not be retained in the
#       /etc/sysconfig/iptables file. Included only as a reminder.
#---------------------------------------------------------------

echo 1 > /proc/sys/net/ipv4/ip_forward

#---------------------------------------------------------------
# Allow masquerading
# - Interface eth0 is the internet interface
# - Interface eth1 is the private network interface
#---------------------------------------------------------------

#iptables -A POSTROUTING -t nat -o eth0 -s 192.168.1.0/24 -d 0/0 \
    #    -j MASQUERADE

#---------------------------------------------------------------
# Prior to masquerading, the packets are routed via the filter
# table's FORWARD chain.
# Allowed outbound: New, established and related connections
# Allowed inbound : Established and related connections
#---------------------------------------------------------------

iptables -A FORWARD -j ACCEPT
#Only port 80
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 0:442 -j REDIRECT --to-port 8080
# bypass SSL website
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 444:9999 -j REDIRECT --to-port 8080
#webmin port at 10000
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 10001:65535 -j REDIRECT --to-port 8080

#iptables -A FORWARD -t filter -o eth0 -m state -p tcp \
      #  --state NEW,ESTABLISHED,RELATED -j ACCEPT

#iptables -A FORWARD -t filter -i eth0 -m state -p tcp \
       # --state ESTABLISHED,RELATED -j ACCEPT    
#--state ESTABLISHED,RELATED -j ACCEPT

echo "Router started success!"
touch /var/lock/subsys/router
;;
'stop')
rm -f /var/lock/subsys/router
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0

GomezPeer Activation in Malaysia

this week (25/1 - 1/2 2012) i receive a letter from gomezpeerzone

http://carigold.com/portal/forums/showthread.php?p=12023681#post12013027

Action requested: Activations in your area‏

Dear PEER:

This week the Gomez PEER Zone will be activating new PEERs in your area . . . making it the perfect time for you to rack up the referral bonuses.

You will earn a $1 referral bonus for each new PEER we activate who enters your username in the "I Was Referred By" field on the application page; and right now we are aggressively activating in your area.

Simply click below to log-in to your account and fill out the referral form:

http://gomez.apis17.info

To stay up to date on all the latest Gomez PEER Zone promotions and incentives connect with us on our Twitter, Facebook and PEER News pages.

Thank you for your participation in the Gomez PEER program.

Cheers,

The Gomez PEER Team

Register your free account now & get cash when you online. :)
http://gomez.apis17.info

Wednesday, January 25, 2012

reduce LVM size

http://www.azhowto.com/2009/02/07/how-to-resize-lvm-running-xen-part-2-decrease-disk-size/

reducing LVM size takes more step than expanding. i already tried and it's works :)


I want to reduce the size of the XenWeb logical volume to 9G. First of all, let me shut it down.
[root@bpehhome2 mapper]# xm shutdown web
[root@bpehhome2 mapper]# pwd
/dev/mapper
[root@bpehhome2 mapper]# kpartx -a /dev/xenvg/XenWeb
[root@bpehhome2 mapper]# ls
control     xenvg-XenAuth           xenvg-XenWeb    xenvg-XenWebp2  XenWeb2
xenvg-root  xenvg-XenCentOSInstall  xenvg-XenWeb1   xenvg-XenWebp3  XenWeb3
xenvg-swap  xenvg-XenDebianDefault  xenvg-XenWebp1  XenWeb1
OK, let’s reduce the partition XenWeb2 size. I want XenWeb2 to be 9000M, but when I do the resize, I need to bring it abit lower, say 8500M. You will see why later.
[root@bpehhome2 mapper]# resize2fs XenWeb2 8500M
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f XenWeb2' first.

[root@bpehhome2 mapper]# e2fsck -f XenWeb2
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/: 246385/2395520 files (1.0% non-contiguous), 1044750/2469993 blocks

[root@bpehhome2 mapper]# resize2fs XenWeb2 8500M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on XenWeb2 to 2176000 (4k) blocks.
The filesystem on XenWeb2 is now 2176000 blocks long.
Its time to resize the logical volumn
[root@bpehhome2 mapper]# lvresize -L 9000M /dev/xenvg/XenWeb
  Rounding up size to full physical extent 8.81 GB
  WARNING: Reducing active and open logical volume to 8.81 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce XenWeb? [y/n]: y
  Reducing logical volume XenWeb to 8.81 GB
  Logical volume XenWeb successfully resized

additional information:
http://www.azhowto.com/2009/02/06/how-to-resize-lvm-running-xen-explained-part-1-increase-disk-size/
extending LVM size.

Saturday, January 21, 2012

[tips & trick] reboot on panic


# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-version.img
#boot=/dev/sda
default 0
timeout 5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
fallback 1
title CentOS (2.6.18-274.7.1.el5.028stab095.1xen)
root (hd0,0)
kernel /boot/xen.gz-2.6.18-274.7.1.el5.028stab095.1 panic=10
module /boot/vmlinuz-2.6.18-274.7.1.el5.028stab095.1xen ro root=LABEL=/
module /boot/initrd-2.6.18-274.7.1.el5.028stab095.1xen.img
title CentOS (2.6.18-274.17.1.el5xen)
root (hd0,0)
kernel /boot/xen.gz-2.6.18-274.17.1.el5 panic=10
module /boot/vmlinuz-2.6.18-274.17.1.el5xen ro root=LABEL=/
module /boot/initrd-2.6.18-274.17.1.el5xen.img
title CentOS (2.6.18-238.el5xen)
root (hd0,0)
kernel /boot/xen.gz-2.6.18-238.el5 panic=10
module /boot/vmlinuz-2.6.18-238.el5xen ro root=LABEL=/
module /boot/initrd-2.6.18-238.el5xen.img

you can use webmin. put Kernel options : panic=10

kernel panic! boot on AHCI [solved]

http://serverfault.com/questions/68793/enabling-ahci-in-rhel5-post-install

[root@m02 ~]# vi /etc/modprobe.conf


#alias scsi_hostadapter ata_piix
alias scsi_hostadapter ahci
alias scsi_hostadapter1 usb-storage
alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1
alias eth0 e1000
alias eth1 e1000e

http://forums.fedoraforum.org/showthread.php?t=202286

mkinitrd --allow-missing --preload=ahci --force-scsi-probe /boot/initrd-`uname -r`-custom `uname -r`
Related Posts Plugin for WordPress, Blogger...