@@ -57,8 +57,6 @@ func main() {
5757 os .Exit (ExitSetupFailed )
5858 }
5959
60- fmt .Printf ("Setting up interface %s\n " , interfaceName )
61-
6260 links , err := netlink .LinkList ()
6361 if err != nil {
6462 fmt .Printf ("Could not list links: %v\n " , err )
@@ -80,6 +78,8 @@ func main() {
8078 linkAttrs := netlink .NewLinkAttrs ()
8179 linkAttrs .Name = interfaceName
8280
81+ fmt .Printf ("Creating WireGuard interface %s\n " , interfaceName )
82+
8383 wireguard := & netlink.Wireguard {LinkAttrs : linkAttrs }
8484 err = netlink .LinkAdd (wireguard )
8585 if err != nil {
@@ -95,6 +95,8 @@ func main() {
9595 fmt .Printf ("Could not parse host peer IPNet: %v\n " , err )
9696 }
9797
98+ fmt .Println ("Assigning IP to WireGuard interface" )
99+
98100 addr := netlink.Addr {IPNet : vmIpNet , Peer : hostIpNet }
99101 netlink .AddrAdd (wireguard , & addr )
100102
@@ -146,6 +148,8 @@ func main() {
146148 },
147149 }
148150
151+ fmt .Println ("Configuring WireGuard device" )
152+
149153 err = c .ConfigureDevice (interfaceName , wgtypes.Config {
150154 PrivateKey : & vmPrivateKey ,
151155 Peers : []wgtypes.PeerConfig {peer },
@@ -167,6 +171,8 @@ func main() {
167171 os .Exit (ExitSetupFailed )
168172 }
169173
174+ fmt .Println ("Adding iptables NAT rule for host WireGuard IP" )
175+
170176 // Add iptables NAT rule to translate incoming packet's
171177 // source IP to the respective Docker network interface IP.
172178 // Required to route reply packets back through correct
0 commit comments