vi /etc/iproute2/rt_tables 200 Service 100 Tech
ip route add 192.168.100.0/24 dev eth0 proto kernel scope link src 192.168.200.8 table Tech
ip route add 202.127.124.0/28 dev eth1 proto kernel scope link src 202.127.124.1 table Tech
ip route add default via 202.127.124.2 dev eth1
ip route add 192.168.200.0/24 dev eth0 proto kernel scope link src 192.168.100.8 table Service
ip route add 219.236.153.0/28 dev eth2 proto kernel scope link src 219.236.153.1 table Service
ip route add default via 219.236.153.2 dev eth2
ip rule list ip rule add from 192.168.100.6 to Tech
ip rule add from 192.168.100.7 to Service
iptables -t nat -A POSTROUTING -s 192.168.100.6 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.100.7 -j MASQUERADE
sysctl -A | grep net.ipv4.ip_forward route print
本文详细介绍了如何在Linux系统中通过`iproute2`命令配置路由表、添加路由条目,并使用iptables进行NAT规则设置,包括不同子网间的路由转发和服务之间的访问控制,确保网络服务的隔离与流量正确转发。
242

被折叠的 条评论
为什么被折叠?



