当前位置:网站首页>How to troubleshoot the problem that VPN server cannot forward
How to troubleshoot the problem that VPN server cannot forward
2022-07-24 00:56:00 【Sindweller5530】
About how to check vpn The problem that the server cannot forward
- iptables Rule misses for
- vpn The server kernel does not enable the routing and forwarding function
- The reverse route verification failed
First, check whether the client and server are connected
tcpdump -i eth1( adapter name ) port 1197
see vpn Log /var/log/openvpn-vpn01.log
WARNING: Failed running command (--auth-user-pass-verify): could not execute external program
TLS Auth Error: Auth Username/Password verification failed for peer
You can check whether the script cannot execute correctly , If already set script-security 2 了 , Then the probability is that the script itself cannot run ( Report errors )
iptables The rules
First check iptables Whether the rule writes forwarding .( For example, will FORWARD The default policy of the chain is set to DROP) The previous rule building process is as follows :
- Empty iptables
iptables -FOr for nat surfaceiptables -t nat -Fiptables -Xiptables -Z
- For the default filter surface , Write the status module , For received packets , Receive the response package of its association or established connection .( If not set , Then you can only receive packets , Cannot receive response packets )
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
- Write forwarding rules
iptables -A FORWARD -s source -d destination -i tun+ -j ACCEPTMake the source address (vpn Assign virtual ip pool ) To the destination address (155 test machine ) Can forward . The packet input network interface is tun+ It means match all of them tun network card .-s Followed by the source address ,-d Followed by the destination address ,-i It is the network card that enters .
- Set up nat surface ( Optional , I don't know if it's useful , I haven't figured it out yet )
iptables -t nat -A POSTROUTING -s source -o eth0 -j MASQUERADE-o It's from here
- stay vpn Push routes to clients in the configuration file
push "route xx.xxx.xx.xxx 255.255.255.255"This is used here. 32 Push a little bit less
Routing forwarding is not enabled by the kernel
- Temporarily open
echo 1 > /proc/sys/net/ipv4/ip_forward( Write to memory open in memory ) - Permanent open ( Write to the kernel )
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.confsysctl -pload (-p yes –load)sysctlUsed to modify kernel parameters when the kernel is running (/proc/sys).
linux Reverse route verification
When linux Of IP Protocol stack received IP Packet time , Find the route , The package of this machine is forwarded to the upper layer , Non native packets will be forwarded according to the route . To prevent illegal packets from being forwarded ,linux After finding the route, it will call fib_validate_source() To check the legitimacy of the source , Find out the network interface through the source address of the package , Compare whether the original input interface of the package is consistent with the found output interface , If inconsistent, query strict attributes skb->dev Of rp_filter by 1 Just when drop Packet loss .
If there are two network cards in one LAN in , If a package comes from eth0 Enter but the server is from eth1 Discovery gateway , So from eth1 You can't get out , It doesn't work . The reverse route check requires you to go back to where you come from .
Turn off reverse route check ( Replace the network card name in the second and third lines according to your own situation ), rp_filter In Chinese, it means 1, Default on . Change it to 0 Just close the check .
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter
ref
边栏推荐
- 黑马程序员-接口测试-四天学习接口测试-第四天-Postman读取外部数据文件,读取数据文件数据,iHRM项目实战,员工管理模块,添加员工,批量运行测试用例,生成测试报告,
- Create a self signed certificate to digitally sign exe files
- MySQL common commands
- Classic examples of C language - adding two scores
- Graphic pipeline (I) post-processing stage alpha test template test depth test mix
- There are various signs that apple is expected to support AV1
- IDEA 热部署(热加载)
- Tutorial on principles and applications of database system (051) -- MySQL query (XIII): using queries in DML statements
- Tutorial on principles and applications of database system (042) -- MySQL query (4): using wildcards to construct query conditions
- About redis: there is still a risk of data loss after redis sets data persistence
猜你喜欢

Classic example of C language - print the input two digits in reverse order

爬虫requests模块的基本使用

Prometheus+node exporter+grafana monitoring server system resources

Off screen rendering & FBO

Classic example of C language - convert the input two digits into English

postman测试接口在URL配置正确的情况下出现404或者500错误

Hcia-01 initial understanding of the Internet

How to use mitmproxy to get data return in automated testing?

Sparksql design and introduction, 220722,

Idea hot deployment (hot load)
随机推荐
Treatment of particle boundary collision
C language book recommendation
AVX instruction set accelerated matrix multiplication
網絡系統實驗:ping不通的問題解决
The salary of a tester who has worked for 3 years after job hopping is twice that of the original. The secret is
Bean Validation自定义容器验证篇----06
QT入门篇(2.1初入QT的开始第一个程序)
Bean Validation使用篇----05
[STM32] basic knowledge of serial communication
落枕如何快速缓解
Method of C language annotation
Sword *offer04 rebuild binary tree
【LeetCode第 83 场双周赛】
Tutorial on principles and applications of database system (047) -- MySQL query (IX): connection query
SAP 实施项目中涉及到编程方式操作 Excel 的几种场景介绍
Intelligent video monitoring solutions for elderly care institutions, using new technologies to help the intelligent supervision of nursing homes
JS related knowledge
Tutorial on the principle and application of database system (048) -- MySQL query (x): self connection query
How to use mitmproxy to get data return in automated testing?
What impact does the European "gas shortage" have on China?