LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-16-2017, 03:35 PM   #1
mark_weigel
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Rep: Reputation: 0
LibreSwan Configuration File Errors


I am doing a fresh install of LibreSwan and I cannot get it to recognize the autokeying parameters.

I have an include for file vpn.conf which contains the following - very simple:

cat vpn.conf
conn mytunnel
type=tunnel
left=192.168.2.23
right=192.168.2.45
authby=secret
auto=add

When I run ipsec setup start I get the following errors:

ipsec setup start
ERROR: /etc/ipsec.d/vpn.conf: 2: keyword type, invalid value: tunnel
ERROR: /etc/ipsec.d/vpn.conf: 2: keyword type, invalid value: tunnel
ERROR: /etc/ipsec.d/vpn.conf: 2: keyword type, invalid value: tunnel
unknown stack
Redirecting to: systemctl start ipsec.service
Job for ipsec.service failed because the control process exited with error code. See "systemctl status ipsec.service" and "journalctl -xe" for details.

I have edited and recreated the file thinking that there were some non-printable character - but I can't seem to get past this. If I comment out that line it errors onauthby=secret

It's driving me crazy - any help would be appreciated.
 
Old 02-16-2017, 04:17 PM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
From https://libreswan.org/man/ipsec.conf.5.html (my emphasis):

Code:
All subsequent non-empty lines which begin with white space are part of the section.
The file listing you provided shows no white space before the section contents. The page I referred to appears to use a tab as its white space character in the examples it shows.
 
Old 02-16-2017, 04:42 PM   #3
mark_weigel
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
File Contents

Sorry - it's because of the way that it pasted onto the page. There are white spaces for all the lines after conn mytunnel

conn mytunnel
type=tunnel
left=192.168.2.23
right=192.168.2.45
authby=secret
auto=add
 
Old 02-16-2017, 04:46 PM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
No problem. You can manually surround output with CODE tags, or select the output and press # on the LQ Advanced Editor (see "Go Advanced" at the bottom of the text box if this isn't showing), like this:

Code:
This is some output
    in CODE tags.
I'll have another look at that config file.
 
Old 02-16-2017, 04:54 PM   #5
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
One other link that I find on the web indicating a similar error message concluded that the poster had strange characters somewhere in the config file - you probably saw that thread too, hence your looking for non-printable characters.

Just so that we can exhaust that line of enquiry, can you paste the output from:

hexdump -C vpn.conf
 
Old 02-16-2017, 04:55 PM   #6
mark_weigel
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
One more time

Thanks - new to posting on this forum

Code:
conn mytunnel
  type=tunnel
  left=192.168.2.23
  right=192.168.2.45
  authby=secret
  auto=add
 
Old 02-16-2017, 05:01 PM   #7
mark_weigel
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
I did see that one - so I tried different editors. VI, Atom Wordpad etc.

I don't see anything weird

hexdump -C vpn.conf
00000000 63 6f 6e 6e 20 6d 79 74 75 6e 6e 65 6c 0d 0a 20 |conn mytunnel.. |
00000010 20 74 79 70 65 3d 74 75 6e 6e 65 6c 0d 0a 20 20 | type=tunnel.. |
00000020 6c 65 66 74 3d 31 39 32 2e 31 36 38 2e 32 2e 32 |left=192.168.2.2|
00000030 33 0d 0a 20 20 72 69 67 68 74 3d 31 39 32 2e 31 |3.. right=192.1|
00000040 36 38 2e 32 2e 34 35 0d 0a 20 20 61 75 74 68 62 |68.2.45.. authb|
00000050 79 3d 73 65 63 72 65 74 0d 0a 20 20 61 75 74 6f |y=secret.. auto|
00000060 3d 61 64 64 0d 0a |=add..|
00000066
 
Old 02-16-2017, 05:49 PM   #8
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Me too. Those are Windows line endings, not Linux line endings though, but I don't know if that makes a difference. How did you get those?

How good are you at reading C code? The reason I ask is that I'm now looking at the LibreSwan source code to try to narrow down why those errors are generated. I'm not too au fait with C - if you are then you might want a look.
 
Old 02-16-2017, 06:10 PM   #9
mark_weigel
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
C-Code

I'll take a look at the code in the AM. In the mean time I'll save the file in unix format
 
Old 02-16-2017, 06:24 PM   #10
mark_weigel
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
CR/LF

I save the file in unix format in vi and the CR/LF is now just LF

00000000 63 6f 6e 6e 20 6d 79 74 75 6e 6e 65 6c 0a 20 20 |conn mytunnel. |
00000010 74 79 70 65 3d 74 75 6e 6e 65 6c 0a 20 20 6c 65 |type=tunnel. le|
00000020 66 74 3d 31 39 32 2e 31 36 38 2e 32 2e 32 33 0a |ft=192.168.2.23.|
00000030 20 20 72 69 67 68 74 3d 31 39 32 2e 31 36 38 2e | right=192.168.|
00000040 32 2e 34 35 0a 20 20 61 75 74 68 62 79 3d 73 65 |2.45. authby=se|
00000050 63 72 65 74 0a 20 20 61 75 74 6f 3d 61 64 64 0a |cret. auto=add.|

New error message
ipsec setup start
'arning: could not open include filename: '/etc/ipsec.d/*.conf
]annot load config '/etc/ipsec.conf': /etc/ipsec.conf:2: syntax error, unexpected STRING, expecting $end [
'arning: could not open include filename: '/etc/ipsec.d/*.conf
]annot load config '/etc/ipsec.conf': /etc/ipsec.conf:2: syntax error, unexpected STRING, expecting $end [
'arning: could not open include filename: '/etc/ipsec.d/*.conf
]annot load config '/etc/ipsec.conf': /etc/ipsec.conf:2: syntax error, unexpected STRING, expecting $end [
unknown stack
Redirecting to: systemctl start ipsec.service
 
Old 02-16-2017, 06:27 PM   #11
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by mark_weigel View Post
I'll take a look at the code in the AM. In the mean time I'll save the file in unix format
Ok. The ERROR: /etc/ipsec.d/vpn.conf: 2: keyword type, invalid value: tunnel errors get generated in lib/libipsecconf/keywords.c, and the unknown stack error gets generated in programs/_stackmanager.in.

Which version of LibreSwan are you using and which Linux distro (and version)?
 
Old 02-17-2017, 09:30 AM   #12
mark_weigel
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
Fixed

It looks like I got this fixed by replacing the white spaces with tabs.

I also made sure the file was saved in unix format.
 
Old 02-17-2017, 09:45 AM   #13
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by mark_weigel View Post
It looks like I got this fixed by replacing the white spaces with tabs.

I also made sure the file was saved in unix format.
Strange, but excellent news!

If you consider the thread solved, can you mark it so (see "Thread Tools" at the top of the thread).

Cheers.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking the config file…FAILEDThe configuration file contains errors troya Linux - Networking 2 06-13-2013 05:43 AM
dhcpd.conf has Configuration file errors encountered windstory Linux - Networking 1 11-25-2011 11:52 PM
Slackware 13.0 DHCP server - Configuration file errors encountered hejo Linux - Server 2 11-20-2010 03:38 AM
Suse 11.1 Installation Problem- Boot Configuration File Contains Errors. mrukjames Linux - Laptop and Netbook 8 08-02-2009 08:03 AM
Exim configuration file errors padawan05 Linux - Software 1 01-13-2005 11:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration