config setup
nat_traversal=yes
virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v4:!10.152.2.0/24
#contains the networks that are allowed as subnet= for the remote client. In other words, the address ranges that may live behind a NAT router through which a client connects.oe=off
protostack=netkey
conn L2TP-PSK-NAT
rightsubnet=vhost:%priv
also=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
authby=secret
pfs=no
auto=add
keyingtries=3
rekey=no
# Apple iOS doesn't send delete notify so we need dead peer detection# to detect vanishing clientsdpddelay=30
dpdtimeout=120
dpdaction=clear
# Set ikelifetime and keylife to same defaults windows hasikelifetime=8h
keylife=1h
type=transport
# Replace IP address with your local IP (private, behind NAT IP is okay as well)left=x.x.x.x
# For updated Windows 2000/XP clients,# to support old clients as well, use leftprotoport=17/%anyleftprotoport=17/1701
right=%any
rightprotoport=17/%any
#force all to be nat'ed. because of iOSforceencaps=yes
for each in /proc/sys/net/ipv4/conf/*
doecho 0 > $each/accept_redirects
echo 0 > $each/send_redirects
done
验证ipsec服务
1
sudo ipsec verify
不能出现任何错误
123456789101112
Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path [OK]Linux Openswan U2.6.28/K2.6.32-32-generic-pae (netkey)Checking for IPsec support in kernel [OK]NETKEY detected, testing for disabled ICMP send_redirects [OK]NETKEY detected, testing for disabled ICMP accept_redirects [OK]Checking that pluto is running [OK]Pluto listening for IKE on udp 500 [OK]Pluto listening for NAT-T on udp 4500 [OK]Checking for'ip'command[OK]Checking for'iptables'command[OK]Opportunistic Encryption Support [DISABLED]
var optionalString: String? = "Hello"
optionalString == nil
var optionalName: String? = "John Appleseed"
//var optionalName: String? = nil
var greeting = "Hello!"
if let name = optionalName {
greeting = "Hello, \(name)"
} else {
greeting = "Hello, world"
}
可选值为nil条件的结果是false,用let声明的name的作用域
仅在if-else结构中
switch可以使用任何种类的比较数据,而不只是整型数值和相等的比较
1234567891011
let vegetable = "red pepper"
switch vegetable {
case "celery":
let vegetableComment = "Add some raisins and make ants on a log."
case "cucumber", "watercress":
let vegetableComment = "That would make a good tea sandwich"
case let x where x.hasSuffix("pepper"):
let vegetableComment = "Is it a spicy \(x)?"
default:
let vegetableComment = "Everything tastes good in soup"
}
let interestingNumbers = [
"Prime": [2, 3, 5, 7, 11, 13],
"Fibonacci": [1, 1, 2, 3, 5, 8],
"Square": [1, 4, 9, 16, 25],
]
var largest = 0;
var largestKind = "";
for (kind, numbers) in interestingNumbers {
for number in numbers {
if number > largest {
largest = number
largestKind = kind
}
}
}
largest // 25
largestKind // Square
var n = 2
while n < 100 {
n = n * 2
}
n // 128
var m = 2
do {
m = m * 2
} while m < 100
m // 128
在循环中使用range..或是初始化,条件,增量的形式来获得索引
123456789101112
var firstForLoop = 0
for i in 0..3 {
firstForLoop += i
}
firstForLoop // 3
var secondForLoop = 0
for var i = 0; i < 3; ++i {
secondForLoop += 1
}
secondForLoop // 3