独立服务器Debian10添加已购IP

添加IPV6

查看网卡。

ifconfig
root@zinoin:~# ifconfig

eno3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 51.255.83.27  netmask 255.255.255.0  broadcast 51.255.83.255
        inet6 fe80::ae1f:6bff:fe70:ec2a  prefixlen 64  scopeid 0x20<link>
        ether ac:1f:6b:70:ec:2a  txqueuelen 1000  (Ethernet)
        RX packets 3003010  bytes 603636341 (575.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 316570  bytes 47667615 (45.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2363  bytes 284492 (277.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2363  bytes 284492 (277.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

可以看到我的网卡是eno3,编辑/etc/network/interfaces(有的服务器是/etc/network/interface)文件。

nano /etc/network/interfaces

添加如下代码。

auto eno3:0
iface eno3:0 inet static
address ip1
netmask 255.255.255.255

如果需要添加多个,以此类推。

auto eno3:0
iface eno3:0 inet static
address ip1
netmask 255.255.255.255

auto eno3:1
iface eno3:1 inet static
address ip2
netmask 255.255.255.255

auto eno3:3
iface eno3:3 inet static
address ip3
netmask 255.255.255.255

将ip上线

ifup eno3:0 

添加ip多的话,可以重启网络。

sudo /etc/init.d/networking restart

将ip下线

ifdown eno3:0

添加IPV6

ifconfig eno3 inet6 add IPV6/64 up

删除IPV6

ifconfig ens3 inet6 del IPV6/64