我尝试启用ip转发(在enp0s3和tun0接口之间)并在/etc/sysctl.conf中写入net.ipv4.ip_forward = 1.重启后我有
$cat /proc/sys/net/ipv4/ip_forward
1
但转发仍然无法正常工作.我尝试在/etc/sysctl.conf中添加net.ipv4.conf.default.forwarding = 1.现在重启后我有了
$cat /proc/sys/net/ipv4/ip_forward
1
$cat /proc/sys/net/ipv4/conf/default/forwarding
1
$cat /proc/sys/net/ipv4/conf/all/forwarding
1
$cat /proc/sys/net/ipv4/conf/enp0s3/forwarding
0
$cat /proc/sys/net/ipv4/conf/tun0/forwarding
0
我无法在sysctl.conf中启用/ proc / sys / net / ipv4 / conf / enp0s3 / forwarding和/ proc / sys / net / ipv4 / conf / tun0 / forwarding,因为这些文件在这样的早期启动时不存在:
systemd-sysctl[85]: Couldn't write '1' to 'net/ipv4/conf/enp0s3/forwarding',ignoring: No such file or directory
systemd-sysctl[85]: Couldn't write '1' to 'net/ipv4/conf/tun0/forwarding',ignoring: No such file or directory)
,更多关于tun0是动态接口(可以随时添加和删除).
如果我手动启用enp0s3和tun0的转发,则转发按预期工作.
那么,如何正确启用接口转发?
PS:内核4.1.15和systemd 226的Gentoo
PPS:如果我的记忆在一段时间之前为我服务,net.ipv4.ip_forward = 1就足够了.