訓練家的佈弱格-Patch1.2

The BLOG of trainer



編輯日期:2020-11-09 09:59

類型:電腦應用
作者:羽山
文章時間:2020-11-09 09:59:25
瀏覽人數:2892人
標題: fedora 架 softether VPN 給 IOS 使用
網址:http://3wa.tw/blog/blog.php?id=1881
內容:
 

 

1、下載 softether vpn : 

cd /opt

wget https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/releases/download/v4.29-9680-rtm/softether-vpnserver-v4.29-9680-rtm-2019.02.28-linux-x64-64bit.tar.gz

 

2、解壓縮

unzip softether-vpnserver-v4.29-9680-rtm-2019.02.28-linux-x64-64bit.tar.gz

 

3、編譯

cd vpnserver

make

 

4、將 vpnserver 移到 /usr/local

cd /opt

mv vpnserver /usr/local

 

5、更改權限

cd /usr/local/vpnserver

chmod 600 *

chmod 700 vpnserver vpncmd

 

6、建議更改預設的遠端連接埠

vim /usr/local/vpnserver/vpn_server.config

找到 uint Port 443

改成 uint Port 4443

 

7、增加防火牆規則

echo "1" > /proc/sys/net/ipv4/ip_forward

echo "1" > /proc/sys/net/ipv4/ip_dynaddr

#4443 建議用完可以關掉

iptables -A INPUT -p tcp --dport 4443 -j ACCEPT

iptables -A INPUT -p tcp --dport 1723 -j ACCEPT

iptables -A INPUT -p udp --dport 4500 -j ACCEPT

iptables -A INPUT -p udp --dport 53 -j ACCEPT

iptables -A INPUT -p udp --dport 500 -j ACCEPT

iptables -A INPUT -p tcp --dport 1701 -j ACCEPT

iptables -A INPUT -p udp --dport 1701 -m state --state new -j ACCEPT

iptables -A INPUT -m policy --pol ipsec --dir in -p udp --dport 1701 -j ACCEPT

#試了很久找不到動態 udp 要開哪一個,暫時全開 udp ...

iptables -A INPUT -p udp -j ACCEPT

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -t nat -A POSTROUTING -s 192.168.7.0/24 -o ppp0 -j MASQUERADE

 

8、撰寫vpnserver啟動腳本

vim /etc/init.d/vpnserver

# 內容如下:

 

#!/bin/sh

### BEGIN INIT INFO

# Provides:          vpnserver

# Required-Start:    $remote_fs $syslog

# Required-Stop:     $remote_fs $syslog

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: Start daemon at boot time

# Description:       Enable Softether by daemon.

### END INIT INFO

DAEMON=/usr/local/vpnserver/vpnserver

LOCK=/var/lock/subsys/vpnserver

TAP_ADDR=192.168.7.1

 

test -x $DAEMON || exit 0

case "$1" in

start)

$DAEMON start

touch $LOCK

sleep 1

/sbin/ifconfig tap_soft $TAP_ADDR

;;

stop)

$DAEMON stop

rm $LOCK

;;

restart)

$DAEMON stop

sleep 3

$DAEMON start

sleep 1

/sbin/ifconfig tap_soft $TAP_ADDR

;;

*)

echo "Usage: $0 {start|stop|restart}"

exit 1

esac

exit 0

 

9、調整腳本權限,啟動 vpnserver

chmod 700 /etc/init.d/vpnserver

/etc/init.d/vpnserver start

 

10、使用 vpncmd 建立管理者密碼

/usr/local/vpnserver/vpncmd

參考:https://www.itread01.com/content/1549828627.html

1、Management of VPN Server or VPN Bridge

Enter

Enter

VPN Server> ServerPasswordSet

Password: *********

Confirm input: ***********

The command completed successfully.

 

11、下載 dnsmasq

yum install -y dnsmasq

 

12、調整 dnsmasq

vim /etc/dnsmasq.conf

最後面加入以下內容

interface=tap_soft

dhcp-range=tap_soft,192.168.7.50,192.168.7.90,12h

dhcp-option=tap_soft,3,192.168.7.1

port=0

dhcp-option=option:dns-server,208.67.222.222,8.8.8.8,8.8.4.4,168.95.192.1,168.95.1.1

#補充,208.67.222.222 是 opendns,如果沒有特殊理由,建議不要使用

 

13、啟動dnsmasq.conf

systemctl enable dnsmasq

systemctl start dnsmasq

 

14、windows 下載遠端管理工具,要注意版本,不是越新越好,新的可能連不上:

https://www.softether-download.com/files/softether/v4.29-9680-rtm-2019.02.28-tree/Windows/SoftEther_VPN_Server_and_VPN_Bridge/softether-vpnserver_vpnbridge-v4.29-9680-rtm-2019.02.28-windows-x86_x64-intel.exe

 

15、windows 安裝 softether 啟動

(一)、創建虛擬 Hub,取名 VPN

(二)、本地網橋設置,虛擬HUB選剛才的VPN,網絡適配器使用「新 tag 設備名稱」,填入 soft 創建後關閉本地網橋設置

(三)、ipsec / l2tp 設置,三個都勾,默認虛擬 HUB,選 VPN,IPsec 預共享密錀取個 8 碼,如 ilove3wa

(四)、管理 HUB,選 VPN,管理用戶,新建用名,建議都用密碼驗證

 

16、嘗試用 ios 連看看 vpn

使用 l2tp

描述 3wa

伺服器 3wa.tw

帳號 剛才建的帳號

密碼 剛才建的帳號密碼

密錀 剛才填的 ilove3wa

完成,回上頁,vpn 打開連線看看,有成功的話,上面連線會多一個 vpn 的框框

 

17、當一切完成可以正常使用後,建議 4443 port 可以關掉,或是只允許信任的來源

 iptables -D INPUT -p tcp --dport 4443 -j ACCEPT

之後需要再遠端連入管理,再用以下指令打開

 iptables -A INPUT -p tcp --dport 4443 -j ACCEPT

首頁  上十頁  上一頁  1 下一頁    最末頁 (總共有...1頁)

第 1 頁

有話要說  看留言 【0】
其他分類
當月訓練
(2020-11-30)
【NSR 150】NSR150 常見齒比

(2020-11-25)
【酷龍 150】酷龍齒比

(2020-11-11)
【KTM 390】KTM DUKE 390 碼表 Service Reset 重置方法

(2020-11-09)
【電腦應用】fedora 架 pptpd VPN 給 windows、android 使用

(2020-11-09)
【電腦應用】fedora 架 softether VPN 給 IOS 使用

(2020-11-09)
【遊戲 / 生活】保養電蚊拍電池

(2020-11-07)
【KTM 390】KTM DUKE 390 廢側柱感應器 Side Stand Down

最新訓練
(2024-03-09)
【HONDA CBR1000RR】CBR1000RR 原廠管

(2024-02-24)
【NSR 150】NSR150 整理後卡鉗

(2024-02-14)
【機車綜合相關】買了牧田的打氣機與心得

(2024-02-10)
【NSR 150】NSR150 整流器接頭重作

(2024-02-09)
【機車綜合相關】鋰電、鋰鐵電池、電源充電器

(2024-01-07)
【NSR 150】NSR150 貨架耳朵斷裂維修

(2024-01-06)
【KTM 390】KTM Duke390 維修發電問題 電盤內仁

(2023-12-29)
【NSR 150】NSR150 改可調拉桿

(2023-11-20)
【遊戲 / 生活】防盜洗手罐

(2023-11-17)
【KTM 390】KTM Duke390 製作鋰鐵電池