ip route

Last login: Fri Oct 27 16:46:14 2017 from 192.168.1.168
[galen@sh45 ~]$ ls
anaconda2                        jianshu_spider.py  spider_school
ip route del default
Anaconda2-4.0.0-Linux-x86_64.sh  spider_POI
ip route del default
[galen@sh45 ~]$ ip r
172.16.2.0/24 dev eth1  proto kernel  scope link  src 172.16.2.45
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.45
169.254.0.0/16 dev eth0  scope link  metric 1002
169.254.0.0/16 dev eth1  scope link  metric 1003
default via 172.16.2.44 dev eth1
[galen@sh45 ~]$ ip route del default
RTNETLINK answers: Operation not permitted
[galen@sh45 ~]$ sudo su -
[sudo] password for galen:
[root@sh45 ~]# cd
[root@sh45 ~]# pwd
/root
[root@sh45 ~]# ip route del default
[root@sh45 ~]# ip r
172.16.2.0/24 dev eth1  proto kernel  scope link  src 172.16.2.45
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.45
169.254.0.0/16 dev eth0  scope link  metric 1002
169.254.0.0/16 dev eth1  scope link  metric 1003
[root@sh45 ~]# ip route add default via 192.168.1.44
[root@sh45 ~]# curl ip.cn
当前 IP:123.160.198.122 来自:河南省三门峡市 电信
[root@sh45 ~]# vi route_normal.sh
[root@sh45 ~]# vi route_pptp.sh
[root@sh45 ~]# ll
total 68
drwxr-xr-x  17 root root  4096 Aug 21 15:30 anaconda2
-rw-------.  1 root root  1299 Aug 18 03:25 anaconda-ks.cfg
drwxr-xr-x   2 root root  4096 Aug 21 14:52 info
-rw-r--r--.  1 root root 28529 Aug 18 03:25 install.log
-rw-r--r--.  1 root root  7572 Aug 18 03:24 install.log.syslog
drwxr-xr-x   3 root root  4096 Aug 21 14:52 lib
-rw-r--r--   1 root root    58 Oct 31 17:04 route_normal.sh
-rw-r--r--   1 root root    59 Oct 31 17:05 route_pptp.sh
drwxr-xr-x   2 root root  4096 Aug 18 13:39 soft
[root@sh45 ~]# chmod +x route*
[root@sh45 ~]# ll
total 68
drwxr-xr-x  17 root root  4096 Aug 21 15:30 anaconda2
-rw-------.  1 root root  1299 Aug 18 03:25 anaconda-ks.cfg
drwxr-xr-x   2 root root  4096 Aug 21 14:52 info
-rw-r--r--.  1 root root 28529 Aug 18 03:25 install.log
-rw-r--r--.  1 root root  7572 Aug 18 03:24 install.log.syslog
drwxr-xr-x   3 root root  4096 Aug 21 14:52 lib
-rwxr-xr-x   1 root root    58 Oct 31 17:04 route_normal.sh
-rwxr-xr-x   1 root root    59 Oct 31 17:05 route_pptp.sh
drwxr-xr-x   2 root root  4096 Aug 18 13:39 soft
[root@sh45 ~]# ./route_normal.sh
[root@sh45 ~]# ip r
172.16.2.0/24 dev eth1  proto kernel  scope link  src 172.16.2.45
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.45
169.254.0.0/16 dev eth0  scope link  metric 1002
169.254.0.0/16 dev eth1  scope link  metric 1003
default via 192.168.1.1 dev eth0
[root@sh45 ~]# curl ip.cn
当前 IP:101.81.127.20 来自:上海市 电信
[root@sh45 ~]# ./route_pptp.sh
[root@sh45 ~]# ip r
172.16.2.0/24 dev eth1  proto kernel  scope link  src 172.16.2.45
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.45
169.254.0.0/16 dev eth0  scope link  metric 1002
169.254.0.0/16 dev eth1  scope link  metric 1003
default via 192.168.1.44 dev eth0
[root@sh45 ~]# curl ip.cn
当前 IP:115.202.52.157 来自:浙江省台州市 电信
[root@sh45 ~]# ls
anaconda2        info         install.log.syslog  route_normal.sh  soft
anaconda-ks.cfg  install.log  lib                 route_pptp.sh
[root@sh45 ~]#

你可能感兴趣的:(ip route)