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
@ -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