当网站做到一定规模的时候,或者说一定排名的时候可能就会被DDOS,很无奈。这时我们的服务器ip被机房封了。怎么办,我们可以添加一个新的IP。
第八云给您出教程
下面是给ubuntu服务器添加IP,添加完后把域名解析到新的IP地址即可。
首先像第八云客服申请IP,申请到IP后,登录第八云计算的会员中心,云服务器管理处有个VNC按钮,远程VNC管理服务器,然后参照以下代码实现
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 如何在 Ubuntu 16.04 LTS 中临时添加辅助 IP 地址 正如本文开头所述,网络接口名称从 Ubuntu 15.10 就开始从 ‘ethX’ 更改为 ‘enXXXX’ (enp0s3),所以,替换你的接口名称。 在执行此操作之前,先检查系统上的 IP 信息: # ifconfig 或 # ip addr enp0s3: flags=4163 mtu 1500 inet 192.168.56.201 netmask 255.255.255.0 broadcast 192.168.56.255 inet6 fe80::a00:27ff:fe97:132e prefixlen 64 scopeid 0x20 ether 08:00:27:97:13:2e txqueuelen 1000 (Ethernet) RX packets 7 bytes 420 (420.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 294 bytes 24747 (24.7 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp0s8: flags=4163 mtu 1500 inet 10.0.3.15 netmask 255.255.255.0 broadcast 10.0.3.255 inet6 fe80::344b:6259:4dbe:eabb prefixlen 64 scopeid 0x20 ether 08:00:27:12:e8:c1 txqueuelen 1000 (Ethernet) RX packets 1 bytes 590 (590.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 97 bytes 10209 (10.2 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 325 bytes 24046 (24.0 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 325 bytes 24046 (24.0 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 如我所见,服务器主 IP 地址是 192.168.56.201,所以,我将下一个 IP 192.168.56.202 作为辅助 IP,使用以下命令完成。 # ip addr add 192.168.56.202/24 broadcast 192.168.56.255 dev enp0s3 运行以下命令来检查是否已分配了新的 IP。当你重启机器时,它会消失。 # ip addr 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link /loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1 /8 scope host lo valid_lft forever preferred_lft forever inet6 ::1 /128 scope host valid_lft forever preferred_lft forever 2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link /ether 08:00:27:97:13:2e brd ff:ff:ff:ff:ff:ff inet 192.168.56.201 /24 brd 192.168.56.255 scope global enp0s3 valid_lft forever preferred_lft forever inet 192.168.56.202 /24 brd 192.168.56.255 scope global secondary enp0s3 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe97:132e /64 scope link valid_lft forever preferred_lft forever 3: enp0s8: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link /ether 08:00:27:12:e8:c1 brd ff:ff:ff:ff:ff:ff inet 10.0.3.15 /24 brd 10.0.3.255 scope global dynamic enp0s8 valid_lft 86353sec preferred_lft 86353sec inet6 fe80::344b:6259:4dbe:eabb /64 scope link valid_lft forever preferred_lft forever 如何在 Ubuntu 16.04 LTS 中添加永久辅助 IP 地址 要在 Ubuntu 系统上添加永久辅助 IP 地址,只需编辑 /etc/network/interfaces 文件并添加所需 IP 的详细信息。 我们不应该在 dns-nameservers 行之后添加辅助 IP 地址,因为它不会起作用,应该以下面的格式添加 IP 详情。 此外,我们不需要添加子接口(我们之前在 Ubuntu 14.04 LTS 中的做法): # vi /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback # The primary network interface auto enp0s3 iface enp0s3 inet static address 192.168.56.201 netmask 255.255.255.0 iface enp0s3 inet static address 192.168.56.202 netmask 255.255.255.0 gateway 192.168.56.1 network 192.168.56.0 broadcast 192.168.56.255 dns-nameservers 8.8.8.8 8.8.4.4 dns-search 2daygeek. local 保存并关闭文件,然后重启网络接口服务: # systemctl restart networking 或 # ifdown enp0s3 && ifup enp0s3 运行以下命令来检查是否已经分配了新的 IP: # ip addr 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link /loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1 /8 scope host lo valid_lft forever preferred_lft forever inet6 ::1 /128 scope host valid_lft forever preferred_lft forever 2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link /ether 08:00:27:97:13:2e brd ff:ff:ff:ff:ff:ff inet 192.168.56.201 /24 brd 192.168.56.255 scope global enp0s3 valid_lft forever preferred_lft forever inet 192.168.56.202 /24 brd 192.168.56.255 scope global secondary enp0s3 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe97:132e /64 scope link valid_lft forever preferred_lft forever 3: enp0s8: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link /ether 08:00:27:12:e8:c1 brd ff:ff:ff:ff:ff:ff inet 10.0.3.15 /24 brd 10.0.3.255 scope global dynamic enp0s8 valid_lft 86353sec preferred_lft 86353sec inet6 fe80::344b:6259:4dbe:eabb /64 scope link valid_lft forever preferred_lft forever 让我来 ping 一下新 IP 地址: # ping 192.168.56.202 -c 4 PING 192.168.56.202 (192.168.56.202) 56(84) bytes of data. 64 bytes from 192.168.56.202: icmp_seq=1 ttl=64 time =0.019 ms 64 bytes from 192.168.56.202: icmp_seq=2 ttl=64 time =0.087 ms 64 bytes from 192.168.56.202: icmp_seq=3 ttl=64 time =0.034 ms 64 bytes from 192.168.56.202: icmp_seq=4 ttl=64 time =0.042 ms --- 192.168.56.202 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3068ms rtt min /avg/max/mdev = 0.019 /0 .045 /0 .087 /0 .026 ms |
此方法仅适用于第八云计算的ubuntu系统,其他Linux类系统咨询客服