I have a CentOS system with libreswan behind a router with static IP, and I have been trying to setup an IPSec tunnel with a server at remote location having juniper firewall. The IPSec VPN settings on the remote server are done via firewall. I have already tried almost every possible combination of settings, but every time, same error of 'malformed payload' is being encountered. Following is the usual log displayed on CentOS shell screen:

002 "GeojitOMS" #6: initiating Main Mode
104 "GeojitOMS" #6: STATE_MAIN_I1: initiate
003 "GeojitOMS" #6: ignoring unknown Vendor ID payload [2c9d7e81995b9967d23f571ac641f9348122f1cc1200000014060000]
003 "GeojitOMS" #6: received Vendor ID payload [draft-ietf-ipsec-nat-t-ike-02_n]
003 "GeojitOMS" #6: received Vendor ID payload [Dead Peer Detection]
003 "GeojitOMS" #6: ignoring Vendor ID payload [HeartBeat Notify 386b0100]
002 "GeojitOMS" #6: enabling possible NAT-traversal with method draft-ietf-ipsec-nat-t-ike-02/03
002 "GeojitOMS" #6: transition from state STATE_MAIN_I1 to state STATE_MAIN_I2
106 "GeojitOMS" #6: STATE_MAIN_I2: sent MI2, expecting MR2
003 "GeojitOMS" #6: NAT-Traversal: Result using draft-ietf-ipsec-nat-t-ike-02/03 sender port 500: I am behind NAT+peer behind NAT
002 "GeojitOMS" #6: transition from state STATE_MAIN_I2 to state STATE_MAIN_I3
108 "GeojitOMS" #6: STATE_MAIN_I3: sent MI3, expecting MR3
003 "GeojitOMS" #6: next payload type of ISAKMP Hash Payload has an unknown value: 210 (0xd2)
003 "GeojitOMS" #6: malformed payload in packet
010 "GeojitOMS" #6: STATE_MAIN_I3: retransmission; will wait 500ms for response
010 "GeojitOMS" #6: STATE_MAIN_I3: retransmission; will wait 1000ms for response
010 "GeojitOMS" #6: STATE_MAIN_I3: retransmission; will wait 2000ms for response
010 "GeojitOMS" #6: STATE_MAIN_I3: retransmission; will wait 4000ms for response
003 "GeojitOMS" #6: discarding duplicate packet; already STATE_MAIN_I3

Having tried every combination of settings on libreswan, I am wondering if it has to do with the version on CentOS itself being incompatible with juniper. This is the version of libreswan and kernel:

[root@localhost xyz]# rpm -qa libreswan
[root@localhost xyz]# uname -r

Port 500 and 4500 of UDP are open on CentOS iptables. Also all the upstream and downstream traffic on beetel router for the ports is permitted. Here is my final connection setting, which is still not working out:

My Local Subnet :

Remote Subnet:

The VPN is suppose to connect the local machine with two boxes on remote subnet, namely and, which I think is configured via subnet, unless there is a way in libreswan to mention such two specific servers in same connection. The /etc/ipsec.d/connection.conf:

conn Connection
    leftid= //Some pre-defined id for local machine
    left= //LAN IP of local machine
    #leftnexthop=xxx.yyy.zzz.www // Public static IP on router
    leftsubnet= //local subnet
    rightid= //Some pre-defined id for remote server
    right=www.zzz.yyy.xxx //Public IP of the remote server 
    rightsubnet= //Remote subnet
    #rightnexthop= //Remote server IP in remote LAN? not sure

Secrets file /etc/ipsec.secrets: PSK "sharedkey"

Different combinations of variables in 'conn' are tried along with enabling disabling 'nat_traversal'. But no matter what combination is used, I still get the same error. Is there anything missing in these settings or is there a compatibility issue between juniper and libreswan or the particular version of libreswan?


I found the libreswan documentation helpful here concerning interop with Juniper.

I feel your pain. VPN's are notoriously difficult to get just right. The seemingly smallest thing can render the connection unstable and/or useless. As such, I can't determine exactly which setting you posted above is wrong or missing so I'll comment on a few lines that may be causing trouble.

phase2=esp phase2alg=3des-sha1 #pfs=no

I had no success at all trying to specify these even when they were correct -- the connection never succeeded. When I let these values be auto-negotiated it magically worked.


Compression should not be enabled because it's a security vulnerability.

For reference, I've successfully achieved a libreswan<-->Juniper tunnel with the following (obfuscated) config. In this config the folling is true:

  1. left==local(libreswan) and right==remote(juniper).
  2. OS is CentOS 7.2
  3. libreswan package is libreswan-3.15-5.el7_1.x86_64
  4. The local libreswan is behind NAT. Juniper NAT status is unknown.
  5. The only Juniper side information I was given:
    • A pre-shared key
    • Phase 1 == "pre-gp2-aes256-sha-24h"
    • Phase 2 == "g2-esp-aes128-sha"
  6. nat_traversal=yes in /etc/ipsec.conf

Config file:

conn MyConnection



| improve this answer | |
  • We ordered a hardware firewall from sonicwall already and it worked with no issues. Though I guess this is one setting which I may not have tried, i.e. removing the phase 1 and phase 2 specs. Thanks. – packet May 10 '16 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.