@@ -57,8 +57,6 @@ func main() {
57
57
os .Exit (ExitSetupFailed )
58
58
}
59
59
60
- fmt .Printf ("Setting up interface %s\n " , interfaceName )
61
-
62
60
links , err := netlink .LinkList ()
63
61
if err != nil {
64
62
fmt .Printf ("Could not list links: %v\n " , err )
@@ -80,6 +78,8 @@ func main() {
80
78
linkAttrs := netlink .NewLinkAttrs ()
81
79
linkAttrs .Name = interfaceName
82
80
81
+ fmt .Printf ("Creating WireGuard interface %s\n " , interfaceName )
82
+
83
83
wireguard := & netlink.Wireguard {LinkAttrs : linkAttrs }
84
84
err = netlink .LinkAdd (wireguard )
85
85
if err != nil {
@@ -95,6 +95,8 @@ func main() {
95
95
fmt .Printf ("Could not parse host peer IPNet: %v\n " , err )
96
96
}
97
97
98
+ fmt .Println ("Assigning IP to WireGuard interface" )
99
+
98
100
addr := netlink.Addr {IPNet : vmIpNet , Peer : hostIpNet }
99
101
netlink .AddrAdd (wireguard , & addr )
100
102
@@ -146,6 +148,8 @@ func main() {
146
148
},
147
149
}
148
150
151
+ fmt .Println ("Configuring WireGuard device" )
152
+
149
153
err = c .ConfigureDevice (interfaceName , wgtypes.Config {
150
154
PrivateKey : & vmPrivateKey ,
151
155
Peers : []wgtypes.PeerConfig {peer },
@@ -167,6 +171,8 @@ func main() {
167
171
os .Exit (ExitSetupFailed )
168
172
}
169
173
174
+ fmt .Println ("Adding iptables NAT rule for host WireGuard IP" )
175
+
170
176
// Add iptables NAT rule to translate incoming packet's
171
177
// source IP to the respective Docker network interface IP.
172
178
// Required to route reply packets back through correct
0 commit comments