Shell Combat: Script Automation to build an IPSec test environment

Source: Internet
Author: User

1.shell script gets the native IP address:

localhostip= ' lc_all=c ifconfig  'inet addr:'127.0.0.1' |  '{print $}'"$localhostIP"

2. Automate the setup of an IPSec test environment:

#!/bin/Bash#sudo Suecho"Get root! "apt-get Install Strongswan- y//required to press Y during installation, so after adding the-y parameter, you will automatically agree to install the localhostip= ' Lc_all=c ifconfig | Grep'inet Addr:'| Grep-v'127.0.0.1'|Cut-D:-f2 | Awk'{print $}'' echo"$localhostIP"ls/etc/ipsec.*CD/etcpwdifTest-e./Ipsec.confthen Echo"exit ipsec.conf start Write something!"Echo"Conn Ipsec_serverKeyexchange=IKEV1 Type=Tunnel Left=$localhostIP Right=%Any ESP=des-md5-modp768 Ike=des-md5-modp768 Auto=Start Authby=psk">> ipsec.confElseEcho"ipsec.conf No Exit!!!"fiifTest-e./Ipsec.secretsthen Echo"exit ipsec.secrets start Write something!"Echo": PSK ' 123456 '">>ipsec.secretsElseEcho"ipsec.secrets No Exit!!!"Fiecho"-----OK-----------"IPSec Restart

3. Running Result: note To run the script as root

Shell Combat: Script Automation to build an IPSec test environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.