Three-layer routing packet forwarding and packet format analysis with single-arm routing

Source: Internet
Author: User


Above the 7242+8328 board, Wan Kou: Port3,lan: Port2,port4. Its port connection can be found in my previous article.
Eth0 The IP address above is dynamically acquired, used as an interface for external WAN Internet access, with no VLAN headers for the packets being communicated.
eth0.2: Used as an internal LAN interface. The IP address is fixed and the VLAN header is automatically added or removed when the packet passes through the LAN port.
There is no communication between the WAN and the LAN.
Note: 192.168.100.244 is the PC IP ip,192.168.1.20 for the LAN port on the PC connected to the WAN port.
---------------------------R8327 switch-configuration commands are as follows-----------------------------------------------------
Ifconfig eth0 up
Ssdk_sh VLAN Entry Create 2
Ssdk_sh Portvlan Ingress set 0 fallback
Ssdk_sh Portvlan Ingress Set 2 fallback
Ssdk_sh Portvlan Ingress set 4 fallback
Ssdk_sh VLAN Entry Append 2 2 0,2,4 0,2,4 default default, default default
Ssdk_sh Portvlan Defaultcvid Set 2 2
Ssdk_sh Portvlan Defaultcvid Set 4 2
Ssdk_sh Portvlan Egress Set 0 untagged
Ssdk_sh Portvlan Egress Set 2 untagged
Ssdk_sh Portvlan Egress Set 4 untagged
The above command is a VLAN-related configuration for the AR8327 switch. That is PORT0,PORT2,PORT4 because of the same VLAN, its VLAN
id=2. The packet is out of port with no VLAN ID.

---------------------------The main CPU ar7242-configuration commands are as follows-----------------------------------------------------
Vconfig Add eth0 2
Ifconfig eth0.2 hw ether 00:03:7f:ff:ff:f2 up ifconfig eth0.2 192.168.1.2
Udhcpc-i eth0-p/var/run/udhcpc_wan.pid-s/etc/udhcpc.script
Iptables-t nat-a postrouting-o Eth0-j Masquerade
Echo 1 >/proc/sys/net/ipv4/ip_forward
It is mainly through the Vconfig add VLAN and configure DHCPC and three-tier packets pass through the NAT rules.

------------------------------------Test 1:DHCP Online-------------------------------------------
/# Ifconfig
Eth0 Link encap:ethernet hwaddr 00:03:7f:ff:ff:ff
inet addr:192.168.100.3 bcast:192.168.100.255 mask:255.255.255.0
Inet6 ADDR:FE80::203:7FFF:FEFF:FFFF/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2382 (2.3 KiB) TX bytes:2012 (1.9 KiB)


eth0.2 Link encap:ethernet hwaddr 00:03:7f:ff:ff:f2
inet addr:192.168.1.2 bcast:192.168.1.255 mask:255.255.255.0
Inet6 ADDR:FE80::203:7FFF:FEFF:FFF2/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:734 (734.0 b) TX bytes:492 (492.0 b)


