{"id":53,"date":"2010-02-04T22:12:38","date_gmt":"2010-02-05T04:12:38","guid":{"rendered":"http:\/\/www.linuxpoweruser.com\/?p=53"},"modified":"2010-02-04T22:12:38","modified_gmt":"2010-02-05T04:12:38","slug":"client-ipsec-vpns-with-linux-and-juniper-netscreen","status":"publish","type":"post","link":"https:\/\/www.linuxpoweruser.com\/?p=53","title":{"rendered":"Client IPSEC VPNs with Linux and Juniper Netscreen"},"content":{"rendered":"<p>Today, as promised I am going to show everyone how to set up a client IPSEC VPN to a Juniper Netscreen FW\/VPN appliance from a Linux machine.\u00a0 Juniper is a market leader in the Firewall and VPN space, and provides appliances from the Small office Home Office footprint all the way up to the largest enterprise data center gateways.\u00a0 The small office version, currently an SSG 5, is based on Juniper&#8217;s ScreenOS.\u00a0 This tutorial only covers ScreenOS configuration.\u00a0 Juniper is now marketing a new platform called the SRX series. These units run JUNOS, which is Junipers Router OS outfitted with VPN and Firewall functionality pulled from ScreenOS.<\/p>\n<p>The Linux system examples I show should work on Ubuntu (and Gentoo, provided your kernel has support for IPSEC configured).<\/p>\n<p>So why VPN?\u00a0 As I have mentioned in previous posts a VPN is a secure method for using a public network for private communications.\u00a0 Most VPNs fall in to type types:\u00a0 IPSEC and SSL.\u00a0 We will be covering IPSEC VPNs in this posting.\u00a0 I typically use a VPN for access to my employer&#8217;s network while on the road so I can be productive while traveling.\u00a0 With the right technology, you can gain access to your home network the same way.<\/p>\n<p>I have a small home network that is protected by a Juniper Netscreen SSG5.\u00a0 This SSG 5 is configured to allow one or more &#8220;client&#8221; vpns to connect to it.\u00a0 Essentially a client VPN is a single PC talking to a LAN via a VPN server or gateway, as opposed to a site to site VPN, which generally connects two networks or LANs together over the internet.<\/p>\n<p>Here is a little background on IPSEC.<\/p>\n<p>IPSEC VPNs generally consist of two phases.\u00a0\u00a0 Phase 1 is an identification phase, where two IPSEC gateways identify each other.\u00a0 If the identification is successful (the two gateways trust each other) then Phase 2 which is the &#8216;tunnel&#8217; phase, can occur.\u00a0 During this phase, the two gateways negotiate the IP subnet traffic that will be allowed to traverse the tunnel and how to encrypt that traffic.\u00a0 Generally this traffic is protected by using 3DES or AES encryption, which dynamic key rotation.\u00a0 IPSEC, if set up properly is very hard to compromise.<\/p>\n<p>Phase 1 typically uses UDP port 500 to perform IKE\/ISAKMP negotiations.\u00a0 Phase 2, in our case, will use IPSEC ESP (Encapsulated Security Payload) which is a transport layer protocol (like TCP and UDP, runs at layer 4 of of the OSI model). If a NAT firewall is detected in between the two gateways, then ESP can be encapsulated in UDP port 4500 or UDP port 500 depending on the implementation used.\u00a0 This encapsulation is called IPSEC NAT traversal, or NAT-T.<\/p>\n<p>We will start with the following example network layout:<\/p>\n<p><a href=\"http:\/\/www.linuxpoweruser.com\/wp-content\/uploads\/2010\/02\/VPN_Example.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-54\" title=\"VPN Example\" src=\"http:\/\/www.linuxpoweruser.com\/wp-content\/uploads\/2010\/02\/VPN_Example.jpg\" alt=\"Diagram of Example VPN Network\" width=\"764\" height=\"349\" \/><\/a>First we will start with the Netscreen configuration, which is best performed from the netscreen command line.\u00a0 Keep in mind that this will work on several Netscreen models sold over the last few years.\u00a0 This includes the Netscreen 5XT, and 5GT.\u00a0 These units can be found on Ebay for less than $100, and are highly recommended for use as a home or small office firewall.<\/p>\n<p>Note:\u00a0 It is best to have a static IP for the VPN gateway side of the connection.\u00a0 Dynamic will work, however it will become difficult to track the ip as the ISP reassigns addressing to the Juniper via DHCP or other means.\u00a0 Newer Juniper Netscreens can support dynamic dns registration with DDNS providers such as dyndns.org, which would make tracking the ip easier.<\/p>\n<p>So, lets get started.\u00a0 From an ssh or telnet session, login to your netscreen.\u00a0 The first thing we need to do is define VPN users and a group &#8211; here is an example of creating a user &#8220;rwalters&#8221;.\u00a0 This user id is used for IKE negotiation.<\/p>\n<p>Phase 1: (IKE gateway negotiation)<\/p>\n<p>User definition:<br \/>\n<code><br \/>\nset user \"rwalters\" uid 1<br \/>\nset user \"rwalters\" ike-id u-fqdn \"rettw@rtwnetwork.com\" share-limit 1<br \/>\nset user \"rwalters\" type ike<br \/>\nset user \"rwalters\" \"enable\"<br \/>\n<\/code><br \/>\nAfter creating a user, we should add that user to a group.\u00a0 While not required, if you want more than one client VPN to be active at one time, you should add your user to a group, as the group will be used in the IKE gateway definition, and any of the users in the group will be allowed to authenticate in Phase 1.<\/p>\n<p>Here we create a group called dialupusers:<br \/>\n<code><br \/>\nset user-group \"dialupusers\" id 1<br \/>\nset user-group \"dialupusers\" user \"rwalters\"<br \/>\n<\/code><br \/>\nNext we will define the IKE Phase 1 gateway definition.\u00a0 In most cases, we use pre-shared key authentication, which is basically a password.\u00a0 Other forms of credentials can be used as well such as RADIUS or X-AUTH but those are beyond the scope of this tutorial.\u00a0 Here is an example of the ScreenOS command for IKE gateway definition:<br \/>\n<code><br \/>\nset ike gateway \"Publicdialupvpn\" dialup \"dialupusers\" Aggr outgoing-interface  \"ethernet0\/0\" preshare \"&lt;password&gt;\" proposal \"pre-g2-3des-sha\"<br \/>\nset ike gateway \"Publicdialupvpn\" nat-traversal udp-checksum<br \/>\nset ike gateway \"Publicdialupvpn\" nat-traversal keepalive-frequency 5<br \/>\n<\/code><br \/>\nThe first command creates an IKE gateway called &#8220;Publicdialupvpn&#8221; and associates the &#8220;dialupusers&#8221; group with it.\u00a0 It also defines the outgoing interface, ethernet0\/0 and the preshared key or password.\u00a0 You should use a complex password in place of the &lt;password&gt; shown in the command.\u00a0\u00a0\u00a0 The Aggr means aggressive mode, which is used when the IP address of one of the gateways is dynamic &#8211; this case the laptop will almost always have a dynamic IP address.\u00a0 The remaining commands set nat-traversal capabilities.\u00a0 Without NAT-T, Phase 2 will not come up if a NAT-Router or firewall is present in the middle of the network.\u00a0 The last piece is the encryption used for IKE traffic &#8211; in this case 3DES, with SHA-1 hashing algorithm.<\/p>\n<p>Next, we will define the Phase 2 tunnel.\u00a0 An example is below:<br \/>\n<code><br \/>\nset vpn \"Publicdialupvpn\" gateway \"Publicdialupvpn\" no-replay tunnel idletime 0  proposal \"g2-esp-3des-sha\"<br \/>\n<\/code><br \/>\nThis command is pretty simple.\u00a0 It defines a VPN (or tunnel) called Publicdialupvpn, using the IKE gateway definition of the same name. It also turns on no-replay, which prevents replaying of traffic (a common method of hacking VPNs) and sets the transport to ESP, and encryption to 3DES, with SHA-1 hashing.<\/p>\n<p>The last piece of Netscreen configuration is the Firewall policy to allow the encrypted traffic to the internal network.\u00a0 This policy is actually used as part of phase 2 as well, since phase 2 requires the exchange and agreement on the ip addresses that will be allowed to traverse the tunnel (known as a policy based VPN in Juniper terminology).<\/p>\n<p>In this example we will create an address object for the local LAN:<br \/>\n<code><br \/>\nset address \"Trust\" \"Local LAN\" 192.168.0.0 255.255.255.0<br \/>\n<\/code><br \/>\nThen we will create a policy to allow it to be tunnelled to from the outside.\u00a0 Note that Dial-Up VPN is a default address book entry that ships with ScreenOS.\u00a0 Note that you can limit the ports\/protocols allowed through the tunnel by changing the &#8220;ANY&#8221; to a specific service, such as http, for instance.<br \/>\n<code><br \/>\nset policy id 8 from \"Untrust\" to \"Trust\"  \"Dial-Up VPN\" \"Local LAN\" \"ANY\" tunnel  vpn \"Publicdialupvpn\" id 0x3 log<br \/>\nset policy id 8<br \/>\nset log session-init<br \/>\nexit<br \/>\n<\/code><br \/>\nSo, that should take care of the Netscreen side of the equation.\u00a0 Next we will tackle the Linux side which is the fun part.\u00a0 The beauty of Linux IPSEC is that its one of those built in features that you would have to pay for if using one of those operating systems made in Redmond, WA.<\/p>\n<p>Linux IPSEC has a few requirements.\u00a0 If using Ubuntu, all the kernel requirements are already fulfilled.\u00a0 If you&#8217;re using Gentoo or a custom kernel, make sure the following is set in your kernel config:<\/p>\n<p>Under networking:<br \/>\n<code><br \/>\nCONFIG_INET_AH=m<br \/>\nCONFIG_INET_ESP=m<br \/>\nCONFIG_INET_IPCOMP=m<br \/>\nCONFIG_INET_XFRM_TUNNEL=m<br \/>\nCONFIG_INET_TUNNEL=m<br \/>\nCONFIG_INET_XFRM_MODE_TRANSPORT=m<br \/>\nCONFIG_INET_XFRM_MODE_TUNNEL=m<br \/>\nCONFIG_INET_XFRM_MODE_BEET=m<br \/>\n<\/code><br \/>\nUnder Cypto\/Block:<br \/>\n<code><br \/>\nCONFIG_CRYPTO_MD5=y<br \/>\nCONFIG_CRYPTO_SHA1=m<br \/>\n<\/code><br \/>\nUnder Crypto\/Ciphers:<br \/>\n<code><br \/>\nCONFIG_CRYPTO_AES=m<br \/>\nCONFIG_CRYPTO_AES_X86_64=m<br \/>\nCONFIG_CRYPTO_DES=m<br \/>\n<\/code><br \/>\nLinux IPSEC is handed by the kernel in conjunction with two different packages:\u00a0 ipsec-tools, and racoon.\u00a0 Both of these must be installed and configured for our VPN to work properly.\u00a0 On Ubuntu you can install these with:<br \/>\n<code><br \/>\napt-get install ipsec-tools<br \/>\n<\/code><br \/>\n<code><br \/>\napt-get install racoon<br \/>\n<\/code><br \/>\nOn gentoo, just a simple:<br \/>\n<code><br \/>\nemerge ipsec-tools<br \/>\n<\/code><br \/>\nShould install the necessary software.<\/p>\n<p>Three files files need to be customized for Linux IPSEC VPNs to work with a Juniper Netscreen.\u00a0 The first file, ipsec-tools.conf, usually resides in \/etc, and the second, psk.txt in \/etc\/racoon. The third file, is racoon.conf, which is also in the \/etc\/racoon directory.<\/p>\n<p>The ipsec-tools.conf file handled Phase 2 security association, and the racoon.conf\/psk.txt file provide IKE (Phase 1) and dynamic re-keying of encryption between two VPN endpoints.\u00a0 Here is an example of an ipsec-tools.conf file that would work for our sample VPN diagram and Juniper configuration above.<br \/>\n<code><br \/>\n#!\/usr\/sbin\/setkey -f<br \/>\n<\/code><br \/>\n<code><br \/>\nflush;<br \/>\nspdflush;<br \/>\n<\/code><br \/>\n<code><br \/>\n#outbound<br \/>\nspdadd 99.99.99.99 192.168.0.0\/24 any<br \/>\n-P out ipsec esp\/tunnel\/99.99.99.99-77.77.77.77\/require;<br \/>\n<\/code><br \/>\n<code><br \/>\n#inbound<br \/>\nspdadd 192.168.0.0\/24 99.99.99.99 any<br \/>\n-P in ipsec esp\/tunnel\/77.77.77.77-99.99.99.99\/require;<br \/>\n<\/code><br \/>\nThe information in this file is pretty straight forward.\u00a0 Essentially its a tunnelling policy.\u00a0 It basically states that all traffic to 192.168.0.0\/24, which is our remote LAN behind the Juniper from 99.99.99.99 (the Internet IP of our laptop) be tunnelled through the esp tunnel between 77.77.77.77 (the internet IP of our Juniper) and 99.99.99.99 (our laptop) and vice versa.\u00a0 Note that is file must be updated with the existing IP address on the laptop or remote PC every time a VPN is started. For instance if your laptop gets an ip address of 101.100.111.1 from the ISP your using to connect to the internet, all of the 99.99.99.99 ip addresses in the ipsec-tools.conf file will have to be changed to 101.100.111.1.<\/p>\n<p>The other two files \/etc\/racoon\/psk.txt, and \/etc\/racoon\/racoon.conf are relatively static. \u00a0 The first file, psk.txt, is essentially a list of IP addresses of remote VPN gateways and the pre-shared key to use for a password when doing IKE with that gateway.<\/p>\n<p>The password in this file should match the password used in the netscreen Phase 1 IKE configuration shown above.\u00a0 Here is a sample of that file:<br \/>\n<code><br \/>\n# IPv4\/v6 addresses<br \/>\n77.77.77.77\u00a0\u00a0\u00a0 &lt;your pre-shared key password&gt;<br \/>\n10.160.94.3\u00a0\u00a0 \u00a0mekmitasdigoat<br \/>\n172.16.1.133\u00a0\u00a0 \u00a00x12345678<br \/>\n194.100.55.1\u00a0\u00a0 \u00a0whatcertificatereally<br \/>\n3ffe:501:410:ffff:200:86ff:fe05:80fa\u00a0\u00a0 \u00a0mekmitasdigoat<br \/>\n3ffe:501:410:ffff:210:4bff:fea2:8baa\u00a0\u00a0 \u00a0mekmitasdigoat<br \/>\n# USER_FQDN<br \/>\nfoo@kame.net\u00a0\u00a0 \u00a0mekmitasdigoat<br \/>\n# FQDN<br \/>\nfoo.kame.net\u00a0\u00a0 \u00a0hoge<br \/>\n<\/code><br \/>\nThe last file, racoon.conf controls Phase 1 IKE negotiation, Phase 2 VPN SA setup and VPN re-key.\u00a0 This file rarely changes for a particular vpn definition.<\/p>\n<p>Here is a sample racoon.conf:<br \/>\n<code><br \/>\npath pre_shared_key \"\/etc\/racoon\/psk.txt\";<br \/>\n<\/code><br \/>\n<code><br \/>\n# Remote host<br \/>\nremote 77.77.77.77<br \/>\n{<br \/>\nexchange_mode aggressive;<br \/>\n<\/code><br \/>\n<code><br \/>\n# Change this to your local ID<br \/>\nmy_identifier user_fqdn \"rettw@rtwnetwork.com\";<br \/>\nlifetime time 28800 sec;<br \/>\nproposal {<br \/>\nencryption_algorithm 3des;<br \/>\nhash_algorithm sha1;<br \/>\nauthentication_method pre_shared_key;<br \/>\ndh_group modp1024;<br \/>\n}<br \/>\n}<br \/>\n<\/code><br \/>\n<code><br \/>\n# A sample sainfo section<br \/>\n# Create one for each subnet you want to access, etc.<br \/>\n#sainfo address 172.20.0.3 any address 192.168.0.0\/24 any<br \/>\nsainfo anonymous<br \/>\n{<br \/>\npfs_group modp1024;<br \/>\nlifetime time 3600 sec;<br \/>\nencryption_algorithm 3des;<br \/>\nauthentication_algorithm hmac_sha1;<br \/>\ncompression_algorithm deflate;<br \/>\n}<br \/>\n<\/code><br \/>\nGenerally there are two sections to racoon.conf.\u00a0 The first section controls IKE parameters, and Phase 1 negotiations.\u00a0 The second section controls Phase 2 negotiations.\u00a0 There are a couple of things I would like to point out about.\u00a0 First, notice the local id or user fqdn.\u00a0 This should be the same as one of the users created on the Juniper side.\u00a0\u00a0 The second item is the lifetime and encryption types.\u00a0 The first lifetime value in the IKE\/Phase 1 section dictates the length of time the two gateways will trust each other without re-identification.\u00a0 The Phase 2 section has its own lifetime parameter as well.\u00a0 This controls the re-key time on the tunnel, in this case every 3600 seconds or one hour, the tunnel encryption keys will be renegotiated.<\/p>\n<p>Note also the &#8220;aggressive mode&#8221; statement &#8211; this should match the Phase 1 definition on the Juniper as well.<\/p>\n<p>So, after the files have been configured correctly, you need to start the VPN.\u00a0 The first step is to run the ipsec-tools.conf file, so it should be executable.\u00a0 The last step is to start racoon.\u00a0 Here are the example commands.<br \/>\n<code><br \/>\n\/etc\/ipsec-tools.conf<br \/>\n<\/code><br \/>\n<code><br \/>\n\/etc\/init.d\/racoon start<br \/>\n<\/code><br \/>\nAfter the racoon daemon is started, try to ping something on the remote LAN &#8211; for example, 192.168.0.2.\u00a0 The ping will start the IPSEC negotiations.\u00a0 Watching your \/var\/log\/daemon.log or \/var\/log\/messages will show you what is happening.<\/p>\n<p>So &#8211; what if it doesn&#8217;t work?\u00a0 Double check your configuration.\u00a0 Juniper ScreenOS event log (command: get event) is very helpful in determing what is happening.\u00a0 The linux \/var\/log\/daemon.log and \/var\/log\/messages will also be helpful.<\/p>\n<p>Ok &#8211; so this seems like a lot of work, modifying files and starting services &#8211; I agree its not quite optimal, at least on the Linux side.\u00a0 So, I wrote a couple of scripts &#8211; one to determine your PC\/Laptop&#8217;s IP address, create the ipsec-tools.conf file, run it, and then run racoon.\u00a0 As a bonus, it also replaces your resolv.conf with another resolve.conf &#8211; in case there is a dns server for your remote network you would like to use to be able to resolve machine names on your protected LAN.\u00a0 The second script clears the ipsec-tools.conf policies, and stops racoon, and replaces the resolv.conf with the original one.<\/p>\n<p>With the scripts below, starting a VPN to your office or home lan is as simple as connecting to the internet, and running a the script.\u00a0 Afterwards, the to undo the changes, you run another script.\u00a0 This way, there are only one time changes needed to \/etc\/racoon\/psk.txt and \/etc\/racoon\/racoon.conf<\/p>\n<p>Here is the script for starting the vpn:<br \/>\n<code><br \/>\n#!\/usr\/bin\/python<br \/>\n<\/code><br \/>\n<code><br \/>\n#script to find outgoing internet interface (by opening a socket to google.com)<br \/>\n#and build a vpn policy file for ... and turn up the VPN tunnel<br \/>\n<\/code><br \/>\n<code><br \/>\nimport socket<br \/>\nimport os<br \/>\n<\/code><br \/>\n<code><br \/>\ndef OutputSpace2file():<br \/>\nfilehandle.write ( ' ' )<br \/>\ns = socket.socket()<br \/>\n# Connect to google.com to find out going IP address<br \/>\ns.connect(('google.com',80))<br \/>\nipport = s.getsockname()<br \/>\nipaddr = ipport[0]<br \/>\ndestip = '77.77.77.77'<br \/>\ndestsubnet = '192.168.0.0\/24'<br \/>\nprint \"Setting VPN tunnel up from Source:\",ipaddr,\"To IP address:\",destip<br \/>\nprint \"For destination subnet\",destsubnet<br \/>\nprint \"Generating ipsec-tools.conf file in \/etc\"<br \/>\nfilehandle = open ('\/etc\/ipsec-tools.conf','w')<br \/>\nfilehandle.write ( '#!\/usr\/sbin\/setkey -fn' )<br \/>\nfilehandle.write ( 'n')<br \/>\nfilehandle.write ( 'flush;n' )<br \/>\nfilehandle.write ( 'spdflush;nn' )<br \/>\nfilehandle.write ( '#outboundn' )<br \/>\nfilehandle.write ( 'spdadd ' )<br \/>\nfilehandle.write ( ipaddr )<br \/>\nOutputSpace2file()<br \/>\nfilehandle.write ( destsubnet )<br \/>\nOutputSpace2file()<br \/>\nfilehandle.write ( 'anyn' )<br \/>\nfilehandle.write ( '\u00a0\u00a0\u00a0 -P out ipsec esp\/tunnel\/' )<br \/>\nfilehandle.write ( ipaddr )<br \/>\nfilehandle.write ( '-' )<br \/>\nfilehandle.write ( destip )<br \/>\nfilehandle.write ( '\/require;nn' )<br \/>\nfilehandle.write ( '#inboundn' )<br \/>\nfilehandle.write ( 'spdadd ' )<br \/>\nfilehandle.write ( destsubnet )<br \/>\nOutputSpace2file()<br \/>\nfilehandle.write ( ipaddr )<br \/>\nOutputSpace2file()<br \/>\nfilehandle.write ( 'anyn' )<br \/>\nfilehandle.write ( '\u00a0\u00a0\u00a0 -P in ipsec esp\/tunnel\/' )<br \/>\nfilehandle.write ( destip )<br \/>\nfilehandle.write ( '-' )<br \/>\nfilehandle.write ( ipaddr )<br \/>\nfilehandle.write ( '\/require;n' )<br \/>\nfilehandle.close()<br \/>\n# set permissions on new policy file<br \/>\nrc = os.system( 'chmod a+x \/etc\/ipsec-tools.conf' )<br \/>\n# Check return code for permissions command<br \/>\nif rc != 0:<br \/>\nprint \"Error Setting permissions!\"<br \/>\nos._exit(1)<br \/>\n# Continue by runninng ipsec-tools.conf script<br \/>\nprint \"Running ipsec-tools.conf script.\"<br \/>\nrc = os.system( '\/etc\/ipsec-tools.conf' )<br \/>\n# Check return code for command<br \/>\nif rc != 0:<br \/>\nprint \"Error running ipsec-tools.conf script!\"<br \/>\nos._exit(1)<br \/>\n# Continue by reloading racoon<br \/>\nprint \"Reloading racoon IKE server.\"<br \/>\nrc = os.system( '\/etc\/init.d\/racoon reload' )<br \/>\n# Check return code for command<br \/>\nif rc != 0:<br \/>\nprint \"Error running \/etc\/init.d\/racoon reload!\"<br \/>\nos._exit(1)<br \/>\n<\/code><br \/>\n<code><br \/>\n# backup existing \/etc\/resolv.conf and build new one for remote lan<br \/>\n<\/code><br \/>\n<code><br \/>\nprint \"Backing up \/etc\/resolv.conf and setting resolv.conf to rtwsecurenet.com DNS\"<br \/>\nrc = os.system( 'mv \/etc\/resolv.conf \/etc\/resolv.conf.bak' )<br \/>\nif rc != 0:<br \/>\nprint \"Error backing up \/etc\/resolv.conf\"<br \/>\nos._exit(1)<br \/>\nfilehandle = open ('\/etc\/resolv.conf','w')<br \/>\nfilehandle.write ( '# File created by LPU vpn-start.py scriptn' )<br \/>\nfilehandle.write ( 'search homelan.comn' )<br \/>\nfilehandle.write ( 'nameserver 192.168.0.17n' )<br \/>\nfilehandle.close()<br \/>\n<\/code><\/p>\n<p>And for stopping the VPN:<br \/>\n<code><br \/>\n#!\/usr\/bin\/python<br \/>\n<\/code><br \/>\n<code><br \/>\n#script to stop vpn started by vpn-start.py and restore resolv.conf<br \/>\n<\/code><br \/>\n<code><br \/>\nimport socket<br \/>\nimport os<br \/>\n<\/code><br \/>\n<code><br \/>\n# stop vpn by flushing ipsec policies<br \/>\nprint \"Flushing IPSEC policies\"<br \/>\nrc = os.system( '\/usr\/sbin\/setkey -FP' )<br \/>\n# Check return code for permissions command<br \/>\nif rc != 0:<br \/>\nprint \"Error flushing policies!\"<br \/>\nos._exit(1)<br \/>\n# Continue by runninng ipsec-tools.conf script<br \/>\nprint \"Restoring \/etc\/resolv.conf to previous state\"<br \/>\nrc = os.system( 'cp \/etc\/resolv.conf.bak \/etc\/resolv.conf' )<br \/>\n# Check return code for command<br \/>\nif rc != 0:<br \/>\nprint \"Error restoring \/etc\/resolv.conf - name resolution will not work properly!\"<br \/>\nos._exit(1)<br \/>\n# Continue by reloading racoon<br \/>\nprint \"Stopping racoon IKE server.\"<br \/>\nrc = os.system( '\/etc\/init.d\/racoon stop' )<br \/>\n# Check return code for command<br \/>\nif rc != 0:<br \/>\nprint \"Error running \/etc\/init.d\/racoon stop!\"<br \/>\nos._exit(1)<br \/>\n<\/code><br \/>\nSo, there you have it.\u00a0 I use this type of vpn set up regularly to access my home network when on the road.\u00a0 So far, I haven&#8217;t found anything that keeps it from working, unless the hotel ISP network assigns my laptop a 192.168.0 IP.\u00a0 This of course would render the vpn useless, since you can&#8217;t tunnel from 192.168.0.0 to 192.168.0.0 as it will confuse the ip stack and routing processes.\u00a0 Feel free to use these scripts in your own environment.<\/p>\n<p>While some purists may say, why not use linux for both ends of the tunnel. While this can be done, its hard to beat the price and usability of Juniper&#8217;s Netscreen line. It is an excellent firewall, and used units can be found on Ebay for less than $100 now &#8211; look for Netscreen 5GT or 5XT.<\/p>\n<p>I have tried to cover some key concepts of IPSEC VPNs, but this is by no means a complete overview, but more of a implementation for a specific application.  There are several IPSEC references available on the internet via <a href=\"http:\/\/en.wikipedia.org\/wiki\/IPsec\">this<\/a> Wikipedia article.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, as promised I am going to show everyone how to set up a client IPSEC VPN to a Juniper Netscreen FW\/VPN appliance from a Linux machine.\u00a0 Juniper is a market leader in the Firewall and VPN space, and provides appliances from the Small office Home Office footprint all the way up to the largest [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[20,38,39,43,48,72],"_links":{"self":[{"href":"https:\/\/www.linuxpoweruser.com\/index.php?rest_route=\/wp\/v2\/posts\/53"}],"collection":[{"href":"https:\/\/www.linuxpoweruser.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxpoweruser.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxpoweruser.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxpoweruser.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=53"}],"version-history":[{"count":0,"href":"https:\/\/www.linuxpoweruser.com\/index.php?rest_route=\/wp\/v2\/posts\/53\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.linuxpoweruser.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxpoweruser.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxpoweruser.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}