centos7配置策略路由
时间: 2023-10-16 09:07:08 浏览: 137
Centos 7 策略路由配置
配置CentOS 7的策略路由的步骤如下:
1. 打开路由配置文件:`vi /etc/iproute2/rt_tables`
2. 在文件末尾添加以下内容:
```
101 innerRoute
102 globalRoute
```
3. 添加路由配置脚本(确保脚本可用):
```
ip route flush table globalRoute
ip rule add dev eth1 table globalRoute
if ! ip rule show | grep x.x.x.x ; then
ip rule add from x.x.x.x table globalRoute
fi
ip route add default via y.y.y.y dev eth1 table globalRoute
ip route flush table innerRoute
ip rule add dev eth2 table innerRoute
if ! ip rule show | grep 172.16.x.x ; then
ip rule add from 172.16.x.x table innerRoute
fi
ip route add default via 172.16.y.y dev eth2 table innerRoute
```
4. 赋予脚本可执行权限并开机启动:
```
chmod +x /opt/script/autostart.sh
echo "/opt/script/autostart.sh" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
```
阅读全文