Wireless Ad-Hoc connection sharing in Ubuntu 10.10
Fri, 11/16/2012 - 18:05 — sandip-
dnsmasq-base has to be installed:
sudo apt-get install dnsmasq-base
sudo apt-get remove dnsmasq
sudo /etc/init.d/network-manager restart
Set encryption to WEP 40/128-bit Key with a 13 characters key. (Note: You may have to experiment here according to what type of encryption with ad-hoc the device supports. WPA is not supported).
NetworkManager now should connect to itself (which means it creates the ad-hoc wireless network and routes any Internet traffic to your wired network interface). Now, connect with the client(s), and you should have a working Internet connection.
You have to make sure that this connection is shared to other computers and devices (clients). Make sure that the Connect automatically check-box is selected and on the IPv4 Settings tab make sure that the Method option is set to "Shared to other computers".
- sandip's blog
- Login or register to post comments
- Read more
Updating OpenVZ vzctl on CentOS-5.8
Wed, 11/14/2012 - 11:27 — sandipWhile updating vzctl to latest on CentOS-5.8, I was getting the below error:
# yum update vzctl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* openvz-kernel-rhel5: mirror.fdcservers.net
* openvz-utils: mirror.fdcservers.net
Excluding Packages in global exclude list
Finished
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package vzctl.x86_64 0:4.1-1 set to be updated
--> Processing Dependency: vzctl-core = 4.1-1 for package: vzctl
--> Processing Dependency: libvzctl-4.1.so()(64bit) for package: vzctl
--> Processing Dependency: libcgroup.so.1()(64bit) for package: vzctl
--> Running transaction check
---> Package libcgroup.x86_64 0:0.37-4 set to be updated
---> Package vzctl-core.x86_64 0:4.1-1 set to be updated
--> Processing Conflict: vzctl conflicts ploop-lib < 1.5-1
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package ploop-lib.x86_64 0:1.5-1 set to be updated
--> Processing Conflict: ploop-lib conflicts vzkernel < 2.6.32-042stab061.1
--> Processing Conflict: ploop-lib conflicts vzkernel < 2.6.32-042stab061.1
--> Processing Conflict: ploop-lib conflicts vzkernel < 2.6.32-042stab061.1
--> Processing Conflict: ploop-lib conflicts vzkernel < 2.6.32-042stab061.1
--> Finished Dependency Resolution
ploop-lib-1.5-1.x86_64 from openvz-utils has depsolving problems
--> ploop-lib conflicts with ovzkernel
Error: ploop-lib conflicts with ovzkernel
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
&nbs p; &nbs p; &nbs p; &nbs p; package-cleanup --dupes
&nbs p; &nbs p; &nbs p; &nbs p; rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.
Turns out that ploop is no longer required for vzctl on CentOS-5.8 and can be removed:
yum update problem on CentOS 5.8 server
"Since you have RHEL5-based kernel that do not require ploop, you can remove ploop when installing vzctl-4.0. I have made vzctl not requiring ploop by dynamically loading it when it's available. Note that vzctl is not requiring ploop anymore, it just conflicts with the old version of it."
The solution was to remove ploop in single transaction as mentioned:
# yum shell
> update vzctl
> remove ploop\*
> run
> quit
- sandip's blog
- Login or register to post comments
- Read more
iscsi notes
Mon, 10/15/2012 - 10:13 — sandipiscsi target
-
Install iscsi utils:
yum install scsi-target-utils
chkconfig tgtd on
service tgtd start
# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2012-10.com.linuxweblog.sr v01:lv1_iscsi0
# tgtadm --lld iscsi --op delete --mode target --tid 1
# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/vg1/lv1_iscsi0
# tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 1
# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
# tgtadm --lld iscsi --op show --mode target
# tgt-admin --dump >/etc/tgt/targets.conf
iscsi initiator
-
install the initiator client:
# yum install iscsi-initiator-utils
# chkconfig iscsid on
# chkconfig iscsi on
# service iscsid start
# iscsiadm --mode discovery --type sendtargets --portal 192.168.1.11
# service iscsi restart
# iscsiadm --mode node --targetname iqn.2012-10.com.linuxweblog.sr v01:lv1_iscsi0 --portal 192.168.1.11 --login
# iscsiadm --mode node --targetname iqn.2012-10.com.linuxweblog.sr v01:lv1_iscsi0 --portal 192.168.1.11 --logout
# iscsiadm --mode node --targetname iqn.2012-10.com.linuxweblog.sr v01:lv1_iscsi0 --portal 192.168.1.11 -o delete
# iscsiadm -m session
# iscsiadm -m node
- sandip's blog
- Login or register to post comments
- Read more
Accessing ssh servers behind NAT
Tue, 10/09/2012 - 10:29 — sandipCreate a "config" file in your "~/.ssh" directory with the below contents:
Host server1
Hostname server1.example.com
HostKeyAlias server1
CheckHostIP no
Port 221
Host server2
Hostname server2.example.com
HostKeyAlias server2
CheckHostIP no
Port 222
The key is to set CheckHostIP to "no" and use "HostKeyAlias" to specify an alias that should be used instead of the real host name when looking up or saving the host key in the host key database files.
The Port line avoids having to specify the port when connectig.
Connect to corresponding host via:
$ ssh {user}@server1
$ ssh {user}@server2
- sandip's blog
- Login or register to post comments
- Read more
strace all apache child processes
Wed, 10/03/2012 - 15:51 — sandip# ps h --ppid `cat /var/run/httpd.pid` -o pid | awk '{print "-v -ff -tt -T -s 1024 -o /tmp/strace.out -p " $1}' | xargs strace
This will attach strace to each of the apache child processes.
-v verbose
-ff with -o will log the output to "/tmp/strace.out.{pid}" and follow forks.
-tt prints the timestamp of each call.
-T prints the duration of each call.
-s specifies the maximum size of the output string to more than the default 32.
Related links:
- sandip's blog
- Login or register to post comments
- Read more
md5 and sha1 digest with openssl
Thu, 08/30/2012 - 17:00 — sandipmd5 digest:
echo -n 'md5 digest of text' | openssl dgst -md5
841fc570f41fad1a64cc237b1612 7225
sha1 digest:
echo -n 'sha1 digest of text' | openssl dgst -sha1
80efdb4abbeb92c0ea15a4146d68 c39adff5ad47
- sandip's blog
- Login or register to post comments
- Read more
base64 encoding decoding with openssl
Thu, 08/30/2012 - 16:28 — sandipBase64 encoding with openssl:
echo -n 'encode this with base64' | openssl enc -base64
ZW5jb2RlIHRoaXMgd2l0aCBiYXNl NjQ=
Base64 decoding with openssl:
echo 'ZW5jb2RlIHRoaXMgd2l0aCBi YXNlNjQ=' | openssl enc -base64 -d
encode this with base64
- sandip's blog
- Login or register to post comments
- Read more
Handling filenames with spaces, carriage returns or other control characters
Mon, 08/27/2012 - 23:42 — sandipfind -print0 | while IFS= read -rd $'\0' filename ; do echo "[$filename]" ; done
-print0, prints the full file name on the standard output, followed by a null character instead of the newline character.
IFS, is the "Internal Field Separator" that is used for word splitting after expansion. Here, IFS is set to null string.
-r, specifies that backslash "\" does not act as an escape character.
-d, is the delimeter. Which in this case is the null character '\0'.
$'\0', the $ prefixed single quoted string decodes the backslash escape character. In this case a null character.
[], is simply there to print out the text, so you notice any spaces in the beginning and end of text.
- sandip's blog
- Login or register to post comments
- Read more
Get public IP Address
Mon, 08/27/2012 - 21:01 — sandipGet current public IP via command line curl and wget.
With curl:
curl icanhazip.com
curl ifconfig.me
With wget:
wget -qO- icanhazip.com
wget -qO- ifconfig.me/ip
- sandip's blog
- Login or register to post comments
- Read more
redirect stdout/stderr within bash script
Fri, 06/22/2012 - 08:04 — sandipThis executes the date command via shell script and logs it to the specified file with current pid.
#!/bin/bash
LOG=$$.log
exec > $LOG 2>&1
date
- sandip's blog
- Login or register to post comments
- Read more