目录
一.环境准备:
1.打开内核转发功能,编辑/etc/sysctl.conf添加以下内容:
net.ipv4.ip_forward=1
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0
[root@achao ~]# vi /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward=1
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0
2.重新加载sysctl.conf
[root@achao ~]# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
3.删除防火墙规则
[root@achao ~]# iptables -F
[root@achao ~]# iptables -X
[root@achao ~]# iptables -Z
[root@achao ~]# /usr/sbin/iptables-save
# Generated by iptables-save v1.4.21 on Sun Feb 26 22:04:57 2023