Configure IPsec on Linux Machine (2024)

Install Libreswan

Configure IPsec on Linux Machine (1)

Before beginning, make sure packet forwarding is enabled on the Linux distribution.

Configure IPsec on Linux Machine (2)

To download the latest source code of Libreswan, visit the Libreswan Downloads page.

  1. Run the following commands as root:

    CODE

    yum -y updateyum -y install libnss3-dev libnspr4-dev pkg-config libpam0g-dev libcap-ng-dev libcap-ng-utils libselinux1-dev libcurl4-nss-dev flex bison gcc makeyum install wget
  2. Install Libreswan:

    CODE

    yum install libreswan
  3. Start the IPsec service and enable the service to be started:

    CODE

    systemctl enable ipsec
  4. Configure the firewall to allow 500 and 4500/UDP ports for the IKE, ESP, and AH protocols by adding the IPsec service:

    CODE

     #firewall-cmd --add-service="ipsec"# firewall-cmd --runtime-to-permanent

Initialize the NSS Database

Configure IPsec on Linux Machine (3)

After a new installation of Libreswan, the NSS database should be initialized as part of the installation process. Before you start a new database, remove the old database.

  1. Use the following commands to remove the old database:

    CODE

    ~]# systemctl stop ipsec

    CODE

    ~]# rm /etc/ipsec.d/*db
  2. Enable IPsec:

    CODE

    systemctl enable ipsec

    Configure IPsec on Linux Machine (4)

    Libreswan requires the firewall to allow the following packets: UDP port 500 and 4500 for the Internet Key Exchange (IKE) protocol. Protocol 50 for Encapsulated Security Payload (ESP) IPsec packets. Protocol 51 for Authenticated Header (AH) IPsec packets (uncommon).

  3. Check IPsec status:

    CODE

    $ipsec setup status

    Configure IPsec on Linux Machine (5)

  4. Initialize the new NSS database, run the following command as root:

    CODE

    ~]# ipsec initnss

    Configure IPsec on Linux Machine (6)

Create Host-to-Host VPN

  1. Go to the/etc/ipsec.d/ directory and create a new my_host-to-host.conf file.
  2. Edit the file, and enter all the details shown below:

    Configure IPsec on Linux Machine (7)

    It is mandatory to maintain the gap of one tab between conn mytunnel and auto=start.

    CODE

    conn mytunnel auto=start keyexchange=ike phase2=esp pfs=no type=tunnel authby=secret leftid=(Domain name/ip of linux machine) left=(ip address of linux machine) right=(ip address of Windows machine) rightid=(Domain name of Windows machine)

    For example, see the screenshot below:

    Configure IPsec on Linux Machine (8)

    SettingValue
    Connection namemytunnel
    leftid10.1.0.127 (Linux machine)
    right

    10.1.22.59 (Windows machine)

    rightidRinkitest.QA.schq.secious.com (FQDN domain name of Windows machine)
  3. Go to the /etc folder, and make the following edits in the ipsec.secrets file:

    CODE

    (ip adddress of linux machine)<space>( ip address of windows machine)<space> : <space>PSK<space>"Shared key which we passed for Windows machine"

    Configure IPsec on Linux Machine (9)

  4. Start the IPsec service:

    CODE

    systemctl start ipsec
  5. Verify the tunnel is up and running:

    CODE

    ipsec auto --add mytunnel

    Configure IPsec on Linux Machine (10)

    Configure IPsec on Linux Machine (11)

    If you receive any error message after running the above command, you have entered the incorrect values in either your host-to-host.conf file or your ipsec.secrets file. You will need to go back and enter the correct values.

  6. Restart the IPsec service:

    CODE

    systemctl restart ipsec
  7. You have completed configuring IPsec between Windows and Linux machines.

  8. You can verify that traffic is coming in properly and is encrypted by using Wireshark:
    Configure IPsec on Linux Machine (12)
Configure IPsec on Linux Machine (2024)
Top Articles
What is food insecurity and why it is a threat? | British Red Cross
Yoga With Adriene | Adriene Mishler , Yoga Teacher, Actress, Texan.
Creepshotorg
Sdn Md 2023-2024
neither of the twins was arrested,传说中的800句记7000词
Login Page
Craigslist Parsippany Nj Rooms For Rent
Craigslist Furniture Bedroom Set
The Pope's Exorcist Showtimes Near Cinemark Hollywood Movies 20
Violent Night Showtimes Near Amc Fashion Valley 18
Roblox Character Added
83600 Block Of 11Th Street East Palmdale Ca
Saw X | Rotten Tomatoes
Panorama Charter Portal
Committees Of Correspondence | Encyclopedia.com
10-Day Weather Forecast for Santa Cruz, CA - The Weather Channel | weather.com
Craigslist Red Wing Mn
Vigoro Mulch Safe For Dogs
Best Mechanics Near You - Brake Masters Auto Repair Shops
Used Safari Condo Alto R1723 For Sale
Puretalkusa.com/Amac
Academy Sports Meridian Ms
Which Sentence is Punctuated Correctly?
Bocca Richboro
Lexus Credit Card Login
Dtm Urban Dictionary
2004 Honda Odyssey Firing Order
Salemhex ticket show3
Rugged Gentleman Barber Shop Martinsburg Wv
Frequently Asked Questions - Hy-Vee PERKS
Kids and Adult Dinosaur Costume
Autopsy, Grave Rating, and Corpse Guide in Graveyard Keeper
Mg Char Grill
What Is Xfinity and How Is It Different from Comcast?
Sitting Human Silhouette Demonologist
Indiana Immediate Care.webpay.md
Craigslist Car For Sale By Owner
Etowah County Sheriff Dept
Kgirls Seattle
Laff Tv Passport
Babbychula
1v1.LOL Game [Unblocked] | Play Online
South Bend Tribune Online
The best bagels in NYC, according to a New Yorker
Acts 16 Nkjv
FedEx Authorized ShipCenter - Edouard Pack And Ship at Cape Coral, FL - 2301 Del Prado Blvd Ste 690 33990
Breaking down the Stafford trade
Craigslist Pet Phoenix
Costner-Maloy Funeral Home Obituaries
Missed Connections Dayton Ohio
Grace Charis Shagmag
Turning Obsidian into My Perfect Writing App – The Sweet Setup
Latest Posts
Article information

Author: Gregorio Kreiger

Last Updated:

Views: 5915

Rating: 4.7 / 5 (77 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Gregorio Kreiger

Birthday: 1994-12-18

Address: 89212 Tracey Ramp, Sunside, MT 08453-0951

Phone: +9014805370218

Job: Customer Designer

Hobby: Mountain biking, Orienteering, Hiking, Sewing, Backpacking, Mushroom hunting, Backpacking

Introduction: My name is Gregorio Kreiger, I am a tender, brainy, enthusiastic, combative, agreeable, gentle, gentle person who loves writing and wants to share my knowledge and understanding with you.