ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20191216]route妙用.txt

[20191216]route妙用.txt

原创 Linux操作系统 作者:lfree 时间:2019-12-17 11:15:52 0 删除 编辑

[20191216]route妙用.txt

--//使用route add -host ip_address reject,可以拒接某台机器的连接.自己做一个测试:

1.显示路由表:
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.XXX 0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0

2.改写路由表:
# route add -host 192.168.100.40 reject

3.测试:

# ping 192.168.100.40
connect: Network is unreachable

--//从192.168.100.40操作看看:
# ping 192.168.100.78 -c 2
PING 192.168.100.78 (192.168.100.78) 56(84) bytes of data.
From 192.168.100.40 icmp_seq=0 Destination Host Unreachable
From 192.168.100.40 icmp_seq=1 Destination Host Unreachable

--- 192.168.100.78 ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1001ms
, pipe 2

4.显示路由表:
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.XXX 0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.100.40  -               255.255.255.255 !H    0      -        0 -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--//这样就无法ping连接192.168.100.40.

Flags  Possible flags include
U      route is up
H      target is a host
G      use gateway
R      reinstate route for dynamic routing
D      dynamically installed by daemon or redirect
M      modified from routing daemon or redirect
A      installed by addrconf
C      cache entry
!      reject route

5.测试还原:

# route del -host 192.168.100.40 reject
# ping 192.168.100.40 -c 2
PING 192.168.100.40 (192.168.100.40) 56(84) bytes of data.
64 bytes from 192.168.100.40: icmp_seq=1 ttl=64 time=0.109 ms
64 bytes from 192.168.100.40: icmp_seq=2 ttl=64 time=0.137 ms

--- 192.168.100.40 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.109/0.123/0.137/0.014 ms

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2668955/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969289