Skip to main content

CentOS配置静态路由

·165 words·1 min
Rory
Author
Rory
Step by step the ladder is ascended

查看路由表
#

[root@xuxing ~]# ip route show
default via 10.75.49.1 dev ens32 proto static metric 100
10.75.49.0/24 dev ens32 proto kernel scope link src 10.75.49.238 metric 100
[root@xuxing ~]# ip route show | column -t   <<< 格式化显示
default        via  10.75.49.1  dev    ens32   proto  static  metric  100
10.75.49.0/24  dev  ens32       proto  kernel  scope  link    src     10.75.49.238  metric  100
[root@xuxing ~]#
[root@xuxing ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:10:f8:30 brd ff:ff:ff:ff:ff:ff
    inet 10.75.49.238/24 brd 10.75.49.255 scope global ens32
       valid_lft forever preferred_lft forever
    inet6 fe80::b5ca:2b34:2fbe:4a03/64 scope link
       valid_lft forever preferred_lft forever

添加路由条目
#

[root@xuxing ~]# ip route add  10.50.0.0/16 via 10.75.49.1 dev ens32
[root@xuxing ~]# ip route add  10.52.0.0/16 via 10.75.49.1 dev ens32

删除路由条目
#

[root@xuxing ~]# ip route del 10.50.0.0/16
[root@xuxing ~]# ip route del 10.52.0.0/16