For CSS, I use "csstidy", the C++ version. I added CSS 3.0 support to it and also added a default "indented" template. You can get the latest version at:
https://bitbucket.org/tiebingzhang/csstidy
For Javascript, I use the command line version of jsbeautifier, which can be downloaded at
http://github.com/einars/js-beautify/zipball/master
For PHP, I use an enhanced version of phptidy:
https://bitbucket.org/tiebingzhang/phptidy
June 18, 2012
php.ini send email on Linux
If you just want to send email (not receiving email) from your PHP server, and you have a SMTP Email server, here is how you do it:
(First, you don't need to edit your php.ini file SMTP settings, because on Linux those are not used by PHP)
1. Install SSMTP on your system (Debian/Ubuntu via apt-get, RHEL/CentOS using the Fedora EPEL Package search to find the package.
2. Use "ssmtp" to replace "sendmail" on your system. ssmtp use the same command argument as sendmail.
3. configure your /etc/ssmtp/ssmtp.conf file:
root=postmaster
mailhub=SMTP SERVER IP ADDRESS
RewriteDomain=your_from_domain.com
#this allows you to specify your from address
FromLineOverride=YES
sSMTP will then wait for you to type your message, which needs to be formatted like this:
Note the blank like after the subject, everything after this line is the body of the email. When you’re finished, press Ctrl-D.
You can also use script. Create a file msg.txt, then send it:
msg.txt is a simple text using the proper formatting for sSMTP:
(First, you don't need to edit your php.ini file SMTP settings, because on Linux those are not used by PHP)
1. Install SSMTP on your system (Debian/Ubuntu via apt-get, RHEL/CentOS using the Fedora EPEL Package search to find the package.
2. Use "ssmtp" to replace "sendmail" on your system. ssmtp use the same command argument as sendmail.
3. configure your /etc/ssmtp/ssmtp.conf file:
root=postmaster
mailhub=SMTP SERVER IP ADDRESS
RewriteDomain=your_from_domain.com
#this allows you to specify your from address
FromLineOverride=YES
4. Now send an email. Type
ssmtp recipient_email@example.comsSMTP will then wait for you to type your message, which needs to be formatted like this:
To: recipient_email@example.com
From: myemailaddress@gmail.com
Subject: test email
hello world!Note the blank like after the subject, everything after this line is the body of the email. When you’re finished, press Ctrl-D.
You can also use script. Create a file msg.txt, then send it:
ssmtp myemailaddress@gmail.com < msg.txt
msg.txt is a simple text using the proper formatting for sSMTP:
To: myemailaddress@gmail.com
From: myemailaddress@gmail.com
Subject: alert
The server is down!
Credit: http://tombuntu.com/index.php/2008/10/21/sending-email-from-your-system-with-ssmtp/
June 15, 2012
June 7, 2012
RHEL/Centos sysconfig network scripts
The /etc/sysconfig/network-scripts/ifcfg-ethN files
File configurations for each network device you may have or want to add on your system are located in the /etc/sysconfig/network-scripts/ directory with Red Hat Linux 6.1 or 6.2 and are named ifcfg-eth0 for the first interface and ifcfg-eth1 for the second, etc. Following is a example /etc/sysconfig/network-scripts/ifcfg-eth0 file: DEVICE=eth0
IPADDR=208.164.186.1
NETMASK=255.255.255.0
NETWORK=208.164.186.0
BROADCAST=208.164.186.255
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
|
- DEVICE=devicename, where devicename is the name of the physical network device.
- IPADDR=ipaddr, where ipaddr is the IP address.
- NETMASK=netmask, where netmask is the netmask IP value.
- NETWORK=network, where network is the network IP address.
- BROADCAST=broadcast, where broadcast is the broadcast IP address.
- ONBOOT=answer, where answer is yes or no. Do the interface need to be active or inactive at boot time.
-
BOOTPROTO=proto, where proto is one of the following :
- none - No boot-time protocol should be used.
- bootp - The bootp now pump protocol should be used.
- dhcp - The dhcp protocol should be used.
-
USERCTL=answer, where answer is one of the following:
- yes - Non-root users are allowed to control this device.
-
no - Only the super-user root is allowed to control this device.
NM_CONTROLLED="no"/"yes" : Whether Network-Manager controlled
May 25, 2012
xargs argument replacement
This is how xargs works:
cat listfile | xargs ls
but if you want to use the argument in the middle, such as "mv", you need to do the following:
cat listfile | xargs -I {} mv {} trash
-I {} tells xargs to replace all instances of {} with the argument from listfile.
So you can use other weird strings as long as you know it does not appear in the listfile, such as
cat listfile | xargs -I HAHA mv HAHA trash
cat listfile | xargs ls
but if you want to use the argument in the middle, such as "mv", you need to do the following:
cat listfile | xargs -I {} mv {} trash
-I {} tells xargs to replace all instances of {} with the argument from listfile.
So you can use other weird strings as long as you know it does not appear in the listfile, such as
cat listfile | xargs -I HAHA mv HAHA trash
May 18, 2012
Windows 7 IKEv2 with StrongSwan Certificate Generation Guide
Windows 7 supports IPSec IKEv2 with machine certificate authentication. Using StrongSwan on Linux for server, this is a good solution for Road Warrior remote access.
The problem with Windows 7 IKEv2 client is that it does not provide any log for trouble-shooting at all. So if it does not like something in your setup, it simply throws an error number and a very vague error message. Error 13806 is one of them.
I spent a few days finally got my Windows 7 running IKEv2 machine authentication with my strongswan server. Below are a few tips for Error 13806:
1. Error 13806 is because the machine certificate or CA certificate on the Windows 7 has problems. This is NOT about the Server's certificate. So focus on fixing the Windows 7 certificates. The error message does not really tell you this clearly.
2. There are a few variables in your client certificate that are important, whether you use OpenSSL or StrongSwan ipsec pki to generate your certs:
Here is what works and what does not work in my tests (For Windows 7 client only, not for StrongSwan server):
The name win7.mycompany.local does not have to be in your DNS server.
What works:
What does not work (Error 13806):
The problem with Windows 7 IKEv2 client is that it does not provide any log for trouble-shooting at all. So if it does not like something in your setup, it simply throws an error number and a very vague error message. Error 13806 is one of them.
I spent a few days finally got my Windows 7 running IKEv2 machine authentication with my strongswan server. Below are a few tips for Error 13806:
1. Error 13806 is because the machine certificate or CA certificate on the Windows 7 has problems. This is NOT about the Server's certificate. So focus on fixing the Windows 7 certificates. The error message does not really tell you this clearly.
2. There are a few variables in your client certificate that are important, whether you use OpenSSL or StrongSwan ipsec pki to generate your certs:
- The Common Name (CN) in the subject of your certificate
- The Subject Alternative Name (SAN)
- The Key Usage
- The Extended Key Usage, where you can specify "clientAuth", "serverAuth", "1.3.6.1.5.5.8.2.2", either one or a combination of them.
Here is what works and what does not work in my tests (For Windows 7 client only, not for StrongSwan server):
- You do not need to set Key Usage and Extended Key Usage(EKU). If you set them, some combinations may cause trouble. see more below.
- You do not need to set SAN. If you really want to set it, it has to be exactly the same as the CN. Otherwise you will get Error 13806.
- Set CN to either a full DNS name such as "win7.mycompany.local", or just a string name "win7". Either one works.
- If you set Key Usage to "nonRepudiation, digitalSignature, keyEncipherment", and Extended Key Usage to "1.3.6.1.5.5.8.2.2,serverAuth,clientAuth", you MUST set your CN to the long form of DNS name such as "win7.mycompany.local". Using the short form "win7" will fail and cause error 13806.
The name win7.mycompany.local does not have to be in your DNS server.
What works:
- CN="win7", no SAN, No Keyusage, No EKU.
- CN="win7", SAN="win7", No Keyusage, No EKU.
- CN="win7.mycompany.local", SAN="win7.mycompany.local", No Keyusage, No EKU.
- CN="win7.mycompany.local", SAN="win7.mycompany.local",keyUsage = nonRepudiation, digitalSignature, keyEncipherment, extendedKeyUsage = 1.3.6.1.5.5.8.2.2,serverAuth,clientAuth
What does not work (Error 13806):
- CN="win7", SAN="something else", No Keyusage, No EKU.
- CN="win7", SAN="win7",keyUsage = nonRepudiation, digitalSignature, keyEncipherment, extendedKeyUsage = 1.3.6.1.5.5.8.2.2,serverAuth,clientAuth
Your server certificate should have the following:
- CN
- SAN, which should be exactly the same as your CN
- keyUsage = nonRepudiation, digitalSignature, keyEncipherment,
- extendedKeyUsage = 1.3.6.1.5.5.8.2.2,serverAuth
Your Windows 7 VPN connection host name should exactly the same as the Server's CN. And that CN name should be DNS resolvable. The easiest way to do that in a test environment is to add the CN name to your local computer's host file, located at "c:\windows\system32\drivers\etc\hosts"
Of course you should read StrongSwan's Wiki page on Windows 7. Very helpful, although can be a little bit more detailed on the client side. (http://wiki.strongswan.org/projects/strongswan/wiki/Windows7)
Andreas at StrongSwan also pointed out to me that although ECDSA has been supported by Windows since Windows Vista, it only works in IKEv1. IKEv2 in Windows 7 and Windows 2008 R2 does not support ECDSA. I have also personally verified that this is true.
One more important note:
Please make sure all your certificates has the PKIX recommended "Authority Key Identifier" in it. Otherwise, Windows 7 will give an Error 13806.
If you use OpenSSL to generate your certs, make sure the following line is in your openssl.conf file:
authorityKeyIdentifier=keyid,issuer
Please make sure all your certificates has the PKIX recommended "Authority Key Identifier" in it. Otherwise, Windows 7 will give an Error 13806.
If you use OpenSSL to generate your certs, make sure the following line is in your openssl.conf file:
authorityKeyIdentifier=keyid,issuer
"Subject Key Identifier" seems to be optional for Windows 7.
Another useful post on this subject: http://forums.opensuse.org/english/get-technical-help-here/network-internet/435097-strongswan-opensuse-11-2-quick-setup.html
More Update:
Following above-written rules, I was able to generate certificates using StrongSwan ipsec pki command for both Windows 7 and StrongSwan, and the IKEv2 connection was established.
Here are the scripts:
First, Generate the CA:
bits=2048
ipsec pki --gen --type rsa --size $bits --outform pem > ca.key
ipsec pki --self --flag serverAuth --in ca.key --type rsa --digest sha1 --dn "C=CH, O=strongSwan, CN=pkiCA" --ca > caCert.der
Another useful post on this subject: http://forums.opensuse.org/english/get-technical-help-here/network-internet/435097-strongswan-opensuse-11-2-quick-setup.html
More Update:
Following above-written rules, I was able to generate certificates using StrongSwan ipsec pki command for both Windows 7 and StrongSwan, and the IKEv2 connection was established.
Here are the scripts:
First, Generate the CA:
bits=2048
ipsec pki --gen --type rsa --size $bits --outform pem > ca.key
ipsec pki --self --flag serverAuth --in ca.key --type rsa --digest sha1 --dn "C=CH, O=strongSwan, CN=pkiCA" --ca > caCert.der
Next, generate two certs, one for Server and one for Win7
bits=2048
for user in server win7; do
ipsec pki --gen --type rsa --size $bits --outform pem > $user.key
flags="";
[ "$user" = "server" ] && flags="--flag serverAuth";
ipsec pki --pub --in $user.key --type rsa | ipsec pki --issue --cacert caCert.der --cakey ca.key --digest sha1 \
--dn "C=CH, O=strongSwan, CN=$user.mycompany.local" --san "$user.mycompany.local" $flags --outform pem > $user.cert
done;
Next convert Win7 cert to P12 format:
# Usage: ./convert-to-p12.sh Username
user=$1
openssl pkcs12 -export -inkey $user.key -in $user.cert -name "$user" -certfile caCert.der -caname "vpnserver7" -out $user.p12
then run ./convert-to-p12.sh win7
Next convert Server key to DER format so that Strongswan can take it:
openssl rsa -in $1.key -out $1.der -outform DER
where $1 is "server"
May 4, 2012
[Solved] apt-get “is to be installed” errors in Debian
Fortunately, you can force the version in apt-get:
sudo apt-get install deluge-common=1.3.0-0ubuntu1
Source: http://www.absolutelytech.com/2010/10/17/solved-apt-get-is-to-be-installed-errors-in-ubuntu/
March 21, 2012
use vimdiff for hg diff
put the following to your ~/.hgrc file
[extensions]
hgext.extdiff =
[extdiff]
cmd.vimdiff =
[alias]
vi = vimdiff
vim = vimdiff
March 12, 2012
ubuntu update issue
If your ubuntu is failing to update/install software, make sure you have the ubuntu update repository set in your apt source.list file:
###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
February 23, 2012
FINDDUPE: Duplicate file detector and eliminator
FINDDUPE: Duplicate file detector and eliminator
This tools is cool. Especially the hard-linking feature:
Freeing hard drive space
Sometimes its intentional to have certain media in multiple places. By running finddupe, and hard linking the identical files, you can keep the files in multiple places, while only having one physical copy on the hard drive.
Sometimes its intentional to have certain media in multiple places. By running finddupe, and hard linking the identical files, you can keep the files in multiple places, while only having one physical copy on the hard drive.
February 1, 2012
IE and IPv6 address
To use IPv6 address in your IE8/IE9 address bar, you have to add a square bracket to the beginning and the end of the IP address. Your IPv6 URL will look something like this:
http://[2001:1:1::02]
http://[2001:1:1::02]
January 24, 2012
Change WireShark Dispaly Time to GMT/UTC or other timezone
On Windows:
1. Open a CMD window
2. set TZ=GMT or TZ=GMT10 or set TZ=GMT-5 (whatever you want your timezone to be)
3. lunch wireshark by: "C:\Program Files\Wireshark\wireshark.exe"
On Linux:
TZ=GMT wireshark
January 13, 2012
rsync using a different ssh port
# rsync -avz -e "ssh -p $portNumber" user@remoteip:/path/to/files/ /local/path/
December 30, 2011
Disable Windows Temporary IPv6 Address
In a "cmd" window with administrative rights, run the following commands:
netsh interface ipv6 set privacy state=disabled store=active
netsh interface ipv6 set privacy state=disabled store=persistent
netsh interface ipv6 set global randomizeidentifiers=disabled store=active
netsh interface ipv6 set global randomizeidentifiers=disabled store=persistent
netsh interface ipv6 set privacy state=disabled store=persistent
netsh interface ipv6 set global randomizeidentifiers=disabled store=active
netsh interface ipv6 set global randomizeidentifiers=disabled store=persistent
Then Restart your machine.
December 29, 2011
Shrew Soft VPN client group auth key auth-mutual-psk
If you are provided with a shrew-soft Windows VPN client from your company, and you would like to run a VPN client on Linux. You can either use the Shrew VPN client Linux version or another open source VPN client "vpnc".
To run vpnc, you will need to know the group password. If you export your Shrew VPN profile which is a plain text file, you will see a line in the file that starts with:
b:auth-mutual-psk:
This is the group password, encoded with BASE64 format. So just copy the value and paste it to any web-based BASE64 decoder such as the one http://www.opinionatedgeek.com/dotnet/tools/Base64Decode/ (This link happens to be on the top when I searched and it works fine), then you get the group password in plain-text.
To run vpnc, you will need to know the group password. If you export your Shrew VPN profile which is a plain text file, you will see a line in the file that starts with:
b:auth-mutual-psk:
This is the group password, encoded with BASE64 format. So just copy the value and paste it to any web-based BASE64 decoder such as the one http://www.opinionatedgeek.com/dotnet/tools/Base64Decode/ (This link happens to be on the top when I searched and it works fine), then you get the group password in plain-text.
December 28, 2011
Running User Mode Linux as normal non-root user
User Mode Linux (UML) is running linux over linux. The guest linux OS runs as a regular process on the host CPU. UML has been around for a while, the famous windows-based "coLinux" is inspired by it.
An unique feature of UML is that you can run it on a powerful Linux server as a regular user. You do not need any sort of root permission to run it. In fact, this is the only feasible solution for a non-root user (other than QEMU running in emulation mode which is much much slower). UML in fast.
To get UML running, you need two things: the kernel and the file system. UML provides the kernel and the compilation is straightforward.
To get file system, you need to have root access on a Linux machine (does not have to be your final HOST machine) and do the following:
An unique feature of UML is that you can run it on a powerful Linux server as a regular user. You do not need any sort of root permission to run it. In fact, this is the only feasible solution for a non-root user (other than QEMU running in emulation mode which is much much slower). UML in fast.
To get UML running, you need two things: the kernel and the file system. UML provides the kernel and the compilation is straightforward.
To get file system, you need to have root access on a Linux machine (does not have to be your final HOST machine) and do the following:
(root@host)# apt-get install debootstrap
(root@host)# cd /tmp (root@host)# dd if=/dev/zero of=debian.bin bs=1M count=1 seek=4096 (root@host)# mkfs.ext3 debian.bin(root@host)# mkdir -p /mnt; mount -o loop debian.bin /mnt (root@host)# debootstrap squeeze /mntIf you are in the year after 2012, Replace "squeeze" with whatever the latest debian stable version name is.(root@host)# chroot /mnt(chroot@host)# mkdir /dev/ubd (chroot@host)# cd /dev/ubd (chroot@host)# for i in 0 1 2 3 4 5 6 7; do mknod $i b 98 $[ $i * 16 ]; done(chroot@host)# cat > /etc/fstab << EOF /dev/ubd/0 / xfs defaults 0 0 /dev/ubd/1 none swap defaults 0 0 none /proc proc defaults 0 0 sys /sys sysfs defaults 0 0 none /dev/pts devpts defaults 0 0 EOF(chroot@host)# echo uml0 > /etc/hostname(chroot@host)# exit (root@host)# rm -f /mnt/root/.bash_history (root@host)# umount /mntNow the file debian.bin has the latest debian base installation. This is your File System.Now you need to download and compile Slirp from http://slirp.sourceforge.net/. Slirp is a cool hack that allows UML limited access to the network bytunneling it over regular UDP and TCP connections. This is really the key to making UML useful as a regular user. The other (better) methods for accessing the network need root access. Be sure to apply the latest patch, as otherwise it does not work. It is critical to editconfig.hand uncomment the line that says#define FULL_BOLT. This will make Slirp go as fast as it can. Otherwise, slirp will only go 115kbps. Trying to do "apt-get" over that is painful.Copy the slirp program you build to /home/YOU/bin/./linux ubd0=debian6.bin con=pts con0=fd:0,fd:1 eth0=slirp,,/home/user/bin/slirpI also add "single rw" to get linux boot into single mode and get me started. Once everything is running, I take out "single rw" so that all the daemons are started correctly.I also have a file ~/.slirprc to direct TCP connections so that I can ssh into the UML.#cat ~/.slirprc redir 2200 22
December 23, 2011
StrongSwan Configuration Guide
Recently I got a chance to study strongswan and its
configurations. This document intends to record the findings, in the hope to
help myself in the future and to help others too.
Conn
myvpn
Strongswan is open-source IPSec/VPN software. It was based
on FreeSwan, whose development is now stopped. Another descendent of FreeSwan
is “OpenSwan”. I have no experience with OpenSwan, and therefore will be
focusing on StrongSwan in this document.
By the way, I found the authors of StrongSwan (Andrea and
Martini) very much helpful. The know strongswan inside out and was able to
explain things really well in many of the mailinglist posts and also in the
wiki documentation. This is a great strength of strongswan.
StrongSwan’s core VPN behavior is largely controlled by the
configuration file /etc/ipsec.conf. There are many possible lines there you can
put in this file. Some lines are extremely important, and a good understanding
of what they mean is critical to the successful establishment of the VPN
tunnels.
There are a few types of VPN Connections:
- Host to Host
- Net to Net
- Host to Net
Host to Host is fairly rare, and many of the things discussed
here also apply to apply to it. So I will focus on “net-net” and “host-net”.
The following settings are tested with StrongSwan 4.5.3 and
4.6.1.
1.
Common Configuration
Common configuration lines in /etc/ipsec.conf
config setup
strictcrlpolicy=no
charonstart=yes
plutostart=no
conn %default
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
keyexchange=ikev2
esp=aes256gcm16,aes128gcm16!
mobike=yes
leftikeport=4500
rightikeport=4500
Explanations:
“strictcrlpolicy” indicates whether CRL is mandatory or not.
If CRL is not mandatory, put no. Otherwise, put yes.
“Charon” is the IKEv2 daemon, and “Pluto” is the IKEv1
daemon. In this document, we are only using “IKEv2” and will focus on IKEv2
options only.
“Mobike” stands for Mobile IKE. This is for the case where
the public IP of the device may change. If Mobike is enabled, strongswan may
float its communication port from UDP port 500 to UDP port 4500 and start
telling the Linux kernel to use UDP encapsulation for ESP packets. It is a good thing to enable if there is a
chance that your device’s public IP may change.
“leftikepor” and “rightikeport” tells strongswan to always
use UDP port 4500, from the very beginning of IKEv2 message exchange.
2.
Net to Net
2.1 VPN Server
A working net-net VPN SERVER configuration file
left=%defaultroute
leftcert=/etc/certs/vpn.cert
leftsubnet=192.168.17.0/24
leftfirewall=yes
right=%any
rightsubnet=0.0.0.0/0
auto=add
Left means “my side”. Right means “my peer’s side”. You could switch it the other way, but this
is how most people use it and is a common convention. Unless one really wants
to be different and asking for troubles, it is strongly suggested that this
common convention be followed.
“left” is your IP address. This can be set to
“%defaultroute” where the system will figure out the value based on the “right”
IP address.
“leftcert” is the certificate file of the left. The file
path can be an absolute path (starting with /) or a relative path, in which
case, the system will look for certs under /etc/ipsec.d/certs/
“leftsubnet”: This is “the” critical line that tells
strongswan you want a subnet tunnel instead of a host tunnel. Without this
line, the strongswan will try to make a host-only tunnel. This is the subnet on “your” device’s side.
Your peers will only be able to talk to IPs in this subnet.
“leftfirewall”: optional. Tells strongswan to automatically
insert firewall rules (iptables rules) when a connection is up or down.
“right” is the peer’s address. For server, this can be
“%any”.
“rightsubnet”: similar to “leftsubnet”, this line is
critical to indicating that you want to connect to a “subnet”, not just a
remote host. Unless “leftsubnet”, you can put “0.0.0.0/0” indicating that you
just accept the subnet that the peer defines.
“auto=add” means when you run “ipsec start”, the ipsec
daemon just listens, not initiate a connection. “auto=start” means that when
you run “ipsec start”, the ipsec daemon will actually try to initiate a call.
So “auto=add” is good for servers, and “auto=start” is good for clients.
“auto=start” is equivalent to “auto=add” plus “ipsec up MYCONNECTION”
We skipped “leftid=”. leftid by default is derived from the
leftcert certificate file, using the Distinguished Name, in the format of
“C=XX, O=XXX, CN=XXX, …”. There are any forms of ID that can be used by the
leftid/rightid field, but in this document we chose to use this format. See the
end of this document for more detailed description of leftid/rightid field.
A working net-net VPN CLIENT configuration file
Net-net is pretty much symmetrical. You can run the above
same configuration file on client side and it will work. I chose to one more
configuration line:
rightid="C=CH, O=strongSwan, CN=server"
This tells the client to check the server’s certificate ID
and make sure it matches this ID. This is just to be safe so that I know I did
not connect to some other server. Keep this mind this is after the server
certificate is being authenticated by the CA certificate.
3.
Host to Net
3.1 VPN Server
A working host-net VPN SERVER configuration file
conn server
leftcert=server.cert
leftfirewall=yes
right=%any
rightsourceip=192.168.22.0/24
auto=add
Notice that we simply removed “leftsubnet” and “rightsubnet”
from the net-net VPN SERVER configuration, and here we have a host-net VPN
SERVER.
We added one more line “rightsourceip”. This enables the
server to “automatically assign a virtual IP address to the connecting peer”.
Note that in IKEv1 (Pluto) "rightsourceip" can be used to specify the internal side IP address. For IKEv2 (Charon) this is done automatically by the charon daemon and rightsourceip takes up the new meaning of requesting a virtual IP address. If the server does not have "rightsourceip" configured but client has "leftsourceip=x.x.x.x" configured, the tunnel establishment will fail because the server is rejecting the request for a virtual IP address.
Note that in IKEv1 (Pluto) "rightsourceip" can be used to specify the internal side IP address. For IKEv2 (Charon) this is done automatically by the charon daemon and rightsourceip takes up the new meaning of requesting a virtual IP address. If the server does not have "rightsourceip" configured but client has "leftsourceip=x.x.x.x" configured, the tunnel establishment will fail because the server is rejecting the request for a virtual IP address.
3.2 VPN Client
A working host-net VPN CLIENT configuration file
left=%defaultroute
leftcert=client.cert
leftsourceip=%config
leftfirewall=yes
right=192.168.5.1
rightid="C=CH, O=strongSwan, CN=server"
auto=start
The only special line here is “leftsourceip”, which tells
the client to obtain a virtual IP address from the VPN Server.
4.
leftid and rightid, what to use?
The ID by which a peer is identifying itself during IKE main
mode can by any of the ID types IPV4_ADDR, FQDN, USER_FQDN
or DER_ASN1_DN. If one of the first three ID types is used, then the
accompanying X.509 certificate of the peer must contain a matching subjectAltName
field of the type ipAddress (IP:), dnsName (DNS:)
or rfc822Name (email:), respectively. With the fourth type DER_ASN1_DN,
the identifier must completely match the subject field of the peer's
certificate. One of the two possible representations of a Distinguished
Name (DN) is the LDAP-type format
rightid="C=CH,O=Linux strongSwan,
CN=sun.strongswan.org"
Additional whitespace can be added everywhere as desired
since it will be automatically eliminated by the X.509 parser. An exception is
the single whitespace between individual words , like e.g. in Linux
strongSwan, which is preserved by the parser.
The Relative Distinguished Names (RDNs) can alternatively be
separated by a slash ( '/') instead of a comma (',')
rightid="/C=CH/O=Linux
strongSwan/CN=sun.strongswan.org"
This is the representation extracted from the certificate by
the OpenSSL command line option
openssl x509 -in sunCert.pem -noout –subject
The following X.501 RDNs are supported by strongSwan
DC
|
Domain Component
|
C
|
Country
|
ST
|
State or province
|
L
|
Locality or town
|
O
|
Organisation
|
OU
|
Organisational Unit
|
CN
|
Common Name
|
ND
|
Name Distinguisher,
used with CN
|
N
|
Name
|
G
|
Given name
|
S
|
Surname
|
I
|
Initials
|
T
|
Personal title
|
E
|
E-mail
|
Email
|
E-mail
|
emailAddress
|
E-mail
|
SN
|
Serial number
|
serialNumber
|
Serial number
|
D
|
Description
|
UID
|
User ID
|
ID
|
X.500 Unique
Identifier
|
TCGID
|
[Siemens]
|
unstructuredName
|
Unstructured Name
|
UN
|
Unstructured Name
|
employeeNumber
|
Employee Number
|
EN
|
Employee Number
|
5.
Recommended Documentation
- http://www.strongswan.org/docs/readme.htm
I’ve found this readme file very helpful, although it may be a little old.
Information presented here still applies. It is a good starting point, and gives
you a good base understanding of everything. This should be the first
read, and then you can move on to other documentation such as the wiki.
- Strong Swan WiKi, which contains “lots of”
information. Here is a guide to get you started:
December 15, 2011
ubuntu kvm KSM high cpu usage
Source: http://www.interphero.com/?p=219
If you use KVM virtualization, under Ubuntu 10.04 Server LTS, with more than one virtual host running at a time, you may have noticed ksmd eating a lot of CPU cycles. This behavior was not present under 8.04 Server LTS. Apparently, the kmsd functionality was enabled by default in 10.04. KSM – Kernel Samepage Merging – merges memory pages between virtual hosts to save space. Unfortunately, for some, it also utilizes a lot of CPU resources to perform this function. For my use case, I don’t care about the amount of RAM occupied by my virtual hosts, indeed, I installed far more RAM than I need in my server so that I don’t have to worry about a lack of RAM.
If you would like to disable ksmd, edit your /etc/default/qemu-kvm file as follows:
# To disable qemu-kvm’s page merging feature, set KSM_ENABLED=0 and
# sudo restart qemu-kvm
KSM_ENABLED=0
#SLEEP_MILLISECS=2000
Then, as the comments in the file state, restart qemu-kvm. (stop your VM, then "sudo stop qemu-kvm", then "sudo start qemu-kvm")
If you use KVM virtualization, under Ubuntu 10.04 Server LTS, with more than one virtual host running at a time, you may have noticed ksmd eating a lot of CPU cycles. This behavior was not present under 8.04 Server LTS. Apparently, the kmsd functionality was enabled by default in 10.04. KSM – Kernel Samepage Merging – merges memory pages between virtual hosts to save space. Unfortunately, for some, it also utilizes a lot of CPU resources to perform this function. For my use case, I don’t care about the amount of RAM occupied by my virtual hosts, indeed, I installed far more RAM than I need in my server so that I don’t have to worry about a lack of RAM.
If you would like to disable ksmd, edit your /etc/default/qemu-kvm file as follows:
# To disable qemu-kvm’s page merging feature, set KSM_ENABLED=0 and
# sudo restart qemu-kvm
KSM_ENABLED=0
#SLEEP_MILLISECS=2000
Then, as the comments in the file state, restart qemu-kvm. (stop your VM, then "sudo stop qemu-kvm", then "sudo start qemu-kvm")
December 13, 2011
Net-snmp debug token list
http://net-snmp.sourceforge.net/wiki/index.php/Debug_tokens_5.4.2.1
For example: register_mib is an useful token for debugging SNMP AGENTX subagents.
For example: register_mib is an useful token for debugging SNMP AGENTX subagents.
December 7, 2011
crontab for non-root user
If you could not get your crontab file to work with non-root user, and you have made sure the crond is running and your crontab syntax is correct, check this:
Make sure there is an empty line as last line in your crontab file.
This fixed my problem.
Make sure there is an empty line as last line in your crontab file.
This fixed my problem.
Subscribe to:
Posts (Atom)