mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
tstest/natlab/vnet: add start of IPv6 support
Updates #13038 Change-Id: Ic3d095f167daf6c7129463e881b18f2e0d5693f5 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
31b5239a2f
commit
b78df4d48a
@@ -2,12 +2,18 @@
|
||||
|
||||
echo "Type 'C-a c' to enter monitor; q to quit."
|
||||
|
||||
# If the USE_V6 environment is set to 1, set the nameserver explicitly to.
|
||||
EXTRA_ARG=""
|
||||
if [ "$USE_V6" = "1" ]; then
|
||||
EXTRA_ARG="tta.nameserver=2411::411"
|
||||
fi
|
||||
|
||||
set -eux
|
||||
qemu-system-x86_64 -M microvm,isa-serial=off \
|
||||
-m 1G \
|
||||
-nodefaults -no-user-config -nographic \
|
||||
-kernel $HOME/src/github.com/tailscale/gokrazy-kernel/vmlinuz \
|
||||
-append "console=hvc0 root=PARTUUID=60c24cc1-f3f9-427a-8199-76baa2d60001/PARTNROFF=1 ro init=/gokrazy/init panic=10 oops=panic pci=off nousb tsc=unstable clocksource=hpet tailscale-tta=1 tailscaled.env=TS_DEBUG_RAW_DISCO=1" \
|
||||
-append "console=hvc0 root=PARTUUID=60c24cc1-f3f9-427a-8199-76baa2d60001/PARTNROFF=1 ro init=/gokrazy/init panic=10 oops=panic pci=off nousb tsc=unstable clocksource=hpet tailscale-tta=1 tailscaled.env=TS_DEBUG_RAW_DISCO=1 ${EXTRA_ARG}" \
|
||||
-drive id=blk0,file=$HOME/src/tailscale.com/gokrazy/natlabapp.img,format=raw \
|
||||
-device virtio-blk-device,drive=blk0 \
|
||||
-device virtio-rng-device \
|
||||
|
@@ -25,10 +25,12 @@ var (
|
||||
listen = flag.String("listen", "/tmp/qemu.sock", "path to listen on")
|
||||
nat = flag.String("nat", "easy", "type of NAT to use")
|
||||
nat2 = flag.String("nat2", "hard", "type of NAT to use for second network")
|
||||
portmap = flag.Bool("portmap", false, "enable portmapping")
|
||||
portmap = flag.Bool("portmap", false, "enable portmapping; requires --v4")
|
||||
dgram = flag.Bool("dgram", false, "enable datagram mode; for use with macOS Hypervisor.Framework and VZFileHandleNetworkDeviceAttachment")
|
||||
blend = flag.Bool("blend", true, "blend reality (controlplane.tailscale.com and DERPs) into the virtual network")
|
||||
pcapFile = flag.String("pcap", "", "if non-empty, filename to write pcap")
|
||||
v4 = flag.Bool("v4", true, "enable IPv4")
|
||||
v6 = flag.Bool("v6", true, "enable IPv6")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -61,9 +63,18 @@ func main() {
|
||||
var c vnet.Config
|
||||
c.SetPCAPFile(*pcapFile)
|
||||
c.SetBlendReality(*blend)
|
||||
node1 := c.AddNode(c.AddNetwork("2.1.1.1", "192.168.1.1/24", vnet.NAT(*nat)))
|
||||
|
||||
var net1opt = []any{vnet.NAT(*nat)}
|
||||
if *v4 {
|
||||
net1opt = append(net1opt, "2.1.1.1", "192.168.1.1/24")
|
||||
}
|
||||
if *v6 {
|
||||
net1opt = append(net1opt, "2000:52::1/64")
|
||||
}
|
||||
|
||||
node1 := c.AddNode(c.AddNetwork(net1opt...))
|
||||
c.AddNode(c.AddNetwork("2.2.2.2", "10.2.0.1/16", vnet.NAT(*nat2)))
|
||||
if *portmap {
|
||||
if *portmap && *v4 {
|
||||
node1.Network().AddService(vnet.NATPMP)
|
||||
}
|
||||
|
||||
@@ -72,8 +83,10 @@ func main() {
|
||||
log.Fatalf("newServer: %v", err)
|
||||
}
|
||||
|
||||
if err := s.PopulateDERPMapIPs(); err != nil {
|
||||
log.Printf("warning: ignoring failure to populate DERP map: %v", err)
|
||||
if *blend {
|
||||
if err := s.PopulateDERPMapIPs(); err != nil {
|
||||
log.Printf("warning: ignoring failure to populate DERP map: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
s.WriteStartingBanner(os.Stdout)
|
||||
|
Reference in New Issue
Block a user