简体   繁体   English

如何保存IP规则和IP路由配置

[英]how to save ip rule and ip route configuration

The issus is: I configured the following policy routing: 问题是:我配置了以下策略路由:

ip route add 192.168.1.0/24 via 10.0.2.15 dev eth0 table 10 IP路由通过10.0.2.15 dev eth0 table 10添加192.168.1.0/24

ip route add default via 10.0.2.15 dev eth0 table 10 ip route通过10.0.2.15 dev eth0表10添加默认值

ip rule add from 10.0.2.15 table 10 从10.0.2.15表10添加ip规则

these configurations are temporary, once network restart or reboot,the policy route I configured would lost, Is there any way you can solve this problem? 这些配置是临时的,一旦网络重启或重启,我配置的策略路由就会丢失,有什么办法可以解决这个问题?

Create a file if does not exist 创建文件(如果不存在)

/etc/sysconfig/network-scripts/route-eth0 在/ etc / sysconfig / network中的脚本/路由的eth0

Add the following contents 添加以下内容

192.168.1.0/24 via 10.0.2.15 dev eth0 192.168.1.0/24通过10.0.2.15 dev eth0

default via 10.0.2.15 dev eth0 默认通过10.0.2.15 dev eth0

default route can be added in /etc/sysconfig/network-scripts/ifcfg-eth0 可以在/ etc / sysconfig / network-scripts / ifcfg-eth0中添加默认路由

GATEWAY=10.0.2.15 GATEWAY = 10.0.2.15

Third rule is not clear to me 第三条规则我不清楚

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM