在 [信息显示] 的 [LAN] 选项中,可以确认 ONU 的 IP 地址。 在 [DHCP 租约] 选项中,可以查看当前分配的 IP 地址。 这次,我们决定将尚未被分配的 192.168.1.254 分配给 Cisco 1812J。
图片
连接 Cisco 1812J 并进行配置
首先,确定串口线的 USB 端口并连接到 Cisco 1812J。
guest@ubuntu:∼$ sudo dmesg | grep ttyUSB
[ 34.739950] usb 1-1.3.4: FTDI USB Serial Device converter now attached to ttyUSB0
[ 34.996889] usb 1-1.3.1: pl2303 converter now attached to ttyUSB1
guest@ubuntu:∼$ cu --speed 9600 --parity=none --line /dev/ttyUSB0
Connected.
Router1>
Router1> enable
Password: ciscoRouter1# conf t
Enter configuration commands, one per line. End with CNTL/Z.
配置 Loopback 接口 Loopback 接口是一个虚拟接口,仅用于与设备自身(Cisco 1812J)通信。 我们将其 IP 地址设定为 192.168.192.168。
Router1(config)# interface Loopback 0
*Apr 6 12:39:06.171: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router1(config-if)# ip address 192.168.192.168 255.255.255.0
Router1(config-if)# exit
配置连接 ONU 的接口 将连接到 ONU 的 FastEthernet 0 接口的 IP 地址设置为 192.168.1.254。 该接口将用于向 ONU 发送流量,从而访问互联网。
Router1(config)# interface FastEthernet 0
Router1(config-if)# ip address 192.168.1.254 255.255.255.0
Router1(config-if)# no shutdown
Router1(config-if)# exit
*Apr 6 12:42:33.035: %LINK-3-UPDOWN: Interface FastEthernet0, changed state to up
*Apr 6 12:42:45.419: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0, changed state to up
配置路由信息 为了测试,我们尝试通过互联网访问 Google DNS 服务器(8.8.8.8)。 因此,我们需要将发往 8.8.8.8 的流量路由到 ONU(192.168.1.1)。
Router1(config)# ip route 8.8.8.8 255.255.255.255 192.168.1.1
Router1(config)# exit
*Apr 6 12:44:39.887: %SYS-5-CONFIG_I: Configured from console by console
然而,这样配置后,路由表并不会立即更新。
Router1# show ip route
Default gateway is not set
Host Gateway Last Use Total Uses Interface
ICMP redirect cache is empty
需要执行 ip routing 命令以使路由配置生效。
Router1# conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)# ip routing
Router1(config)# exit
*Apr 6 12:45:53.867: %SYS-5-CONFIG_I: Configured from console by console
Router1# show 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
C 192.168.192.0/24 is directly connected, Loopback0
8.0.0.0/32 is subnetted, 1 subnets
S 8.8.8.8 [1/0] via 192.168.1.1
C 192.168.1.0/24 is directly connected, FastEthernet0
C 192.168.101.0/24 is directly connected, FastEthernet1