Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ip netns add router
- # ip netns add client1
- # ip netns add client2
- # ip link add name veth-router1 netns router type veth peer name veth-client netns client1
- # ip link add name veth-router2 netns router type veth peer name veth-client netns client2
- # ip -n router address add 192.168.1.1/24 dev veth-router1
- # ip -n router address add 192.168.2.1/24 dev veth-router2
- # ip -n client1 address add 192.168.1.2/24 dev veth-client
- # ip -n client2 address add 192.168.2.2/24 dev veth-client
- # ip -n router link set veth-router1 up
- # ip -n router link set veth-router2 up
- # ip -n client1 link set veth-client up
- # ip -n client2 link set veth-client up
- # ip -n router address
- 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000
- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
- 2: veth-router1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
- link/ether 62:aa:de:e6:cb:ed brd ff:ff:ff:ff:ff:ff link-netnsid 0
- inet 192.168.1.1/24 scope global veth-router1
- valid_lft forever preferred_lft forever
- inet6 fe80::60aa:deff:fee6:cbed/64 scope link
- valid_lft forever preferred_lft forever
- 3: veth-router2@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
- link/ether 0a:6c:37:15:31:7f brd ff:ff:ff:ff:ff:ff link-netnsid 1
- inet 192.168.2.1/24 scope global veth-router2
- valid_lft forever preferred_lft forever
- inet6 fe80::86c:37ff:fe15:317f/64 scope link
- valid_lft forever preferred_lft forever
- # ip -n client1 address
- 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000
- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
- 2: veth-client: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
- link/ether 32:ce:07:18:9c:40 brd ff:ff:ff:ff:ff:ff link-netnsid 0
- inet 192.168.1.2/24 scope global veth-client
- valid_lft forever preferred_lft forever
- inet6 fe80::30ce:7ff:fe18:9c40/64 scope link
- valid_lft forever preferred_lft forever
- # ip -n client2 address
- 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000
- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
- 2: veth-client@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
- link/ether 66:7b:08:c7:c9:62 brd ff:ff:ff:ff:ff:ff link-netnsid 0
- inet 192.168.2.2/24 scope global veth-client
- valid_lft forever preferred_lft forever
- inet6 fe80::647b:8ff:fec7:c962/64 scope link
- valid_lft forever preferred_lft forever
- # ip -n client1 route add default via 192.168.1.1
- # ip -n client2 route add default via 192.168.2.1
- # ip netns exec client1 ping 192.168.2.2
- PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
- 64 bytes from 192.168.2.2: icmp_seq=1 ttl=63 time=0.043 ms
- 64 bytes from 192.168.2.2: icmp_seq=2 ttl=63 time=0.062 ms
- 64 bytes from 192.168.2.2: icmp_seq=3 ttl=63 time=0.064 ms
- 64 bytes from 192.168.2.2: icmp_seq=4 ttl=63 time=0.063 ms
- ^C
- --- 192.168.2.2 ping statistics ---
- 4 packets transmitted, 4 received, 0% packet loss, time 3098ms
- rtt min/avg/max/mdev = 0.043/0.058/0.064/0.008 ms
- # ip netns exec client1 ping 192.168.2.2 -q &
- [1] 6273
- # PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
- # ip netns exec router bash
- # tcpdump -ni any
- tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
- listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
- 01:24:32.851462 IP 192.168.1.2 > 192.168.2.2: ICMP echo request, id 6273, seq 19, length 64
- 01:24:32.851485 IP 192.168.1.2 > 192.168.2.2: ICMP echo request, id 6273, seq 19, length 64
- 01:24:32.851502 IP 192.168.2.2 > 192.168.1.2: ICMP echo reply, id 6273, seq 19, length 64
- 01:24:32.851507 IP 192.168.2.2 > 192.168.1.2: ICMP echo reply, id 6273, seq 19, length 64
- 01:24:33.875420 IP 192.168.1.2 > 192.168.2.2: ICMP echo request, id 6273, seq 20, length 64
- 01:24:33.875443 IP 192.168.1.2 > 192.168.2.2: ICMP echo request, id 6273, seq 20, length 64
- 01:24:33.875460 IP 192.168.2.2 > 192.168.1.2: ICMP echo reply, id 6273, seq 20, length 64
- 01:24:33.875465 IP 192.168.2.2 > 192.168.1.2: ICMP echo reply, id 6273, seq 20, length 64
- 01:24:34.899485 IP 192.168.1.2 > 192.168.2.2: ICMP echo request, id 6273, seq 21, length 64
- 01:24:34.899507 IP 192.168.1.2 > 192.168.2.2: ICMP echo request, id 6273, seq 21, length 64
- 01:24:34.899525 IP 192.168.2.2 > 192.168.1.2: ICMP echo reply, id 6273, seq 21, length 64
- 01:24:34.899529 IP 192.168.2.2 > 192.168.1.2: ICMP echo reply, id 6273, seq 21, length 64
- 01:24:35.923286 IP 192.168.1.2 > 192.168.2.2: ICMP echo request, id 6273, seq 22, length 64
- 01:24:35.923312 IP 192.168.1.2 > 192.168.2.2: ICMP echo request, id 6273, seq 22, length 64
- 01:24:35.923332 IP 192.168.2.2 > 192.168.1.2: ICMP echo reply, id 6273, seq 22, length 64
- 01:24:35.923338 IP 192.168.2.2 > 192.168.1.2: ICMP echo reply, id 6273, seq 22, length 64
- ^C
- 16 packets captured
- 16 packets received by filter
- 0 packets dropped by kernel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement