Skip to content

Commit 00636f1

Browse files
edipascaleFrostman
authored andcommitted
Update VLAB demo with GW peering examples
Signed-off-by: Emanuele Di Pascale <[email protected]> (cherry picked from commit 9fb8e2a)
1 parent 8b88897 commit 00636f1

File tree

1 file changed

+201
-2
lines changed

1 file changed

+201
-2
lines changed

docs/vlab/demo.md

Lines changed: 201 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ graph TD
8787
## Utility based VPC creation
8888

8989
### Setup VPCs
90-
`hhfab vlab` includes a utility to create VPCs in vlab. This utility is a `hhfab vlab` sub-command. `hhfab vlab setup-vpcs`.
90+
`hhfab vlab` includes a utility to create VPCs in vlab. This utility is a `hhfab vlab` sub-command, `hhfab vlab setup-vpcs`.
9191

9292
```
9393
NAME:
@@ -99,14 +99,17 @@ USAGE:
9999
OPTIONS:
100100
--dns-servers value, --dns value [ --dns-servers value, --dns value ] DNS servers for VPCs advertised by DHCP
101101
--force-cleanup, -f start with removing all existing VPCs and VPCAttachments (default: false)
102+
--hash-policy value, --hash value xmit_hash_policy for bond interfaces on servers [layer2|layer2+3|layer3+4|encap2+3|encap3+4|vlan+srcmac] (default: "layer2+3")
102103
--help, -h show help
103104
--interface-mtu value, --mtu value interface MTU for VPCs advertised by DHCP (default: 0)
104105
--ipns value IPv4 namespace for VPCs (default: "default")
106+
--keep-peerings, --peerings Do not delete all VPC, External and Gateway peerings before enforcing VPCs (default: false)
105107
--name value, -n value name of the VM or HW to access
106108
--servers-per-subnet value, --servers value number of servers per subnet (default: 1)
107109
--subnets-per-vpc value, --subnets value number of subnets per VPC (default: 1)
108110
--time-servers value, --ntp value [ --time-servers value, --ntp value ] Time servers for VPCs advertised by DHCP
109111
--vlanns value VLAN namespace for VPCs (default: "default")
112+
--vpc-mode value, --mode value VPC mode: empty (l2vni) by default or l3vni, etc
110113
--wait-switches-ready, --wait wait for switches to be ready before and after configuring VPCs and VPCAttachments (default: true)
111114
112115
Global options:
@@ -118,7 +121,7 @@ OPTIONS:
118121
```
119122

120123
### Setup Peering
121-
`hhfab vlab` includes a utility to create VPC peerings in VLAB. This utility is a `hhfab vlab` sub-command. `hhfab vlab setup-peerings`.
124+
`hhfab vlab` includes a utility to create VPC peerings in VLAB. This utility is a `hhfab vlab` sub-command, `hhfab vlab setup-peerings`.
122125