Lo Link encap:local Loopback
inet addr:127.0.0.1 mask:255.0.0.0
Inet6 addr::: 1/128 scope:host
Up loopback RUNNING mtu:16436 metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0  (0.0 B) TX bytes:0 (0.0 B)
WAN Access PC1,PC1 IP address is: 192.168.100.244, ping 192.168.100.3 above the PC1, the 7242+8328 of the board eth0 above the bag as follows:
00:02:25.389238 IP (Tos 0x0, TTL 128, id 61845, offset 0, flags [None], Proto ICMP (1), length 60)
192.168.100.244 > 192.168.100.3:icmp echo request, ID 1280, SEQ 256, length 40
0x0000:0003 7fff ffff e839 3538 9e4a 0800 4500
0x0010:003c f195 0000 8001 fee2 C0A8 64f4 c0a8
0x0020:6403 0800 475c 0500 0100 6162 6364 6566
0x0030:6768 696a 6b6c 6d6e 6f70 7172 7374 7576
0x0040:7761 6263
00:02:25.389421 IP (Tos 0x0, TTL, id 15814, offset 0, flags [None], Proto ICMP (1), length 60)
192.168.100.3 > 192.168.100.244:icmp echo reply, id 1280, SEQ 256, length 40
0x0000:e839 3538 9e4a 0003 7fff FFFF 0800 4500
0x0010:003c 3dc6 0000 4001 f2b2 C0A8 6403 c0a8
0x0020:64f4 0000 4f5c 0500 0100 6162 6364 6566
0x0030:6768 696a 6b6c 6d6e 6f70 7172 7374 7576
0x0040:7761 6263
With the above data, there is no VLAN header when communicating with PC1 (host or server).
---------------------------------------------------------------------------------------------
LAN port PC2,PC2 IP address: 192.168.1.20, in the PC2 above ping 192.168.1.2, 7242+8328 on the board eth0 above grab bag as follows:
00:08:03.487572 IP (Tos 0x0, TTL 128, ID 253, offset 0, flags [None], Proto ICMP (1), length 60)
192.168.1.20 > 192.168.1.2:icmp echo request, ID, seq 9728, length 40
0x0000:0003 7fff fff2 001a 4b8d 0305 8100 0002
0x0010:0800 4500 003c 00fd 0000 8001 b65d C0A8
0x0020:0114 c0a8 0102 0800 255c 0200 2600 6162
0x0030:6364 6566 6768 696a 6b6c 6d6e 6f70 7172
0x0040:7374 7576
00:08:03.487725 IP (Tos 0x0, TTL, id 50979, offset 0, flags [None], Proto ICMP (1), length 60)
192.168.1.2 > 192.168.1.20:icmp echo reply, id, seq 9728, length 40
0x0000:001a 4b8d 0305 0003 7fff fff2 8100 0002
0x0010:0800 4500 003c c723 0000 4001 3037 C0A8
0x0020:0102 c0a8 0114 0000 2d5c 0200 2600 6162
0x0030:6364 6566 6768 696a 6b6c 6d6e 6f70 7172
0x0040:7374 7576
The above data know, and PC1 (host or server) when communication with VLAN head its VLAN id=2.
---------------------------------------------------------------------------------------------
At the same time on the PC2 ping 192.168.100.244, in the eth0 grab bag as follows:
00:15:34.482979 IP (Tos 0x0, TTL 128, ID 951, offset 0, flags [None], Proto ICMP (1), length 60)
192.168.1.20 > 192.168.100.244:icmp echo request, ID, seq 42497, length 40
0x0000:0003 7fff fff2 001a 4b8d 0305 8100 0002
0x0010:0800 4500 003c 03b7 0000 8001 4fb1 C0A8
0x0020:0114 c0a8 64f4 0800 a55a 0200 a601 6162
0x0030:6364 6566 6768 696a 6b6c 6d6e 6f70 7172
0x0040:7374 7576
00:15:34.483077 IP (Tos 0x0, TTL 127, ID 951, offset 0, flags [None], Proto ICMP (1), length 60)
192.168.100.3 > 192.168.100.244:icmp echo request, ID, seq 42497, length 40
0x0000:e839 3538 9e4a 0003 7fff FFFF 0800 4500
0x0010:003c 03b7 0000 7f01 edc1 C0A8 6403 c0a8
0X0020:64F4 0800 a55a 0200 a601 6162 6364 6566
0x0030:6768 696a 6b6c 6d6e 6f70 7172 7374 7576
0x0040:7761 6263
00:15:34.483393 IP (Tos 0x0, TTL 128, id 64339, offset 0, flags [None], Proto ICMP (1), length 60)
192.168.100.244 > 192.168.100.3:icmp echo reply, id, seq 42497, length 40
0x0000:0003 7fff ffff e839 3538 9e4a 0800 4500
0x0010:003c fb53 0000 8001 f524 C0A8 64f4 c0a8
0x0020:6403 0000 ad5a 0200 a601 6162 6364 6566
0x0030:6768 696a 6b6c 6d6e 6f70 7172 7374 7576
0x0040:7761 6263
00:15:34.483458 IP (Tos 0x0, TTL 127, id 64339, offset 0, flags [None], Proto ICMP (1), length 60)
192.168.100.244 > 192.168.1.20:icmp echo reply,id, seq 42497, length 40
0x0000:001a 4b8d 0305 0003 7fff fff2 8100 0002
0x0010:0800 4500 003c fb53 0000 7f01 5914 C0A8
0X0020:64F4 c0a8 0114 0000 ad5a 0200 a601 6162
0x0030:6364 6566 6768 696a 6b6c 6d6e 6f70 7172
0x0040:7374 7576

The above packet can be known, an intranet packet after Nat, a ping package has "two go and two back" packet.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.