Is there a similar command like this
$ consul agent -bind '{{ GetInterfaceIP "eth0" }}'
for windows network interface?
Is the go-sockaddr template restricted only for Linux?
馃憖馃憖馃憖
I gave it a shot on Windows and didn't seem to work. Would be super nice though if it did.
This should work as support for this was added in Go 1.6: https://github.com/golang/go/issues/5395
Yes, this should work on windows but windows device naming is a little different. For testing things out it might be easier to use the go-sockaddr cli: https://github.com/hashicorp/go-sockaddr#sockaddr-cli. If you want it to dump all the interface names then you could run the following:
sockaddr eval 'GetAllInterfaces | unique "name" | join "name" "\n"'
I was testing this out with some other windows users and it seems like there are issues with shell quote escaping. Consul needs to get the input with the double quotes around the interface name otherwise it will not work. In cmd.exe it seemed that the double quotes inside the single quotes were being removed. So you might want to try escaping those double quotes.
Hi all!
I've been messing around with this and I was able to get it working in conjunction with @mkeeler 's earlier comment about getting the interface name:
PS C:\Users\chipv> consul agent -dev -bind '{{ GetInterfaceIP \"Ethernet\" }}'
==> Starting Consul agent...
Version: 'v1.8.0+ent'
Node ID: 'bfee118a-48e1-333a-8201-5429bce1c51b'
Node name: 'CV-HASHI'
Datacenter: 'dc1' (Segment: '<all>')
Server: true (Bootstrap: false)
Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, gRPC: 8502, DNS: 8600)
Cluster Addr: [IP] (LAN: 8301, WAN: 8302)
Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false, Auto-Encrypt-TLS: false
==> Log data will now stream in as it occurs:
2020-06-25T17:07:48.572-0400 [DEBUG] agent: Using random ID as node ID: id=bfee118a-48e1-333a-8201-5429bce1c51b
2020-06-25T17:07:48.585-0400 [INFO] agent.server.raft: initial configuration: index=1 servers="[{Suffrage:Voter ID:bfee118a-48e1-333a-8201-5429bce1c51b Address:[IP]:8300}]"
2020-06-25T17:07:48.585-0400 [INFO] agent.server.raft: entering follower state: follower="Node at [IP]:8300 [Follower]" leader=
2020-06-25T17:07:48.586-0400 [INFO] agent.server.serf.wan: serf: EventMemberJoin: CV-HASHI.dc1 [IP]
2020-06-25T17:07:48.587-0400 [INFO] agent.server.serf.lan: serf: EventMemberJoin: CV-HASHI [IP]
2020-06-25T17:07:48.588-0400 [INFO] agent.server: Handled event for server in area: event=member-join server=CV-HASHI.dc1 area=wan
2020-06-25T17:07:48.588-0400 [INFO] agent.server: Adding LAN server: server="CV-HASHI (Addr: tcp/[IP]:8300) (DC: dc1)"
2020-06-25T17:07:48.588-0400 [INFO] agent: Started DNS server: address=127.0.0.1:8600 network=udp
2020-06-25T17:07:48.589-0400 [INFO] agent: Started DNS server: address=127.0.0.1:8600 network=tcp
2020-06-25T17:07:48.590-0400 [INFO] agent: Started HTTP server: address=127.0.0.1:8500 network=tcp
2020-06-25T17:07:48.591-0400 [INFO] agent: Started gRPC server: address=127.0.0.1:8502 network=tcp
2020-06-25T17:07:48.591-0400 [INFO] agent: started state syncer
==> Consul agent running!
2020-06-25T17:07:48.641-0400 [WARN] agent.server.raft: heartbeat timeout reached, starting election: last-leader=
2020-06-25T17:07:48.641-0400 [INFO] agent.server.raft: entering candidate state: node="Node at [IP]:8300 [Candidate]" term=2
2020-06-25T17:07:48.642-0400 [DEBUG] agent.server.raft: votes: needed=1
2020-06-25T17:07:48.643-0400 [DEBUG] agent.server.raft: vote granted: from=bfee118a-48e1-333a-8201-5429bce1c51b term=2 tally=1
2020-06-25T17:07:48.643-0400 [INFO] agent.server.raft: election won: tally=1
2020-06-25T17:07:48.643-0400 [INFO] agent.server.raft: entering leader state: leader="Node at [IP]:8300 [Leader]"
2020-06-25T17:07:48.643-0400 [INFO] agent.server: cluster leadership acquired
2020-06-25T17:07:48.643-0400 [INFO] agent.server: New leader elected: payload=CV-HASHI
2020-06-25T17:07:48.643-0400 [DEBUG] agent.server: Cannot upgrade to new ACLs: leaderMode=0 mode=0 found=true leader=192.168.1.167:8300
2020-06-25T17:07:48.644-0400 [INFO] agent.server: Created the builtin namespace: namespace=default
2020-06-25T17:07:48.645-0400 [INFO] agent.leader: started routine: routine="namespace deferred deletion"
2020-06-25T17:07:48.645-0400 [DEBUG] connect.ca.consul: consul CA provider configured: id=07:80:c8:de:f6:41:86:29:8f:9c:b8:17:d6:48:c2:d5:c5:5c:7f:0c:03:f7:cf:97:5a:a7:c1:68:aa:23:ae:81 is_primary=true
2020-06-25T17:07:48.654-0400 [INFO] agent.server.connect: initialized primary datacenter CA with provider: provider=consul
2020-06-25T17:07:48.654-0400 [INFO] agent.leader: started routine: routine="federation state anti-entropy"
2020-06-25T17:07:48.654-0400 [INFO] agent.leader: started routine: routine="federation state pruning"
2020-06-25T17:07:48.654-0400 [INFO] agent.leader: started routine: routine="CA root pruning"
2020-06-25T17:07:48.655-0400 [DEBUG] agent.server: Skipping self join check for node since the cluster is too small: node=CV-HASHI
2020-06-25T17:07:48.655-0400 [INFO] agent.server: member joined, marking health alive: member=CV-HASHI
2020-06-25T17:07:48.804-0400 [DEBUG] agent: Skipping remote check since it is managed automatically: check=serfHealth
2020-06-25T17:07:48.805-0400 [INFO] agent: Synced node info
2020-06-25T17:07:48.815-0400 [INFO] agent.server: federation state anti-entropy synced
2020-06-25T17:07:50.312-0400 [DEBUG] agent: Skipping remote check since it is managed automatically: check=serfHealth
2020-06-25T17:07:50.313-0400 [DEBUG] agent: Node info in sync
2020-06-25T17:07:50.314-0400 [DEBUG] agent: Node info in sync
@codyja , @tai-yi , and @issacliu23 :
Here are the steps to get Consul-Windows running using Network Interfaces:
1) Taking @mkeeler's earlier comment, I ran sockaddr eval 'GetAllInterfaces | unique "name" | join "name" "\n"' in Powershell since single quotes don't work in regular cmd:
PS C:\Users\chipv> sockaddr eval 'GetAllInterfaces | sort \"default\" | unique \"name\" | join \"name\" \"\n\"'
Wi-Fi
Ethernet
vEthernet (Default Switch)
VirtualBox Host-Only Network #3
VirtualBox Host-Only Network #4
VirtualBox Host-Only Network #5
VirtualBox Host-Only Network #6
VirtualBox Host-Only Network #7
VirtualBox Host-Only Network #9
VirtualBox Host-Only Network #10
VirtualBox Host-Only Network #11
VirtualBox Host-Only Network #12
VirtualBox Host-Only Network #13
Local Area Connection* 9
Local Area Connection* 10
VMware Network Adapter VMnet1
VMware Network Adapter VMnet8
vEthernet (Default Switch)
Ethernet
Bluetooth Network Connection
Loopback Pseudo-Interface 1
2) I then run sockaddr eval 'GetInterfaceIP \"Ethernet\"' or sockaddr eval 'GetInterfaceIP \"Wi-Fi\"' to make sure that we do get an IP address returned:
PS C:\Users\chipv> sockaddr eval 'GetInterfaceIP \"Ethernet\"'
[IP1]
PS C:\Users\chipv> sockaddr eval 'GetInterfaceIP \"Wi-Fi\"'
[IP2]
3) I then start a new Consul dev agent with either "Ethernet" and "Wi-Fi"
I'll go ahead and close this, but feel free to comment if anyone has any other questions!
update:
In my case, update command to consul agent -dev -bind " {{ GetInterfaceIP \"Ethernet\" }} " fixed the issue.
Most helpful comment
@codyja , @tai-yi , and @issacliu23 :
Here are the steps to get Consul-Windows running using Network Interfaces:
1) Taking @mkeeler's earlier comment, I ran
sockaddr eval 'GetAllInterfaces | unique "name" | join "name" "\n"'in Powershell since single quotes don't work in regular cmd:2) I then run
sockaddr eval 'GetInterfaceIP \"Ethernet\"'orsockaddr eval 'GetInterfaceIP \"Wi-Fi\"'to make sure that we do get an IP address returned:3) I then start a new Consul dev agent with either "Ethernet" and "Wi-Fi"
I'll go ahead and close this, but feel free to comment if anyone has any other questions!