为路由器配置默认网关除了上面的两种方法外,还有另外的一种就是ip default-network ,ip default-gateway 只有在路由功能关闭的情况下才能用,ip route 0.0.0.0 0.0.0.0 在路由模式下运行,但是不能被动态路由所学习传递。如果使用ip default-network 配置默认网关,被ip default-network 定义的网段就是就是默认网关了,所有未知的数据都发往这个网段,ip default-network 所定义的默认网关可以被动态路由协议所传递,比如:rip 、eigrp、igrp而ospf和is-is则不会去传递的。Ip default-gateway 定义的是有类网络(classful),classless不会成有默认网关的。
在eigrp下配置默认网关,必须是eigrp中所通过的网络,或者是重分布进eigrp网络中的,而rip不需要这样的,不过在rip在下配置默认网络的时候,与rip的版本和ios的版本有关。
2、实验过程
r3(config)#ip route 192.168.1.0 255.255.255.0 f0/0
r3(config)#ip default-network 192.168.1.0
r3#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
r3#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 8/54/112 ms
r3#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
20.0.0.0/24 is subnetted, 1 subnets
C       20.1.1.0 is directly connected, FastEthernet0/1
10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/0
S*   192.168.1.0/24 is directly connected, FastEthernet0/0
r3(config)#ip route 192.168.1.0 255.255.255.0 10.1.1.1
r3#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 10.1.1.1 to network 192.168.1.0
20.0.0.0/24 is subnetted, 1 subnets
C       20.1.1.0 is directly connected, FastEthernet0/1
10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/0
S*   192.168.1.0/24 [1/0] via 10.1.1.1
r3#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/56/84 ms
r3#ping 192.168.1.1                                      
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/56/128 ms
r1#sh int lo0
Loopback0 is up, line protocol is up
Hardware is Loopback
Internet address is 192.168.1.1/24
MTU 1514 bytes, BW 8000000 Kbit, DLY 5000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation LOOPBACK, loopback not set
Last input never, output never, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/0 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
0 packets input, 0 bytes, 0 no buffer
Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
0 packets output, 0 bytes, 0 underruns
0 output errors, 0 collisions, 0 interface resets
0 output buffer failures, 0 output buffers swapped out
但是如果我们把lo0:192.168.1.1 的代理ARP关闭了,在ping 172.16.1.1
r3#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/44/148 ms
修改默认网关为172.16.0.0
r3(config)#ip default-network 172.16.1.0
r3(config)#
r3(config)#ip route 172.16.1.0 255.255.255.0 10.1.1.1
r3#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 10.1.1.1 to network 192.168.1.0
20.0.0.0/24 is subnetted, 1 subnets
C       20.1.1.0 is directly connected, FastEthernet0/1
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
S172.16.0.0/16 [1/0] via 172.16.1.0
S172.16.1.0/24 [1/0] via 10.1.1.1
10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/0
S*192.168.1.0/24 [1/0] via 10.1.1.1
r3(config)#ip default-network 172.16.0.0
r3#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 10.1.1.1 to network 192.168.1.0
20.0.0.0/24 is subnetted, 1 subnets
C       20.1.1.0 is directly connected, FastEthernet0/1
*172.16.0.0/24 is subnetted, 1 subnets
S172.16.1.0 [1/0] via 10.1.1.1
10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/0
S*   192.168.1.0/24 [1/0] via 10.1.1.1
r3(config)#ip route 172.16.0.0 255.255.0.0 10.1.1.1
r3#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 10.1.1.1 to network 172.16.0.0
20.0.0.0/24 is subnetted, 1 subnets
C       20.1.1.0 is directly connected, FastEthernet0/1
*   172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
S*172.16.0.0/16 [1/0] via 10.1.1.1
S       172.16.1.0/24 [1/0] via 10.1.1.1
10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/0
S*192.168.1.0/24 [1/0] via 10.1.1.1
r3#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/57/132 ms
r3#p 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/42/108 ms
注:如果配置多条默认网关,选择AD值小的使用,如果AD值相同,那么就是看谁在路由表里靠上就用谁。

转载于:https://blog.51cto.com/zhaopengrui1208/381355

配置六 ip default-network相关推荐

  1. Docker 配置固定IP及桥接的实现方法(转载)

    这篇文章主要介绍了Docker 配置固定IP和桥接的实现方法的相关资料,这里详细介绍了Docker 的四种网络模式及如何实现桥接的案例,需要的朋友可以参考下 docker默认使用bridge模式,通过 ...

  2. 远程拷贝、查看端口、vim常见快捷键、查找替换命令、grep命令、查看存储空间的命令、chkconfig命令、系统自动启动级别、主机名配置、IP地址配置、域名映射、防火墙设置

    2.1.远程拷贝 (将/export/servers/hadoop上的文件拷贝到bigdate@192.168.1.1:/export/servers/ ) scp –r /export/server ...

  3. 如何在CentOS 7中配置静态IP地址

    转载来源:https://www.techrepublic.com/article/how-to-configure-a-static-ip-address-in-centos-7/ PS:这个简短的 ...

  4. vagrant的同步文件配置,配置虚拟机ip映射

    同步文件的配置 官方说明:https://www.vagrantup.com/docs/synced-folders vagrant默认将Vagrantfile同级目录全部共享到虚拟机的vagrant ...

  5. Linux -- 手动配置静态IP

    什么是ip地址? ip地址是网络通信使用的地址,类似于手机里的电话号码,每台电脑必须有ip地址,才可以与其他电脑通信. 在实际的工作里,linux服务器都是使用静态ip地址,本文教大家如何手动设置配置 ...

  6. 【OS】Linux环境下配置固定IP地址--静态IP地址(不能上外网问题)

    [OS]Linux环境下配置固定IP地址--静态IP地址(不能上外网问题) ---red hat重启网卡 service network restart /etc/rc.d/init.d/networ ...

  7. 如何配置Linux ip地址

    ​ 第一步:在Vmware中打开自己的虚拟机,在菜单栏选中选择虚拟机,进入到虚拟机设置,点击网络适配器,勾选已连接并且选择NAT模式. 第二步:打开Vmware菜单栏中的编辑选项,打开虚拟网络编辑器, ...

  8. linux命令配置网卡IP (全)

    在Linux系统中,TCP/IP网络是通过若干个文本文件进行配置的,有时需要编辑这些文件来完成联网工作. vi /etc/sysconfig/network-scripts/ifcfg-eth0 :进 ...

  9. linux命令的使用:配置静态ip,查看网关,dns服务器ip,关闭防火墙,selinux

    linux是:其实就是类unix的操作系统. like unix 使用c语言写的linux linus 李纳斯:kernel(内核):是操作系统内部最核心的软件.作用:1.对cpu进行调度管理2.对内 ...

最新文章

  1. 远程桌面连接“发生身份验证错误。 无法连接到本地安全机构”解决方法
  2. linux 开机自启动设置 inittab 详解
  3. 为什么Map桶中个数超过8才转为红黑树
  4. xenserver 脚本学习之/opt/xensource/bin/xapi-wait-init-complete
  5. Rancher 2.0正式发布:简化、加速企业Kubernetes落地
  6. Git的工作流程简介
  7. C语言笔试常考知识点
  8. 红外倒车雷达原理图_自动驾驶汽车传感器技术解析—毫米波雷达
  9. 西门子转以太网模块连接S7-300以太网驱动
  10. 53-20210316华为海思Hi3516DV300的linux系统通过网口刷机(eMMC模式)
  11. 有哪些培训管理教务系统?染书CRMA,进销存管理明细清晰
  12. 计算机主机电源品牌有哪些,电脑电源的一线品牌有哪些?
  13. 准程序猿的创意(二)
  14. 2018北京小学生信息学科普竞赛试题点评
  15. 设计幸运大转盘h5小游戏总结
  16. matlab的title太长,如何换行?
  17. 第七周求圆柱体表面积
  18. Android Framework添加自定义服务和接口
  19. USACO 2021 January Contest, BronzeProblem 3. Just Stalling题解 贪心 排序
  20. Maya/3DMax/RV的集成插件下载

热门文章

  1. 聊聊 | 他在Google Play安全奖励计划贡献榜单上排名第一
  2. 思科精睿系列交换机被曝高危漏洞,仅修复部分产品
  3. OpenCV4Android人脸检测功能
  4. exp-小写字母表导出问题?
  5. Spring 定时任务
  6. iOS真机UI调试利器——Reveal
  7. MySQL服务器安装完之后如何调节性能
  8. 2013-8-9练习[多种方法制作一个计时器]
  9. css中的大于号是什么意思 有何作用
  10. linux 快捷matlab_ubuntu下Matlab_Linux添加工具包操作步骤