---
title: "Centos6配置静态路由"
id: "215"
type: "post"
slug: "centos6%e9%85%8d%e7%bd%ae%e9%9d%99%e6%80%81%e8%b7%af%e7%94%b1"
published_at: "2019-07-16T10:01:35+00:00"
modified_at: "2019-07-16T13:35:05+00:00"
url: "https://www.hitsword.org/2019/215.html"
markdown_url: "https://www.hitsword.org/2019/215.md"
excerpt: "方法1：写在开机脚本/etc/rc.local 方法2：在route和rule配置文件配置 /etc/sysc […]"
taxonomy_category:
  - "网关"
taxonomy_post_tag:
  - "Centos"
  - "路由"
---

# Centos6配置静态路由

方法1：写在开机脚本/etc/rc.local

```
route add -net 10.8.0.0/8 gw 192.168.1.2
```

方法2：在route和rule配置文件配置  
 /etc/sysconfig/network-scripts/route-{interferface}【对应ip route add】  
 /etc/sysconfig/network-scripts/rule-{interferface}【对应ip rule add】  
 （{interferface}为网卡接口，如eth0）

```
10.0.0.0/8 via 192.168.1.2 dev eth1
```

方法3：/etc/sysconfig/static-routes配置

```
any net any gw 192.168.1.1
any net 10.0.0.0/8 gw 192.168.1.2
```
