我的服务器的一个网卡有双重 IP 地址。我该如何解决这个问题?

我的服务器的一个网卡有双重 IP 地址。我该如何解决这个问题?

我的服务器 (20.04.2) 有双重地址,我尝试删除一个地址,因为它不属于该地址,我想将该 IP 释放给另一台机器。有没有办法重置/删除旧 IP?(10.0.0.14/24) 我尝试了以下操作:

$ sudo ip addr del 10.0.0.14/24 dev enp3s0 && ip addr show dev enp3s0 && sudo dhclient enp3s0 -v
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 44:8a:5b:2c:d0:b4 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.10/24 brd 10.0.0.255 scope global dynamic enp3s0
       valid_lft 84971sec preferred_lft 84971sec
    inet6 fdca:93c9:a381:2:15f0:9cf1:30bc:e16e/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 1645sec preferred_lft 1645sec
    inet6 fdca:93c9:a381:2:468a:5bff:fe2c:d0b4/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 1645sec preferred_lft 1645sec
    inet6 fe80::468a:5bff:fe2c:d0b4/64 scope link
       valid_lft forever preferred_lft forever
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/enp3s0/44:8a:5b:2c:d0:b4
Sending on   LPF/enp3s0/44:8a:5b:2c:d0:b4
Sending on   Socket/fallback
DHCPREQUEST for 10.0.0.10 on enp3s0 to 255.255.255.255 port 67 (xid=0x7f7c960)
DHCPACK of 10.0.0.10 from 10.0.0.1 (xid=0x60c9f707)
RTNETLINK answers: File exists
bound to 10.0.0.10 -- renewal in 41969 seconds.

$ cat /etc/dhcpcd.conf 
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
interface enp3s0
        static ip_address=10.0.0.14/24
        static routers=10.0.0.1
        static domain_name_servers=208.67.222.222 208.67.220.220

$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp3s0:
      dhcp4: true
  version: 2
/etc/netplan$ cat /etc/network/interfaces
/etc/netplan$

答案1

/etc/dhcpcd.conf修改文件中的行,static ip_address=10.0.0.14/24static ip_address=10.0.0.10/24使其不再尝试设置 10.0.0.14 IP 地址。

相关内容