DEV Community

Michael
Michael

Posted on • Originally published at gbase8.cn

Does a Running Socket Automatically Listen on a Newly Added IP? It Depends.

When managing a gbase database cluster, you may add IP addresses to a running server for network flexibility. Whether an already‑running socket accepts connections on the new IP depends entirely on how the socket was bound and how the IP was added.

The Core Rule

  • Wildcard bind (0.0.0.0 or ::): Listens on all network interfaces present at bind time.
  • Specific IP bind: Listens only on that exact address.

Scenarios and Proof

1. Binding to All IPs (0.0.0.0 / ::)

If your service binds to the wildcard address, and you add a secondary IP alias on an existing interface (e.g., eth0:1), the new IP is picked up automatically — no restart required.

Here's a real test with a GBase 8a node:

  1. The node listens on ::: (IPv6 wildcard, equivalent to 0.0.0.0 for IPv6):
   [root@localhost ~]# netstat -an | grep 5050
   tcp6 0 0 :::5050 :::* LISTEN
Enter fullscreen mode Exit fullscreen mode
  1. The machine currently has only 10.0.2.101:
   [gbase@localhost ~]$ gncli -h10.0.2.101 -e "select version()"
   # Returns 9.5.2.43.5_patch.25c29237
Enter fullscreen mode Exit fullscreen mode
  1. Add three alias IPs on the same NIC without restarting the database:
   [root@localhost ~]# ifconfig enp0s3:0 192.168.0.101 netmask 255.255.255.0 up
   [root@localhost ~]# ifconfig enp0s3:1 192.168.1.101 netmask 255.255.255.0 up
   [root@localhost ~]# ifconfig enp0s3:2 192.168.2.101 netmask 255.255.255.0 up
Enter fullscreen mode Exit fullscreen mode
  1. The GBase 8a service is now reachable on all three new IPs instantly:
   [gbase@localhost ~]$ gncli -h192.168.0.101 -e "select version()"
   [gbase@localhost ~]$ gncli -h192.168.1.101 -e "select version()"
   [gbase@localhost ~]$ gncli -h192.168.2.101 -e "select version()"
   # All commands succeed and return the version
Enter fullscreen mode Exit fullscreen mode

2. When Restarting Is Required

  • New physical NIC: A socket bound to 0.0.0.0 typically does not start listening on a completely new network interface added after the process started. The kernel enumerated only the existing interfaces at bind time. A restart is needed.
  • Specific IP bind: If the service is bound to a single IP (e.g., 192.168.1.100), any other IP added later will be ignored until you change the configuration and restart the service.

Summary

Bind Mode Type of New IP Restart Required?
Specific IP Any Yes
0.0.0.0 / :: Alias on existing NIC (e.g., eth0:1) No
0.0.0.0 / :: New physical NIC / interface Likely Yes

When planning network changes in your gbase database cluster, knowing this distinction helps you decide whether you can add IPs on the fly or need to schedule a maintenance window for a service restart.

Top comments (0)