123126
```
124127
NAME:
@@ -141,6 +144,7 @@ USAGE:
141144
VPC Peerings:
142145
143146
1+2 -- VPC peering between vpc-01 and vpc-02
147+
1+2:gw -- same as above but using gateway peering, only valid if gateway is present
144148
demo-1+demo-2 -- VPC peering between vpc-demo-1 and vpc-demo-2
145149
1+2:r -- remote VPC peering between vpc-01 and vpc-02 on switch group if only one switch group is present
146150
1+2:r=border -- remote VPC peering between vpc-01 and vpc-02 on switch group named border
@@ -149,6 +153,7 @@ USAGE:
149153
External Peerings:
150154
151155
1~as5835 -- external peering for vpc-01 with External as5835
156+
1~as5835:gw -- same as above but using gateway peering, only valid if gateway is present
152157
1~ -- external peering for vpc-1 with external if only one external is present for ipv4 namespace of vpc-01, allowing
153158
default subnet and any route from external
154159
1~:subnets=default@prefixes=0.0.0.0/0 -- external peering for vpc-1 with auth external with default vpc subnet and
@@ -469,3 +474,197 @@ core@control-1 ~ $ kubectl apply -f vpc-3.yaml
469474
At that point you can setup networking on `server-03` the same as you did for `server-01` and `server-02` in
470475
[a previous section](#setting-up-networking-on-test-servers). Once you have configured networking, `server-01` and
471476
`server-03` have IP addresses from the same subnets.
477+
478+
## Gateway peerings and NAT
479+
480+
### Creating simple VPC peering via the gateway
481+
482+
If gateway was [enabled](running.md#gateway) for your VLAB topology, you also have the option of peering VPCs
483+
via the gateway. One way of doing so is using the [hhfab helpers](#setup-peering). For example, assuming vpc-1
484+
and vpc-2 were previously created, you can run:
485+
486+
```
487+
hhfab vlab setup-peerings 1+2:gw
488+
```
489+
490+
Alternatively, you can create the peering manually in the control node, using the examples in the
491+
[gateway section of the user guide](../user-guide/gateway.md#gateway-peering) as a base, e.g.:
492+
493+
```
494+
core@control-1 ~ $ cat <<EOF > vpc-1--vpc-2--gw.yaml
495+
apiVersion: gateway.githedgehog.com/v1alpha1
496+
kind: Peering
497+
metadata:
498+
name: vpc-1--vpc-2
499+
namespace: default
500+
spec:
501+
peering:
502+
vpc-1:
503+
expose:
504+
- ips:
505+
- cidr: 10.0.1.0/24
506+
vpc-2:
507+
expose:
508+
- ips:
509+
- cidr: 10.0.2.0/24
510+
EOF
511+
512+
core@control-1 ~ $ kubectl create -f vpc-1--vpc-2--gw.yaml
513+
peering.gateway.githedgehog.com/vpc-1--vpc-2 created
514+
core@control-1 ~ $
515+
```
516+
517+
You should now be able to check connectivity using the same methods described previously, e.g.:
518+
519+
```
520+
core@server-01 ~ $ ping 10.0.2.10
521+
PING 10.0.2.10 (10.0.2.10) 56(84) bytes of data.
522+
64 bytes from 10.0.2.10: icmp_seq=1 ttl=61 time=70.0 ms
523+
64 bytes from 10.0.2.10: icmp_seq=2 ttl=61 time=11.6 ms
524+
64 bytes from 10.0.2.10: icmp_seq=3 ttl=61 time=14.0 ms
525+
^C
526+
--- 10.0.2.10 ping statistics ---
527+
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
528+
rtt min/avg/max/mdev = 11.560/31.852/70.008/26.998 ms
529+
```
530+
531+
### VPC peering with Stateless NAT
532+
533+
Let's either edit or recreate the previous peering so that it looks like this:
534+
535+
```{.yaml .annotate linenums="1" title="vpc-1--vpc-2--gw.yaml"}
536+
apiVersion: gateway.githedgehog.com/v1alpha1
537+
kind: Peering
538+
metadata:
539+
name: vpc-1--vpc-2
540+
namespace: default
541+
spec:
542+
peering:
543+
vpc-1:
544+
expose:
545+
- ips:
546+
- cidr: 10.0.1.0/24
547+
vpc-2:
548+
expose:
549+
- ips:
550+
- cidr: 10.0.2.0/24
551+
as:
552+
- cidr: 192.168.2.0/24
553+
```
554+
555+
If we try pinging server-2 from server-1 using its real IP address, we should now
556+
observe a failure:
557+
558+
```
559+
core@server-01 ~ $ ping 10.0.2.10 -c 3 -W 1
560+
PING 10.0.2.10 (10.0.2.10) 56(84) bytes of data.
561+
From 10.0.1.1 icmp_seq=1 Destination Net Unreachable
562+
From 10.0.1.1 icmp_seq=2 Destination Net Unreachable
563+
From 10.0.1.1 icmp_seq=3 Destination Net Unreachable
564+
565+
--- 10.0.2.10 ping statistics ---
566+
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2006ms
567+
```
568+
569+
However, using the translated IP:
570+
```
571+
core@server-01 ~ $ ping 192.168.2.10 -c 3 -W 1
572+
PING 192.168.2.10 (192.168.2.10) 56(84) bytes of data.
573+
64 bytes from 192.168.2.10: icmp_seq=1 ttl=61 time=13.5 ms
574+
64 bytes from 192.168.2.10: icmp_seq=2 ttl=61 time=13.1 ms
575+
64 bytes from 192.168.2.10: icmp_seq=3 ttl=61 time=12.7 ms
576+
577+
--- 192.168.2.10 ping statistics ---
578+
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
579+
rtt min/avg/max/mdev = 12.716/13.099/13.460/0.304 ms
580+
```
581+
582+
And in the other direction this is completely transparent:
583+
```
584+
core@server-02 ~ $ ping 10.0.1.10 -c 3 -W 1
585+
PING 10.0.1.10 (10.0.1.10) 56(84) bytes of data.
586+
64 bytes from 10.0.1.10: icmp_seq=1 ttl=61 time=29.8 ms
587+
64 bytes from 10.0.1.10: icmp_seq=2 ttl=61 time=12.2 ms
588+
64 bytes from 10.0.1.10: icmp_seq=3 ttl=61 time=12.3 ms
589+
590+
--- 10.0.1.10 ping statistics ---
591+
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
592+
rtt min/avg/max/mdev = 12.177/18.106/29.826/8.287 ms
593+
```
594+
595+
### VPC peering with Stateful NAT
596+
597+
Let's change the peering again to use source stateful NAT:
598+
599+
```{.yaml .annotate linenums="1" title="vpc-1--vpc-2--gw.yaml"}
600+
apiVersion: gateway.githedgehog.com/v1alpha1
601+
kind: Peering
602+
metadata:
603+
name: vpc-1--vpc-2
604+
namespace: default
605+
spec:
606+
peering:
607+
vpc-1:
608+
expose:
609+
- ips:
610+
- cidr: 10.0.1.0/24
611+
vpc-2:
612+
expose:
613+
- ips:
614+
- cidr: 10.0.2.0/24
615+
as:
616+
- cidr: 192.168.5.40/31
617+
nat:
618+
stateful:
619+
idleTimeout: 1m
620+
```
621+
622+
This time we are not able to ping the server with either its real or
623+
translated IPs; flows are allowed in reverse direction only if they were initiated
624+
by the source, up until the idle timeout expires.
625+
626+
```
627+
core@server-01 ~ $ ping 10.0.2.10 -c 3 -W 1
628+
PING 10.0.2.10 (10.0.2.10) 56(84) bytes of data.
629+
From 10.0.1.1 icmp_seq=1 Destination Net Unreachable
630+
From 10.0.1.1 icmp_seq=2 Destination Net Unreachable
631+
From 10.0.1.1 icmp_seq=3 Destination Net Unreachable
632+
633+
--- 10.0.2.10 ping statistics ---
634+
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2004ms
635+
636+
core@server-01 ~ $ ping 192.168.5.40 -c 3 -W 1
637+
PING 192.168.5.40 (192.168.5.40) 56(84) bytes of data.
638+
639+
--- 192.168.5.40 ping statistics ---
640+
3 packets transmitted, 0 received, 100% packet loss, time 2078ms
641+
```
642+
643+
If we ping from the server attached to the VPC with source NAT, however, things just work:
644+
645+
```
646+
core@server-02 ~ $ ping 10.0.1.10 -c 3 -W 1
647+
PING 10.0.1.10 (10.0.1.10) 56(84) bytes of data.
648+
64 bytes from 10.0.1.10: icmp_seq=1 ttl=61 time=16.3 ms
649+
64 bytes from 10.0.1.10: icmp_seq=2 ttl=61 time=12.2 ms
650+
64 bytes from 10.0.1.10: icmp_seq=3 ttl=61 time=11.6 ms
651+
652+
--- 10.0.1.10 ping statistics ---
653+
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
654+
rtt min/avg/max/mdev = 11.569/13.358/16.297/2.094 ms
655+
```
656+
657+
Running tcpdump on the destination server confirms that pings appear to come from the translated IP address:
658+
659+
```
660+
core@server-01 ~ $ sudo tcpdump -ni bond0.1001 icmp
661+
dropped privs to pcap
662+
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
663+
listening on bond0.1001, link-type EN10MB (Ethernet), snapshot length 262144 bytes
664+
10:06:53.855140 IP 192.168.5.40 > 10.0.1.10: ICMP echo request, id 7170, seq 1, length 64
665+
10:06:53.855205 IP 10.0.1.10 > 192.168.5.40: ICMP echo reply, id 7170, seq 1, length 64
666+
10:06:54.860640 IP 192.168.5.40 > 10.0.1.10: ICMP echo request, id 7170, seq 2, length 64
667+
10:06:54.860704 IP 10.0.1.10 > 192.168.5.40: ICMP echo reply, id 7170, seq 2, length 64
668+
10:06:55.859745 IP 192.168.5.40 > 10.0.1.10: ICMP echo request, id 7170, seq 3, length 64
669+
10:06:55.859801 IP 10.0.1.10 > 192.168.5.40: ICMP echo reply, id 7170, seq 3, length 64
670+
```

0 commit comments

Comments
 (0)