<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Embedded Linux Vietnam</title>
	<atom:link href="http://www.tienphatads.com/embedded/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.tienphatads.com/embedded</link>
	<description>Welcome to Van Duc Uy&#039;s blogs</description>
	<lastBuildDate>Wed, 14 Dec 2011 08:10:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to test Netperf</title>
		<link>http://www.tienphatads.com/embedded/?p=271</link>
		<comments>http://www.tienphatads.com/embedded/?p=271#comments</comments>
		<pubDate>Thu, 02 Dec 2010 03:45:57 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Guide]]></category>
		<category><![CDATA[Linux Porting]]></category>
		<category><![CDATA[net]]></category>
		<category><![CDATA[netperf]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=271</guid>
		<description><![CDATA[You need 2 system to test netperf. PC.2: [root@pc.2]$ ./netserver -4 Starting netserver at port 12865 Starting netserver at hostname 0.0.0.0 port 12865 and family AF_INET [root@pc.2]$ PC.1: [root@pc.1]$ ./netperf -f M –l 120 -H 172.168.1.3 TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 172.168.1.3 (172.168.1.3) port 0 AF_INET Recv   Send    Send Socket [...]]]></description>
			<content:encoded><![CDATA[<p>You need 2 system to test netperf.</p>
<p><strong><span style="text-decoration: underline;">PC.2</span></strong>:</p>
<p><em><span style="color: #ff0000;">[root@pc.2]$ ./netserver -4</span></em></p>
<p><em>Starting netserver at port 12865</em></p>
<p><em>Starting netserver at hostname 0.0.0.0 port 12865 and family AF_INET</em></p>
<p><em>[root@pc.2]$</em></p>
<p><strong><span style="text-decoration: underline;">PC.1</span></strong>:</p>
<p><em><span style="color: #ff0000;">[root@pc.1]$ ./netperf -f M –l 120 -H 172.168.1.3</span></em></p>
<p><em>TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 172.168.1.3 (172.168.1.3) port 0 AF_INET</em></p>
<p><em>Recv   Send    Send</em></p>
<p><em>Socket Socket  Message  Elapsed</em></p>
<p><em>Size   Size    Size     Time     Throughput</em></p>
<p><em>bytes  bytes   bytes    secs.    MBytes/sec</em></p>
<p><em>87380  65535  65535    120.00      49.91</em></p>
<p><em>[root@pc.1]$</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=271</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSWAN: L2TP/IPSec common error</title>
		<link>http://www.tienphatads.com/embedded/?p=265</link>
		<comments>http://www.tienphatads.com/embedded/?p=265#comments</comments>
		<pubDate>Fri, 12 Nov 2010 09:29:04 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Guide]]></category>
		<category><![CDATA[Linux Porting]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=265</guid>
		<description><![CDATA[23:58:40 pluto[14958] packet from X.X.X.X:500: initial Main Mode message received on X.X.X.X:500 but no connection has been authorized with policy=PSK This is a very common error and will cause the vpn not to come up. This basically means that this end of the vpn (where the log is) has received a request to handshake an [...]]]></description>
			<content:encoded><![CDATA[<p><strong>23:58:40 pluto[14958] packet from X.X.X.X:500: initial Main Mode message received on X.X.X.X:500 but no connection has been authorized with policy=PSK</strong></p>
<p lang="en-AU">
<p lang="en-AU"><span style="font-family: 'Times New Roman', serif;"><span style="font-size: small;">This is a very common error and will cause the vpn not to come up. This basically means that this end of the vpn (where the log is) has received a request to handshake an ipsec vpn connection, but as far as this end of the link is concerned its not expecting a vpn connection from the ip address x.x.x.x and so ignores it.</span></span></p>
<p lang="en-AU"><span style="font-family: 'Times New Roman', serif;"><span style="font-size: small;">If the ip address is the one you are expecting it from then you should check the ipsec.conf file and the ipsec.secrets file.</span></span></p>
<p lang="en-AU">
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;"><span id="more-265"></span>/etc/ipsec.conf</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">config setup</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">interfaces=%defaultroute</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">klipsdebug=none</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">plutodebug=none</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">plutoload=%search</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">plutostart=%search</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">uniqueids=yes</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">nat_traversal=yes</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">virtual_private=%v4:10.0.0.0/8,%v4:172.16.0.0/12,%v4:192.168.0.0/16,%v4:!192.168.2.0/255.255.255.0,%v4:\</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">!10.11.100.0/255.255.255.0,%v4:!192.168.4.0/255.255.255.0,%v4:!192.168.3.0/255.255.255.0,%v4:!192.168.0.0/255.255.255.0</span></span></p>
<p lang="en-AU">
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">conn %default</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">keyingtries=0</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;">disablearrivalcheck=no</span></span></p>
<p lang="en-AU"><span style="font-family: 'Courier New', monospace;"><span style="font-size: x-small;"><br />
</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=265</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>openVPN</title>
		<link>http://www.tienphatads.com/embedded/?p=262</link>
		<comments>http://www.tienphatads.com/embedded/?p=262#comments</comments>
		<pubDate>Tue, 09 Nov 2010 08:05:46 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Porting]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=262</guid>
		<description><![CDATA[Config openVPN http://linuxconfig.org/VPN_-_Virtual_Private_Network_and_OpenVPN]]></description>
			<content:encoded><![CDATA[<p>Config openVPN</p>
<p><a href="http://linuxconfig.org/VPN_-_Virtual_Private_Network_and_OpenVPN">http://linuxconfig.org/VPN_-_Virtual_Private_Network_and_OpenVPN</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=262</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nbd: howto</title>
		<link>http://www.tienphatads.com/embedded/?p=258</link>
		<comments>http://www.tienphatads.com/embedded/?p=258#comments</comments>
		<pubDate>Fri, 05 Nov 2010 09:44:18 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Guide]]></category>
		<category><![CDATA[Linux Porting]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[nbd]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=258</guid>
		<description><![CDATA[Network block devices are used to access remote storage device that does not physically reside in the local machine. Using Network Block Device, we can access and use the remote storage devices in following three ways on the local machine: SWAP File System RAW NBD presents a remote resource as local resource to the client. [...]]]></description>
			<content:encoded><![CDATA[<p>Network block devices are used to access remote storage device that does not physically reside in the local machine. Using Network Block Device, we can access and use the remote storage devices in following three ways on the local machine:</p>
<ol>
<li>SWAP</li>
<li>File System</li>
<li>RAW</li>
</ol>
<p><span id="more-258"></span>NBD presents a remote resource as local resource to the client. Also, NBD driver makes a remote resource look like a local device in Linux, allowing a cheap and safe real-time mirror to be constructed.<br />
You can also use remote machine storage area as local machine swap area using NBD.</p>
<p>To setup the NBD based file system, we need a nbd-server (on remote machine, where we like to access/create the content) and nbd-client (on local machine, where we like to access the remote storage device locally).</p>
<h2>I. NBD Server Side Configuration Steps</h2>
<h3>1. Install nbd-server</h3>
<p>If you working on Debian flavor, get the nbd-server through apt-get.</p>
<pre># apt-get install nbd-server</pre>
<h3>2. Create a file content</h3>
<p>Create a file using dd as shown below.</p>
<pre># dd if=/dev/zero of=/mnt/dhini bs=1024 count=36000</pre>
<p>Use mke2fs to make the /mnt/dhini as a filesystem.</p>
<pre># mke2fs /mnt/dhini</pre>
<p>When you try to make /mnt/dhini as ext2 file system, you may get a warning message as show below. Press y to continue.</p>
<pre>/mnt/dhini is not a block special device.
Proceed anyway? (y,n) y</pre>
<h3>3. Start the NBD Server Daemon</h3>
<pre>Syntax: nbd-server  port-number   filename/filesystem

# nbd-server 1043 /mnt/dhini</pre>
<p>You can also run the nbd-server on multiple ports as shown below.</p>
<pre># nbd-server 1043 1077 1076 /mnt/dhini</pre>
<p>You can also specify the timeout to make the server to run N idle seconds</p>
<h2>II. NBD Client Side Configuration Steps</h2>
<p>Perform the following steps in the client machine, where you like to access the remote storage device.</p>
<h3>1. Install nbd-client</h3>
<p>If you working on debian flavor, get the nbd-client through apt-get.</p>
<pre># apt-get install nbd-client</pre>
<h3>2. Using nbd-client create a filesystem on client machine</h3>
<pre>Syntax: nbd-client  server-ip  server-port#  filename/filesystem

# nbd-client 192.168.1.11 1043 /mnt/dhini

Starting NBD client process: Connecting...Negotiation: ..size = 36000KB
bs=1024, sz=36000
connected /mnt/dhini
Activating...
fsck 1.39-WIP (31-Dec-2005)
/mnt/dhini: Superblock last write time is in the future.  FIXED.
/mnt/dhini has gone 49710 days without being checked, check forced.
/mnt/dhini: |===============================| 56.0%
/mnt/dhini: |===============================| 100.0%</pre>
<p>Once it gets to 100%, you will get the block device on your local macine on the same path.</p>
<pre>$ls -lh /mnt/dhini
brw-r--r-- 1 root root 43, 0 2009-02-05 17:31 /mnt/dhini</pre>
<p>If you face any issues during the NBD configuration process, you may also configure the nbd-server and nbd-client through dpkg-reconfigure.</p>
<h2>III. Mount the File System on Client-side</h2>
<pre># mkdir /rem_space
# mount /mnt/dhini /rem_space</pre>
<p>Once mounted, you may get the directory with “lost+found”. You can start accessing the files and directories properly from this point.</p>
<h2>IV. Get Client Changes on Server-side</h2>
<p>Mount the nbd filesystem locally</p>
<pre># mount  -o loop /mnt/dhini /client_changes</pre>
<p>If you are not using “-o loop” option, you may get the following error:</p>
<pre>mount: /mnt/dhini is not a block device (maybe try `-o loop'?)</pre>
<p>When you list the /client_changes, You will get all the client created files and directories properly.</p>
<h2>V. Access Remote Storage as Local Swap Memory Area</h2>
<h3>Configuration On Server side:</h3>
<h4>1. Create a file</h4>
<pre># dd if=/dev/zero of=/mnt/dhini bs=1024 count=16000</pre>
<h4>2. Instead of create a file in ext2 filesystem create it as swap file, using mkswap</h4>
<pre># mkswap /mnt/dhini</pre>
<h4>3. Run the server daemon</h4>
<pre># nbd-server 1043 /mnt/dhini</pre>
<h3>Configuration On Client side:</h3>
<h4>1. Get the filesystem as swap area</h4>
<pre># nbd-client 192.168.1.11 1043 -swap  /mnt/dhini</pre>
<h4>2. Cross check using “cat /proc/swaps “. This will list the swap areas</h4>
<pre>$ cat /proc/swaps
Filename    Type       Size      Used    Priority
/dev/hda4   partition  650624     57732  -1
/mnt/dhini  partition  15992    0        -4</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=258</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vpnc HOWTO</title>
		<link>http://www.tienphatads.com/embedded/?p=255</link>
		<comments>http://www.tienphatads.com/embedded/?p=255#comments</comments>
		<pubDate>Fri, 05 Nov 2010 09:36:05 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Guide]]></category>
		<category><![CDATA[Linux Porting]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[vpnc]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=255</guid>
		<description><![CDATA[1.  Introduction If you&#8217;re reading this, then you likely need to connect to your office network from home or during travel. Many companies utilize Cisco 3000 VPN concentrators for their VPN needs, and I am willing to bet that most Linux newbies think that they are forced to use Windows to connect to them. Well, this [...]]]></description>
			<content:encoded><![CDATA[<p>1.  Introduction</p>
<p>If you&#8217;re reading this, then you likely need to connect to your office network from home or during travel. Many companies utilize Cisco 3000 VPN concentrators for their VPN needs, and I am willing to bet that most Linux newbies think that they are forced to use Windows to connect to them. Well, this document informs you that connecting to a Cisco VPN is very possible and will hopefully enable you to setup a working tunnel using your Gentoo workstation or laptop.</p>
<p><span id="more-255"></span></p>
<ul>
<li>A guide to the basic workings of vpnc</li>
<li>A discussion of DNS and routing issues that relate to VPNs</li>
<li>Examples of managing VPN sessions</li>
<li>Useful tips and tricks (hopefully)</li>
</ul>
<p><a name="doc_chap1_sect3"></a></p>
<ul>
<li>An in-depth guide to VPN/encryption technologies</li>
<li>A feature by feature explanation of vpnc</li>
</ul>
<p><a name="doc_chap1_sect4"></a></p>
<p>The assumptions made at this point are:</p>
<ul>
<li>You have Gentoo installed</li>
<li>You have Internet access</li>
<li>You want to connect to a Cisco 3000 VPN concentrator</li>
<li>You know how to configure, build, and install a new kernel</li>
</ul>
<p><a name="doc_chap2"></a>2.  Kernel Configuration</p>
<p>In order for Linux to be able to open a VPN connection Universal TUN/TAP device driver support must be enabled in the kernel. What is it and why do you need it? Below is a relatively straight forward explanation from the kernel configuration dialog:</p>
<p><a name="doc_chap2_pre1"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 2.1: CONFIG_TUN</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>TUN/TAP provides packet reception and transmission for user space
programs. It can be viewed as a simple Point-to-Point or Ethernet
device, which instead of receiving packets from a physical media,
receives them from user space program and instead of sending packets
via physical media writes them to the user space program.

When a program opens /dev/net/tun, driver creates and registers
corresponding net device tunX or tapX. After a program closed above
devices, driver will automatically delete tunXX or tapXX device and
all routes corresponding to it.</pre>
</td>
</tr>
</tbody>
</table>
<p>You can verify yourself if your kernel has TUN/TAP support with the following command:</p>
<p><a name="doc_chap2_pre2"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 2.2: Checking the kernel config</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>#  grep "TUN" /usr/src/linux/.config
CONFIG_INET_TUNNEL=m
# CONFIG_INET6_TUNNEL is not set
# CONFIG_IPV6_TUNNEL is not set
(TUN/TAP enabled as a module)
CONFIG_TUN=m
# CONFIG_8139TOO_TUNE_TWISTER is not set</pre>
</td>
</tr>
</tbody>
</table>
<p>As you can see above, CONFIG_TUN=m is compiled as a module. If it is disabled in your setup, enable it in your kernel of choice, rebuild, install, reboot and return to this document before continuing with the next steps.</p>
<p><a name="doc_chap2_pre3"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 2.3: Configuration location in the kernel configuration dialog</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>Device Drivers  ---&gt;
  Network device support  ---&gt;
    [*] Universal TUN/TAP device driver support</pre>
</td>
</tr>
</tbody>
</table>
<p>If you built TUN/TAP support directly into the kernel, you should see information from dmesg output like the following:</p>
<p><a name="doc_chap2_pre4"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 2.4: Checking dmesg output</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># dmesg | grep TUN
Universal TUN/TAP device driver 1.5 (C)1999-2002 Maxim Krasnyansky</pre>
</td>
</tr>
</tbody>
</table>
<p>If you build TUN/TAP support as a module, you first must load the tun module:</p>
<p><a name="doc_chap2_pre5"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 2.5: Load tun module</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># modprobe tun
# lsmod
Module                  Size  Used by
tun                     7296  0</pre>
</td>
</tr>
</tbody>
</table>
<p>Now that the tun module is loaded, check dmesg output. You should see something like the following:</p>
<p><a name="doc_chap2_pre6"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 2.6: Checking dmesg output</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># dmesg | grep TUN
Universal TUN/TAP device driver 1.5 (C)1999-2002 Maxim Krasnyansky</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap3"></a>3.  Install Needed Software</p>
<p>Now that you have a working kernel setup, you need to install net-misc/vpnc:</p>
<p><a name="doc_chap3_pre1"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 3.1: Installing vpnc</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># emerge -av net-misc/vpnc</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap4"></a>4.  Example Setup</p>
<p>In order to make the following sections more clear, we need an example setup to work from. For the purposes of this exercise, we will assume that you have a home network of several computers. All computers are on the 192.168.0.0 / 255.255.255.0 network. The LAN in question is run by a Gentoo box using an iptables firewall, DHCP, caching DNS, etc &#8230; and it masquerades the LAN behind the public IP address it receives from an ISP. You also have a workstation on the LAN from which you want to be able to VPN into your office with.</p>
<p>Our example workstation configuration looks like the following:</p>
<p><a name="doc_chap4_pre1"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 4.1: Our workstation configuration</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>(Name server configuration)
# cat /etc/resolv.conf
nameserver      192.168.0.1

(Network configuration)
# cat /etc/hosts
127.0.0.1       desktop localhost
192.168.0.1     router
192.168.2.2     mediacenter

(Interface configuration)
# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:11:2F:8D:08:08
          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::211:2fff:fe8d:808/64 Scope:Link
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3657889 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2305893 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2193722103 (2092.0 Mb)  TX bytes:1415104432 (1349.5 Mb)
          Interrupt:185 Memory:fac00000-0

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:35510 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35510 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:16023838 (15.2 Mb)  TX bytes:16023838 (15.2 Mb)

(Routing information)
# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.0.0     *               255.255.255.0   U         0 0          0 eth0
loopback        desktop         255.0.0.0       UG        0 0          0 lo
default         router          0.0.0.0         UG        0 0          0 eth0</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap5"></a>5.  Configuring vpnc</p>
<p>Now that you have vpnc installed and we have an example to work from, let&#8217;s discuss the basics of setting up vpnc. The configuration file for vpnc connection settings can be located in a couple places, depending on how many profiles you want to setup. By default, vpnc looks first for /etc/vpnc/default.conf for its connection settings. If it doesn&#8217;t find that file, then it looks for /etc/vpnc.conf. This setup will only address a single profile example and will use the configuration file location/etc/vpnc.conf. Make sure you do not have a /etc/vpnc/default.conf file.</p>
<p><a name="doc_chap5_pre1"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 5.1: Example /etc/vpnc.conf file</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>IPSec gateway vpngateway.domain.org
IPSec ID group_id
IPSec secret group_password
Xauth username network_signon
Xauth password network_password</pre>
</td>
</tr>
</tbody>
</table>
<p>The configuration file example above should be modified to reflect the appropriate values for your setup. The gateway optionvpngateway.domain.org can be a fully qualified domain name or an IP address. The ID and secret options should be given to you by a network administrator. If you cannot obtain this information but you currently have a working setup on a Windows box which utilizes the official Cisco VPN client, then all you have to do is export your profile. The user name and password options are for your normal network sign-on, such as a Windows NT domain account.</p>
<p>If you are forced to export your profile from a Windows machine, then what you will likely have is a file ending in .pcf. This file will have all the information you need. Below is an example:</p>
<p><a name="doc_chap5_pre2"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 5.2: Example profile.pcf file</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>[main]
Description=
Host=VPNGATEWAY.DOMAIN.ORG
AuthType=1
GroupName=group_id
GroupPwd=
enc_GroupPwd=F3256220AA200A1D532556024F4F314B0388D48B0FBF2DB12
EnableISPConnect=0
ISPConnectType=0
ISPConnect=FOOBAR
ISPCommand=
Username=
SaveUserPassword=0
UserPassword=
enc_UserPassword=
NTDomain=
EnableBackup=0
BackupServer=
EnableMSLogon=1
MSLogonType=0
EnableNat=1
TunnelingMode=0
TcpTunnelingPort=10000
CertStore=0
CertName=
CertPath=
CertSubjectName=
CertSerialHash=00000000000000000000000000000000
SendCertChain=0
VerifyCertDN=
DHGroup=2
ForceKeepAlives=0
PeerTimeout=90
EnableLocalLAN=0
EnableSplitDNS=1
ForceNetLogin=0</pre>
</td>
</tr>
</tbody>
</table>
<p>In the above example, we can see entries for Host, GroupName and enc_GroupPwd. Your Username and UserPasswordmay or may not be exported depending on the setup. To generate a working vpnc configuration out of it, you can usepcf2vpnc, included with vpnc.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#bbffbb"><strong>Note: </strong>You can decrypt the password with the help from the cisco-decrypt program, shipped with the latest vpnc.</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap5_sect2"></a></p>
<p>Now that you have a configuration in place, it&#8217;s time to test your setup. To start vpnc you do the following:</p>
<p><a name="doc_chap5_pre3"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 5.3: Example vpnc usage</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># vpnc
Enter password for username@vpngateway.domain.org:
VPNC started in background (pid: 14788)...</pre>
</td>
</tr>
</tbody>
</table>
<p>As you can see from the above command output, once you type vpnc (as root), you are prompted for your password. After entering your password, which will not be echoed back to you, the vpnc process will automatically become a background process.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#bbffbb"><strong>Note: </strong>If you specified the Xauth password option in your vpnc config file, then you will not be prompted for your password at vpnc startup. Additionally, if vpnc needs some extra options not specified in the configuration file, or if you have forgotten something, don&#8217;t worry, it will ask you for it.</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap5_pre4"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 5.4: Sample interface configuration changes made by vpnc</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>#  ifconfig -a
eth1      Link encap:Ethernet  HWaddr 00:11:2F:8D:08:08
          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::211:2fff:fe8d:808/64 Scope:Link
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2101119 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1577559 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1757862627 (1676.4 Mb)  TX bytes:732200131 (698.2 Mb)
          Interrupt:177 Memory:faa00000-0

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:192.168.160.42  P-t-P:192.168.160.42  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1412  Metric:1
          RX packets:1 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:60 (60.0 b)  TX bytes:616 (616.0 b)</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap5_pre5"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 5.5: Sample routing modifications made by vpnc</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
vpn01.domain.or router          255.255.255.255 UGH    1500 0          0 eth1
192.168.0.0     *               255.255.255.0   U         0 0          0 eth1
loopback        desktop         255.0.0.0       UG        0 0          0 lo
default         *               0.0.0.0         U         0 0          0 tun0</pre>
</td>
</tr>
</tbody>
</table>
<p>As you can see from the above command output(s), vpnc has done the following:</p>
<ul>
<li>Created the tun0 network interface, a virtual interface to handle the traffic across your VPN tunnel</li>
<li>Obtained the IP address for the tun0 device from your VPN provider</li>
<li>Set the default route to your VPN gateway</li>
</ul>
<p>At this point, your workstation is capable of communicating with hosts via the VPN. Because vpnc sets your default route to your VPN gateway, all network traffic will travel across the VPN, even if it destined for the Internet or elsewhere not specifically specified by additional routes. For some, this basic type of connection may be satisfactory, but for most, additional steps need to be taken.</p>
<p>Additional things you might want to have:</p>
<ul>
<li>DNS for the VPN</li>
<li>A routing setup that will only send traffic destined for the VPN down the virtual tunnel. This way, you can browse the Internet while connected to the VPN, without your personal web/p2p etc. traffic going across the tunnel.</li>
<li>A script to manage all this, because vpnc just doesn&#8217;t do enough by default.</li>
</ul>
<p>When you are ready to end the VPN session, execute vpnc-disconnect. An example is shown below.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#bbffbb"><strong>Note: </strong>Don&#8217;t disconnect yet, because we have additional things to test. The example below is just for informational purposes.</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap5_pre6"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 5.6: vpnc-disconnect</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># vpnc-disconnect
Terminating vpnc daemon (pid: 26250)</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap6"></a>6.  Set up DNS</p>
<p>Unfortunately, vpnc doesn&#8217;t handle the setup and management of DNS for your newly established tunnel. The user is left to decide how DNS should be handled. You could just overwrite /etc/resolv.conf when you connect, but that would utilize your VPN DNS for all DNS queries regardless of whether or not the traffic is destined for your VPN tunnel. This is a very functional solution and if you simply need to connect to the tunnel, do your work, and then disconnect, read no further. But, if you want to be able to leave your tunnel connected for lengthy periods of time and don&#8217;t want your work DNS servers handling requests for your personal traffic, read on.</p>
<p>The ideal setup would allow you to separate your DNS queries into two categories: VPN-related and other. Under this setup, all VPN-related DNS queries would be answered by DNS servers located at the other end of your VPN tunnel and all other queries would continue to be answered by local or ISP supplied DNS servers. This is the setup that will be demonstrated here.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#bbffbb"><strong>Note: </strong>We will consider VPN-related DNS queries to be any query belonging to the example.org domain, such as host1.example.org or server1.example.org.</td>
</tr>
</tbody>
</table>
<p>So how do you set things up, so that only requests made to hosts on the example.org domain get sent to VPN supplied DNS servers? Well, you&#8217;re going to need to install a local DNS server, but don&#8217;t worry, it&#8217;s much easier than you think. There are several software packages that can handle the type of setup we desire, but for the purposes of this demonstration, dnsmasqwill be utilized. Let&#8217;s emerge it now:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#bbffbb"><strong>Note: </strong>This DNS server software will not be available to the network, and will only answer requests from localhost, 127.0.0.1.</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap6_pre1"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 6.1: Install dnsmasq</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># emerge dnsmasq</pre>
</td>
</tr>
</tbody>
</table>
<p>Now you need to add an option to your dnsmasq startup options. Edit the following option to suit your needs. Substitute .example.org with the appropriate domain and the IP address with a valid DNS server that belongs to the VPN tunnel.</p>
<p><a name="doc_chap6_pre2"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 6.2: /etc/conf.d/dnsmasq</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>Config file for /etc/init.d/dnsmasq

# See the dnsmasq(8) man page for possible options to put here.
DNSMASQ_OPTS="-S /.example.org/192.168.125.10"</pre>
</td>
</tr>
</tbody>
</table>
<p>Next, make sure that the first entry in /etc/resolv.conf is your local host 127.0.0.1, followed by the location of the backup DNS servers that should handle the DNS traffic in case dnsmasq fails to start, or if it needs to forward a DNS query it doesn&#8217;t currently have in its cache. An example /etc/resolv.conf is shown below.</p>
<p><a name="doc_chap6_pre3"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 6.3: /etc/resolv.conf</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>nameserver 127.0.0.1
nameserver 192.168.0.1</pre>
</td>
</tr>
</tbody>
</table>
<p>Now that you have setup a rule for your VPN tunnel DNS, you need to start dnsmasq.</p>
<p><a name="doc_chap6_pre4"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 6.4: Starting up dnsmasq</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># /etc/init.d/dnsmasq start
# rc-update add dnsmasq default</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap7"></a>7.  Configuring the routing table</p>
<p>The ideal scenario would be if only the traffic destined for VPN tunnel would travel across the link. At this point, you have a VPN tunnel setup and all traffic will travel across the tunnel, unless you specify additional routes. In order to fix this situation you need to know what networks are available to you on your VPN. The easiest way to find out the needed information is to ask a network administrator, but sometimes they are reluctant to answer such questions. If your local network admin won&#8217;t provide the needed information, some trial and error experiments will be required.</p>
<p>When the VPN tunnel was started, vpnc set the default route to the tunnel. So you must set your default route back to normal, so that things work as expected.</p>
<p><a name="doc_chap7_pre1"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 7.1: Resetting your default route</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># route add default gw 192.168.0.1</pre>
</td>
</tr>
</tbody>
</table>
<p>Earlier, when DNS services were being configured for your VPN, you specified a DNS server to handle your example.org domain. You need to add a route for the 192.168.125.0 subnet so that DNS queries will work.</p>
<p><a name="doc_chap7_pre2"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 7.2: Adding a route for dns</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># route add -net 192.168.125.0 netmask 255.255.255.0 dev tun0</pre>
</td>
</tr>
</tbody>
</table>
<p>At this point, you should add any additional routes for known networks (such as for the subnet 192.168.160.0, which includes the IP address received by the TUN/TAP virtual device). If your friendly network administrator gave you the required info, great. Otherwise, you might need to ping hosts you will be connecting to frequently, to give yourself an idea about what your routing table should look like.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#bbffbb"><strong>Note: </strong>Due to your setup, when using VPN network services by name, you must specify the fully qualified domain name, for instance: webserver1.example.org</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap7_pre3"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 7.3: Ping example</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># ping intranet1.example.org
PING intranet1.example.org (172.25.230.29) 56(84) bytes of data.

--- intranet1.example.org ping statistics ---
18 packets transmitted, 0 received, 100% packet loss, time 16997ms</pre>
</td>
</tr>
</tbody>
</table>
<p>As you can see from the above example, the ping probes to intranet1.example.org were unsuccessful. So we need to add a route for that subnet.</p>
<p><a name="doc_chap7_pre4"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 7.4: another route command example</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># route add -net 172.25.230.0 netmask 255.255.255.0 dev tun0</pre>
</td>
</tr>
</tbody>
</table>
<p>A few ping and route commands later, you should be well on your way to a well working routing table.</p>
<p><a name="doc_chap8"></a>8.  Manage the connection</p>
<p><a name="doc_chap8_sect1"></a></p>
<p>Next is an example script to manage the VPN connection. You could execute it (as root) from an xterm to start a connection to your VPN. Then all you have to do is press return to disconnect the VPN. Obviously you will need to modify this for your setup, remembering to add all the additional routes that you may need.</p>
<p><a name="doc_chap8_pre1"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 8.1: Example session management script</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>#!/bin/bash

source /sbin/functions.sh

ebegin "Connecting to the VPN"
vpnc
eend

ebegin "Modifying the routing table"
route add default gw 192.168.0.1
route add -net 172.25.230.0 netmask 255.255.255.0 dev tun0
route add -net 192.168.160.0 netmask 255.255.255.0 dev tun0
route add -net 192.168.125.0 netmask 255.255.255.0 dev tun0
eend

einfo "Press any key to disconnect ..."

read $disconnect

ebegin "Disconnecting from the VPN"
vpnc-disconnect
eend
ebegin "Reconfiguring the default routing table"
route add default gw 192.168.0.1
eend

einfo "VPN should now be disconnected"</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap8_sect2"></a></p>
<p>Version 0.4.0-r1 of vpnc contains an init script (/etc/init.d/vpnc) which can handle multiple configurations. The default script looks for /etc/vpnc/vpnc.conf, but as many configurations as can be imagined are possible. Before and after shutdown and start-up custom-made scripts can be executed that are connected by their name to the corresponding init script (since version 0.5.1-r1). Their names end in -preup.sh, -postup.sh, -predown.sh and -postdown.sh, stored in the/etc/init.d/scripts.d/ directory. The general naming scheme is sketched in the following table.</p>
<table>
<tbody>
<tr>
<td><strong>init script name</strong></td>
<td><strong>needed configuration file</strong></td>
<td><strong>preup script name</strong></td>
</tr>
<tr>
<td>/etc/init.d/vpnc</td>
<td>/etc/vpnc/vpnc.conf</td>
<td>/etc/vpnc/scripts.d/vpnc-preup.sh</td>
</tr>
<tr>
<td>/etc/init.d/vpnc.work</td>
<td>/etc/vpnc/work.conf</td>
<td>/etc/vpnc/scripts.d/work-preup.sh</td>
</tr>
</tbody>
</table>
<p>Add vpnc to default runlevel with the following commands (in this case for the standard configuration). Don&#8217;t forget to add the tun module (if you have built it that way) to the kernels autoload mechanism at startup.</p>
<p><a name="doc_chap8_pre2"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 8.2: Adding vpnc to startup scripts</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># rc-update add vpnc default</pre>
</td>
</tr>
</tbody>
</table>
<p>If you don&#8217;t want to save your password in the configuration file, you can tell the init script to show all output and prompts on standard output by editing /etc/conf.d/vpnc. Set the variable VPNCOUTPUT to yes or no, where its default is to not display screen output.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#bbffbb"><strong>Note: </strong>The init scripts don&#8217;t handle DNS separation, but you can use the custom scripts to achieve that. See <a href="http://www.gentoo.org/doc/en/vpnc-howto.xml#tipsscript">Tips and Tricks</a>.</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap9"></a>9.  Tips and Tricks</p>
<p><a name="doc_chap9_sect1"></a></p>
<p>If you are looking for a Linux application that supports RDP (Remote Desktop Protocol) then give grdesktop a try. It&#8217;s a GUI app written in GTK+ that fits in well with a Gnome desktop, but doesn&#8217;t require it. If you don&#8217;t want the GUI configuration dialogs that grdesktop provides, then just install rdesktop. Ultimately, grdesktop is just a frontend for rdesktop.</p>
<p>If you are a KDE user, you might want to try kvpnc. It a appears to be a very mature VPN management GUI.</p>
<p>If you need to connect to a Windows machine which doesn&#8217;t have a DNS entry, and you know the address of an available WINS server, you can use a tool called nmblookup to query the WINS server for the host name of the machine you want to connect to. Unfortunately, you have to install samba to get it, but if you are going to be working with boxes running Windows you might as well want to install samba, because it includes several other useful tools.</p>
<p><a name="doc_chap9_pre1"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 9.1: Installing samba</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># emerge -av samba</pre>
</td>
</tr>
</tbody>
</table>
<p>When you have samba and its tools installed, test nmblookup by asking the WINS server at IP address 192.168.125.11 about a host named wintelbox1.</p>
<p><a name="doc_chap9_pre2"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 9.2: nmblookup example</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre># nmblookup -U 192.168.125.11 -R 'wintelbox1'
querying wintelbox1 on 192.168.125.11
172.25.230.76 wintelbox1</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="tipsscript"></a><a name="doc_chap9_sect2"></a></p>
<p>The custom-made scripts for the init.d file can be used to setup a user-defined routing for the vpnc connection. The examples below show how to setup the routing table so that only connections to 123.234.x.x are routed over the VPN and all other connections use the default gateway. The example uses work-preup.sh to save the current default gateway before starting vpnc (which resets the default gateway using the VPN connection). Once vpnc has been started, work-postup.shdeletes this new default gateway, restores the old default gateway and sets the route for all connections to 123.234.x.x to use the vpnc connection.</p>
<p><a name="doc_chap9_pre3"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 9.3: /etc/vpnc/scripts.d/work-preup.sh</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>#!/bin/sh
route -n | grep -E '^0.0.0.0 ' | cut -c 17-32 &gt;/var/tmp/defaultgw</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap9_pre4"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 9.4: /etc/vpnc/scripts.d/work-postup.sh</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>#!/bin/sh
route del -net 0.0.0.0 netmask 0.0.0.0 dev tun1
route add default gw $(cat /var/tmp/defaultgw)
route add -net 123.234.0.0 netmask 255.255.0.0 dev tun1</pre>
</td>
</tr>
</tbody>
</table>
<p>The example scripts assume that the vpnc connection uses tun1 as tun device. You can set the device name in the connection&#8217;s configuration file.</p>
<p><a name="doc_chap9_pre5"></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td bgcolor="#7a5ada">Code Listing 9.5: /etc/vpnc/work.conf</td>
</tr>
<tr>
<td dir="ltr" align="left" bgcolor="#eeeeff">
<pre>Interface name tun1
IPSec gateway vpn.mywork.com
Pidfile /var/run/vpnc.work.pid</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="doc_chap10"></a>10.  Useful Links</p>
<ul>
<li><a href="http://www.unix-ag.uni-kl.de/~massar/vpnc/">vpnc homepage</a></li>
<li><a href="http://home.gna.org/kvpnc/en/index.html">kvpnc homepage</a></li>
<li><a href="http://www.nongnu.org/grdesktop/">grdesktop homepage</a></li>
</ul>
<p><a name="doc_chap11"></a>11.  Final Notes</p>
<p>Hopefully by now you have been able to connect to your VPN of choice and are well on your way to remote office work. Feel free to file a bug at <a href="http://bugs.gentoo.org/">bugs.gentoo.org</a> should you find a mistake or wish to make an addition or recommendation regarding this document.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=255</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>wget: recursively download all FTP directories</title>
		<link>http://www.tienphatads.com/embedded/?p=252</link>
		<comments>http://www.tienphatads.com/embedded/?p=252#comments</comments>
		<pubDate>Wed, 27 Oct 2010 09:14:09 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Guide]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=252</guid>
		<description><![CDATA[http://www.cyberciti.biz/faq/wget-recursive-download-command/]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cyberciti.biz/faq/wget-recursive-download-command/">http://www.cyberciti.biz/faq/wget-recursive-download-command/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=252</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mount NFS share in MAC OS X</title>
		<link>http://www.tienphatads.com/embedded/?p=249</link>
		<comments>http://www.tienphatads.com/embedded/?p=249#comments</comments>
		<pubDate>Wed, 27 Oct 2010 09:12:46 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Guide]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=249</guid>
		<description><![CDATA[http://www.cyberciti.biz/faq/apple-mac-osx-nfs-mount-command-tutorial/]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cyberciti.biz/faq/apple-mac-osx-nfs-mount-command-tutorial/">http://www.cyberciti.biz/faq/apple-mac-osx-nfs-mount-command-tutorial/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=249</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup Time / Clock Synchronization with NTP server and ntpdate command</title>
		<link>http://www.tienphatads.com/embedded/?p=245</link>
		<comments>http://www.tienphatads.com/embedded/?p=245#comments</comments>
		<pubDate>Wed, 27 Oct 2010 09:03:21 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Guide]]></category>
		<category><![CDATA[Linux Porting]]></category>
		<category><![CDATA[ntp]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=245</guid>
		<description><![CDATA[Just run ntpdate command as follows to see you can set date and clock via NTP: Set wrong date (Mon Dec 13 4:27 pm): # date 0412131627 Now set correct date with ntp client: # ntpdate -v -b in.pool.ntp.org 13 Dec 16:27:50 ntpdate[997]: ntpdate 4.2.0-a Thu Nov 3 07:34:22 UTC 2005 (1) 25 Jan 12:35:47 [...]]]></description>
			<content:encoded><![CDATA[<p>Just run ntpdate command as follows to see you can set date and clock via NTP:<br />
Set wrong date (Mon Dec 13 4:27 pm):</p>
<pre># date 0412131627</pre>
<p>Now set correct date with ntp client:</p>
<pre># ntpdate -v -b in.pool.ntp.org<span id="more-245"></span></pre>
<p><em>13 Dec 16:27:50 ntpdate[997]: ntpdate 4.2.0-a Thu Nov 3 07:34:22 UTC 2005 (1)<br />
25 Jan 12:35:47 ntpdate[997]: step time server 61.246.176.131 offset 35237275.965726 sec</em></p>
<p>You can verify that correct data is setup:</p>
<pre># date</pre>
<p>Output:</p>
<pre>Wed Jan 25 12:36:21 IST 2006</pre>
<h2>Enable date and time/ clock Synchronization at boot time</h2>
<p>You need to set ntpdate via /etc/rc.local file.</p>
<pre># vi /etc/rc.conf</pre>
<p>Append following line to it:<br />
<code>ntpdate_enable="YES"<br />
ntpdate_hosts="asia.pool.ntp.org"</code><br />
Save and close the file. Make sure you have correct ntpdate_hosts server entry.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=245</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 10.10 and iBus-Unikey</title>
		<link>http://www.tienphatads.com/embedded/?p=242</link>
		<comments>http://www.tienphatads.com/embedded/?p=242#comments</comments>
		<pubDate>Wed, 20 Oct 2010 04:14:39 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Guide]]></category>
		<category><![CDATA[Tieng Viet]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[unikey]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=242</guid>
		<description><![CDATA[1. Install ibus-unikey sudo apt-get update sudo apt-get install ibus-unikey 2. Install languages 2.1 System &#8211; Administrator &#8211; Language Support-&#62; Vietnamese 2.2 in tab Language -&#62; Keyboard Input Method-&#62;iBus 2.3 Restart X ( Ctrl+Atl+ Backspace or log out and login again). you will see iBus icon on Panel. 3. Configure iBus 3.1 Click on iBus-&#62;Preference [...]]]></description>
			<content:encoded><![CDATA[<p>1. Install ibus-unikey</p>
<pre>sudo apt-get update
sudo apt-get install ibus-unikey</pre>
<p><span id="more-242"></span></p>
<p>2. Install languages</p>
<p>2.1 System &#8211; Administrator &#8211; Language Support-&gt; Vietnamese</p>
<p>2.2 in tab Language -&gt; Keyboard Input Method-&gt;iBus</p>
<p>2.3 Restart X ( Ctrl+Atl+ Backspace or log out and login again). you will see iBus icon on Panel.</p>
<p>3. Configure iBus</p>
<p>3.1 Click on iBus-&gt;Preference -&gt; Input Method -&gt; Vietnamese-Unikey -&gt;Add -&gt; OK</p>
<p>3.2 Select and edit area and press Ctrl + Space, you will see the input method change</p>
<p>3.4 Default is Telex for Vietnamese</p>
<p>3.5 If you want change to Vni: iBus-&gt;Preference-&gt; General-&gt;Show language panel -&gt; Always.</p>
<p>and anytime you enable ibus-unikey, you will see at right conner panel to choose.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=242</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>openSSL:ELF file data encoding not  little-endian</title>
		<link>http://www.tienphatads.com/embedded/?p=240</link>
		<comments>http://www.tienphatads.com/embedded/?p=240#comments</comments>
		<pubDate>Sat, 02 Oct 2010 02:18:28 +0000</pubDate>
		<dc:creator>uvan</dc:creator>
				<category><![CDATA[Linux Guide]]></category>
		<category><![CDATA[Linux Porting]]></category>

		<guid isPermaLink="false">http://www.tienphatads.com/embedded/?p=240</guid>
		<description><![CDATA[This problem because ${cross_compile}ld need to load host .so library when running. and at this time, for many reason the LD_LIBRARY_PATH has change, and ${cross_compile}ld can not load *host* dynamic library files. so you need to set LD_LIBRARY_PATH to host to make it work. export LD_LIBRARY_PATH=/lib:/usr/lib Another solution is patched to openSSL itself. &#8212; openssl-0.9.8i/Makefile.shared  [...]]]></description>
			<content:encoded><![CDATA[<p>This problem because ${cross_compile}ld need to load host .so library when running. and at this time, for many reason the LD_LIBRARY_PATH has change, and ${cross_compile}ld can not load *host* dynamic library files. so you need to set LD_LIBRARY_PATH to host to make it work.</p>
<p>export LD_LIBRARY_PATH=/lib:/usr/lib</p>
<p>Another solution is patched to openSSL itself.</p>
<p>&#8212; openssl-0.9.8i/Makefile.shared      2009-12-16 00:27:33.667686278  -0500<br />
+++ openssl-0.9.8i.fixed/Makefile.shared        2009-12-15  23:35:17.035659855 -0500<br />
@@ -94,7 +94,7 @@<br />
LIBPATH=`for x in  $$LIBDEPS; do if echo $$x | grep &#8216;^ *-L&#8217; &gt; /dev/null 2&gt;&amp;1;  then echo $$x | sed -e &#8216;s/^ *-L//&#8217;; fi; done | uniq`; \<br />
LIBPATH=`echo $$LIBPATH | sed -e &#8216;s/ /:/g&#8217;`; \<br />
LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \<br />
-    $${LDCMD}  $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )<br />
+     $${LDCMD} $${LDFLAGS} -Wl,-EB -o $${APPNAME:=$(APPNAME)} $(OBJECTS)  $${LIBDEPS} )</p>
<p>LINK_SO=       \<br />
( $(SET_X);   \</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tienphatads.com/embedded/?feed=rss2&#038;p=240</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

