Last active
May 22, 2019 09:14
-
-
Save TakashiSasaki/990e8be26e1644a4596dfb8616e2df51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id_rsa.pem | |
openconnect.conf | |
password.enc | |
password.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Running OpenConnect by systemd. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: help clean show-password | |
CONFDIR=/usr/local/etc/ | |
BINDIR=/usr/local/bin/ | |
CONFFILE=openconnect.conf | |
SCRIPTFILE=openconnect.sh | |
SERVICEDIR=/etc/systemd/system/ | |
SERVICEFILE=openconnect.service | |
RESOLVCONFDIR=/etc/ | |
RESOLVCONFFILE=resolv.conf | |
IP_FORWARD=/proc/sys/net/ipv4/ip_forward | |
TUNNELDEVICE=tun0 | |
all: openconnect.conf | |
cat $< | |
install: $(SCRIPTFILE) $(CONFFILE) | |
sudo cp $(SCRIPTFILE) $(BINDIR)$(SCRIPTFILE) | |
sudo cp $(CONFFILE) $(CONFDIR)$(CONFFILE) | |
sudo cp $(SERVICEFILE) $(SERVICEDIR)$(SERVICEFILE) | |
sudo systemctl daemon-reload | |
sudo systemctl enable openconnect | |
sleep 1 | |
-sudo systemctl -a | grep openconnect | |
start: | |
if [ ! -e $(RESOLVCONFDIR) ]; then cp $(RESOLVCONFDIR)$(RESOLVCONFFILE) $(RESOLVCONFFILE); fi | |
sudo service openconnect start | |
-sudo systemctl -a | grep openconnect | |
sleep 1 | |
ps aux | grep openconnect | |
cat $(RESOLVCONFDIR)$(RESOLVCONFFILE) | |
stop: | |
sudo service openconnect stop | |
-sudo systemctl -a | grep openconnect | |
ps aux | grep openconnect | |
route -n | |
enable-napt: | |
cat $(IP_FORWARD) | |
sudo sh -c "echo 1 > ip_forward" | |
cat $(IP_FORWARD) | |
sudo iptables -t nat -F | |
sudo iptables -t nat -A POSTROUTING -o $(TUNNELDEVICE) -j MASQUERADE | |
sudo iptables -t nat -L |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SERVER=vpnserver.example.com | |
USER=nobodynobody | |
PASSWORD=secret_secret | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
After=network.target auditd.service | |
Description=openconnect.sh | |
[Service] | |
ExecStart=/usr/local/bin/openconnect.sh | |
KillMode=mixed | |
Restart=always | |
Type=simple | |
[Install] | |
WantedBy=multi-user.target | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
. /usr/local/etc/openconnect.conf | |
echo ${PASSWORD} | /usr/sbin/openconnect -u ${USER} --passwd-on-stdin --no-dtls --reconnect-timeout 30 ${SERVER} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment