寻觅生命中的那一片浅草......

每月存档 六月, 2010

VboxHeadless & How To Swing It

About a week ago I posted a guide on how to install VirtualBox 3.0.2. While it is a great desktop virtualization solution there are a few things that leave you wanting more when it comes to a headless server. VMWare in this area still has much better solutions for managing several servers. But for small operations VirtualBox does have some options for managing your headless vm’s. This guide assumes that you already have VirtualBox 3 installed. If not I suggest you go take a look at my guide on how to perform the installation before you continue here.

Most tutorials you find out there will always suggest running thing through the sudo command as a regular user. However for this particular guide does not. The commands run here depend on the user running them. So in essence, if you follow this guide as it is written all VirtualBox settings are written to the ~/.VirtualBox/ directory. But, if you run these as root. All the configuration information would be stored in the /root/.VirtualBox/ directory.

So what we will need to continue are the following,

Remote connection to our host server (ssh is ideal)
rdesktop(linux) or Remote Desktop Connection(windows) installed to remotely connect to our headless vm’s from a remote computer
A .iso installation medium or an existing .vdi image to import.
First I’ll cover how to create a new virtual machine, afterwards I’ll go over how to import an existing virtual machine to your headless server.

Login to your Linux headless server and create a new vm. I’ve chosen to install a gentoo vm as it was the first .iso file I found on my computer.
$ VBoxManage createvm –name “Gentoo” –register
Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Virtual machine ‘Gentoo’ is created and registered.
UUID: faa5fe89-f75a-4bc9-93b2-063630353e25
Settings file: ‘/scott/.VirtualBox/Machines/Gentoo/Gentoo.xml’
Next we must set our system settings for the virtual machines use. Here I will configure it with 512 megs of memory, enable ACPI, set the first boot device to a DVD, and configure the network adapter to use NAT instead of Bridged networking.

$ VBoxManage modifyvm “Gentoo” –memory “512” –acpi on –boot1 dvd –nic1 nat
Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
After defining the system settings, we must create the virtual hard disk. I will be making mine a 10gigabyte virtual disk.$ sudo VBoxManage createhd –filename “Gentoo.vdi” –size 10000 –remember
Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

0%…10%…20%…30%…40%…50%…60%…70%…80%…90%…100%
Disk image created. UUID: ce4226ed-fc66-4749-ac8e-b08975a66ce8
Attach our newly created virtual hard disk to our newly created virtual machine as the first hard drive.

$ VBoxManage modifyvm “Gentoo” –hda “Gentoo.vdi”

Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
Register our installation .iso file to our virtual machine so that it may boot from it to begin the installation. Be sure to replace the path with your relevant path.

$ VBoxManage modifyvm “Gentoo” –dvd /path/to/your/install.iso

Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
We should now be ready to start our vm. This will run the vm in the terminal as a background process.

$ VBoxHeadless –startvm “Gentoo” &

Assuming everything went smoothly you can now connect to your headless vm with a RDP viewer. Be sure to replace the “YOURSERVERIP” with your host server’s IP address.$ rdesktop -a 16 YOURSERVERIP
To stop your vm from command line.

$ VBoxManage controlvm “Gentoo” savestate

Most desktop computers should already have this. Ubuntu users can use the above command to run rdesktop. If you are in Gnome, it is also located under Applications > Internet > Remote Desktop Viewer. Windows user’s can use the Remote Desktop Connection utility found under Start > Programs > Accessories > Remote Desktop Connection.
So as a closing note, I would highly recommend heading over to http://www.virtualbox.org/manual/UserManual.html#id2515738 . Sun’s documentation on VirtualBox is very well written. There are tons of other things you can do from the command line to manage your vm’s.

install vim7.2 on debian

wget ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2

sudo apt-get install libncurses5-dev

tar xf vim-7.2.tar.bz2

cd vim72

sudo ./configure –with-features=huge –enable-cscope –enable-multibyte

sudo make

sudo make install

enable syntax :

/bin/cp runtime/gvimrc_example.vim ~/.vimrc

tcpdump详细用法

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://dgfpeak.blog.51cto.com/195468/277304
常用参数简介:
-i指定监听网卡,用于机器有多个网卡的情况
-c指定要监听的数据包的数量
-w将监听到的数据包存入文件中

I.定义类型的参数
包括host,net,port,分别对应着主机,网络地址和端口

II.定义传输方向的参数
包括src,dst,dst or src,dst and src

III.定义协议的参数
包括fddi,ip,arp,tcp,udp等

IV.除以上之外还有gateway,broadcast,less,greater
逻辑运算符:1)非 not ! 2)与 and && 3)或 or ||

1> #tcpdump 直接启动tcpdump默认监听第一块网卡上面流过的所有数据包
2> #tcpdump host 222.222.222.222 获取该主机上面收到和发出的所有数据包
3> #tcpdump host A and \(B or C\) 获取主机A和B或C的通信信息,注意括号
4> #tcpdump ip host A and !B 获取A和除了B的所有ip包
5> #tcpdump tcp port 23 host A 获取A发出或接受的所有telnet包
6> #tcpdump udp port 123 监听udp123端口的ntp服务
7> #tcpdump -i eth0 src host hostname 监听来自hostname的所有信息
8> #tcpdump -i eth0 gateway gatewayname 监听通过网关的数据包
9> #tcpdump -i eth0 host hostname and (src or dst)port 80 监听指定端口的信息

