LogLevel 指令
说明:
控制错误日志的详细程度
语法:
LogLevel 级别
默认值:
LogLevel warn
上下文:
服务器配置, 虚拟主机
状态:
核心
模块:
core
LogLevel用于调整记于错误日志中的信息的详细程度。(参阅ErrorLog指令)。可以选择下列级别,依照重要性降序排列:
Level
Description
Example
emerg
紧急 - 系统无法使用。
"Child cannot open lock file. Exiting"
alert
必须立即采取措施。
"getpwuid: couldn't determine user name from uid"
crit
致命情况。
"socket: Failed to get a socket, exiting child"
error
错误情况。
"Premature end of script headers"
warn
警告情况。
"child process 1234 did not exit, sending another SIGHUP"
notice
一般重要情况。
"httpd: caught SIGBUS, attempting to dump core in ..."
info
普通信息。
"Server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers)..."
debug
出错级别信息
"Opening config file ..."
当指定了特定级别时,所有级别高于它的信息也会同时报告。比如说,当指定了LogLevel info时,所有 notice和warn级别的信息也会被记录。
建议至少要使用crit级别。
示例如下:LogLevel notice() [#page_#][#page_#]
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A INPUT -p tcp --dport http -j ACCEPT
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -p udp --dport 5000 -j ACCEPT #openvpn默认使用udp 5000端口
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tun+ -j ACCEPT #这两句很重要
iptables -A INPUT -i tap+ -j ACCEPT
iptables -A FORWARD -i tap+ -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -j ACCEPT
iptables -A OUTPUT -m state --state NEW -o eth1 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state NEW -o eth1 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -s \$PRIVATE -o eth1 -j MASQUERADE
office.up脚本配置如下:
#!/bin/bash
route add -net 192.168.0.0 netmask 255.255.255.0 gw 10.1.0.2 #此处是对端的vpn ip地址
openvpn-startup.sh脚本配置如下:
#!/bin/bash
dir=/etc/openvpn
\$dir/firewall.sh
modprobe tun
echo 1 > /proc/sys/net/ipv4/ip_forward
openvpn --config /etc/openvpn/static-office.conf
home主机的4个配置文件
static-home.conf如下
dev tun0
remote 61.131.58.194
ifconfig 10.1.0.2 10.1.0.1
secret /etc/openvpn/static.key
port 5000
comp-lzo
ping 15
ping 15
ping-restart 45
ping-timer-rem
persist-tun
persist-key
verb 3
firewall.sh如下
#!/bin/bash
PRIVATE=192.168.0.0/24
LOOP=127.0.0.1
iptables -P OUTPUT DROP
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -F
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -i eth0 -s \$LOOP -j DROP
iptables -A FORWARD -i eth0 -s \$LOOP -j DROP
iptables -A INPUT -i eth0 -d \$LOOP -j DROP
iptables -A FORWARD -i eth0 -d \$LOOP -j DROP
iptables -A FORWARD -p tcp --sport 137:139 -o eth0 -j DROP
iptables -A FORWARD -p udp --sport 137:139 -o eth0 -j DROP
iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP
iptables -A OUTPUT -p udp --sport 137:139 -o eth0 -j DROP
iptables -A FORWARD -s ! \$PRIVATE -i eth1 -j DROP
iptables -A INPUT -s \$LOOP -j ACCEPT
iptables -A INPUT -d \$LOOP -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A INPUT -p tcp --dport http -j ACCEPT
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -p udp --dport 5000 -j ACCEPT
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tun+ -j ACCEPT
iptables -A INPUT -i tap+ -j ACCEPT
iptables -A FORWARD -i tap+ -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT
iptables -A FORWARD -i eth1 -j ACCEPT
iptables -A OUTPUT -m state --state NEW -o eth0 -j ACCEPT[#page_#]iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state NEW -o eth0 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -s \$PRIVATE -o eth0 -j MASQUERADE
home.up脚本如下:
#!/bin/bash
route add -net 192.168.1.0 netmask 255.255.255.0 gw 10.1.0.1
openvpn-startup.sh脚本如下:
#!/bin/bash
dir=/etc/openvpn
\$dir/firewall.sh
modprobe tun
echo 1 > /proc/sys/net/ipv4/ip_forward
openvpn --config /etc/openvpn/static-home.conf
最后需要注意的是在office和home主机的/etc/modules.conf都要加上一行:
alias char-major-10-200 tun
在office主机上
office#cd /etc/openvpn
office#./openvpn-startup.sh
office#./office.up
在home主机上
home#cd /etc/openvpn
home#./openvpn-startup.sh
home#./home.up
A主机的default gateway设为192.168.1.56
B主机的default gateway设为192.168.0.235
在A主机上ping 192.168.0.45
在home主机上用tcpdump监听。
home#tcpdump -i tun0
应该有echo request和echo reply
不行的话,在home#ping 10.1.0.1看两个vpn网关是否通。
http://openvpn.sourceforge.net 上还有howto,faq,examples可参考。()