当网卡开启混杂模式时,系统日志里会有如下信息
March 9 10:03:06 localhost kernel: eth0: Promiscuous mode enabled.
March 9 10:03:06 localhost kernel: device eth0 entered promiscuous mode
March 9 10:03:07 localhost kernel: device eth0 left promiscuous mode

tcpdump对截获的数据并没有进行彻底解码,数据包内的大部分内容是使用十六进制的形式直接打印输出的。显然这不利于分析网络故障,通常的解决办法是 先使用带-w参数的tcpdump 截获数据并保存到文件中,然后再使用其他程序进行解码分析。当然也应该定义过滤规则,以避免捕获的数据包填满整个硬盘。

除了过滤语句,还有一个很重要的参数,也就是说,如果这个参数不设置正确,会导致包数据的丢失!它就是-s 参数,是数据包的截取长度,仔细看man就会明白的!默认截取长度为60个字节,但一般ethernet MTU都是1500字节。所以,要抓取大于60字节的包时,使用默认参数就会导致包数据丢失!

只要使用-s 0就可以按包长,截取数据

本文出自 “Get and Share” 博客,请务必保留此出处http://dgfpeak.blog.51cto.com/195468/277304

Vim 杀手级 Tip: 快速处理配对标点符号中的文本

这称得上是一个 Vim 的杀手级 Tip,利用该 Tip,你可以快速处理 ‘、”、()、[]、{}、<> 等配对标点符号中的文本内容,包括更改、删除、复制等。
ci’、ci”、ci(、ci[、ci{、ci< – 分别更改这些配对标点符号中的文本内容
di’、di”、di(、di[、di{、di< – 分别删除这些配对标点符号中的文本内容
yi’、yi”、yi(、yi[、yi{、yi< – 分别复制这些配对标点符号中的文本内容

对于经常用 Vim 写代码的朋友来说,善用此 Tip 将极大的提高编码效率。

转载自:http://linuxtoy.org/archives/killer-vim-tip.html

使用mod_rewrite时要当心MultiViews

使用mod_rewrite时要当心MultiViews

先看我遇到的问题:试图使用如下rewrite代码

RewriteEngine On

RewriteBase /dex/

RewriteRule ^wsdl/(sjz|bd|qhd|common)/?$ wsdl.php?u=$1 [L]

RewriteRule ^wsdl/?$ wsdl.php [L]

达到以下转换效果:

wsdl/sjz –> wsdl.php?u=sjz

wsdl/ –> wsdl.php

但天不随人愿,第二行转换效果没问题,第一行转换效果总是出不来,查了一下RewriteLog,有一句引起了我的注意:

(1) pass through /dex/wsdl/sjz

(3) [per-dir E:/cvswork/2005dex/] add path info postfix: E:/cvswork/2005dex/wsdl.php -> E:/cvswork/2005dex/wsdl.php/sjz

注意看第二句,它怎么把wsdl/sjz转换成了wsdl.php/sjz?难道和第二句RewriteRule有关?试着把第二句RewriteRule关掉,问题依旧。

于是祭起Google海搜,发现有人和我遇到了同样的问题:

the problem lies in here somewhere

with URL http://localhost/index/q we get:-

add path-info postfix: c:/wwwroot/index.php -> c:/wwwroot/index.php/q

strip per-dir prefix: c:/wwwroot/index.php/q -> index.php/q

applying pattern ‘^([^/.]*)$’ to uri ‘index.php/q’

I dont want index.php/q though!!!!! argghhhhh!!!

……

GOT IT!!!!!!!

Bl**dy windows OS

i removed the .htaccess file and http://localhost/phpinfo/x was still doing phpinfo.php

I added a directory called phpinfo and it worked – giving a directory listing

I re-created the .htaccess and voila it worked.

So basically if a directory doesnt exist it looks for a script (.php .html) and then uses that with further parameters sdded to the end of it.

I have to find a workaround for that now.

原来,是Apache在当前目录下找到了wsdl.php(依据wsdl/sjz中的wsdl),并且来了个狸猫换太子,继续搜索……终于在这个德语网页找到了答案:

MultiViews-option abschalten.

wenn diese aktiviert ist, würde ein request nach /kategorie auch kategorie.php finden, und das kollidiert natürlich mit deiner RewriteRule, weil dort eben mit /kategorie/irgendwas ebenfalls ein “treffer” vorliegt – da kann der server also nicht entscheiden, was jetzt eigentlich gemeint ist.

上面是德语,我是看不懂的,用Google翻译如下:

MultiViews option switch off.

if this is activated, after/category kategorie.php to also find request, and collides naturally with your RewriteRule, because evenly with/category/something is likewise present there a “hit” – there the server cannot decide thus, what is now actually meant.

原来是Apache的MultiViews选项干扰了RewriteRule,将其去掉之后,问题排除。

Options -MultiViews

继续寻找MultiViews的相关信息,收获如下:

* Beware of Apache’s Multiviews

* 内容协商(Apache手册中文版mod_negotiation部分)

所以,在没有明确需要的情况下,一般不要打开MultiViews选项,因为我们一般编写的程序很少用到它,反而会给正常的程序调试带来麻烦,另外早期的版本可能还存在一些安全问题。

在去掉MultiViews的同时,发现还有一个好像也没有用的Options——FollowSymLinks,但如果你的 RewriteRule是写在.htaccess文件中的话,FollowSymLinks这个选项可不能去掉,去掉了RewriteEngine就不干活啦~~

转载自:http://doc.linuxpk.com/4941.html

2010年六月
« 5月   7月 »
 123456
78910111213
14151617181920
21222324252627
282930