设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 数据 手机 公司
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

如何在Ubuntu系统中添加一个辅助IP地址(4)

发布时间:2018-09-10 04:02 所属栏目:117 来源:Prakash Subramanian
导读:此外,我们不需要添加子接口(我们之前在 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 netwo

此外,我们不需要添加子接口(我们之前在 Ubuntu 14.04 LTS 中的做法):

  1. # vi /etc/network/interfaces
  2.  
  3. # interfaces(5) file used by ifup(8) and ifdown(8)
  4. auto lo
  5. iface lo inet loopback
  6.  
  7. # The primary network interface
  8. auto enp0s3
  9. iface enp0s3 inet static
  10. address 192.168.56.201
  11. netmask 255.255.255.0
  12.  
  13. iface enp0s3 inet static
  14. address 192.168.56.202
  15. netmask 255.255.255.0
  16.  
  17. gateway 192.168.56.1
  18. network 192.168.56.0
  19. broadcast 192.168.56.255
  20. dns-nameservers 8.8.8.8 8.8.4.4
  21. dns-search 2daygeek.local

保存并关闭文件,然后重启网络接口服务:

  1. # systemctl restart networking
  2. # ifdown enp0s3 && ifup enp0s3

运行以下命令来检查是否已经分配了新的 IP:

  1. # ip addr
  2. 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
  3. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  4. inet 127.0.0.1/8 scope host lo
  5. valid_lft forever preferred_lft forever
  6. inet6 ::1/128 scope host
  7. valid_lft forever preferred_lft forever
  8. 2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
  9. link/ether 08:00:27:97:13:2e brd ff:ff:ff:ff:ff:ff
  10. inet 192.168.56.201/24 brd 192.168.56.255 scope global enp0s3
  11. valid_lft forever preferred_lft forever
  12. inet 192.168.56.202/24 brd 192.168.56.255 scope global secondary enp0s3
  13. valid_lft forever preferred_lft forever
  14. inet6 fe80::a00:27ff:fe97:132e/64 scope link
  15. valid_lft forever preferred_lft forever
  16. 3: enp0s8: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
  17. link/ether 08:00:27:12:e8:c1 brd ff:ff:ff:ff:ff:ff
  18. inet 10.0.3.15/24 brd 10.0.3.255 scope global dynamic enp0s8
  19. valid_lft 86353sec preferred_lft 86353sec
  20. inet6 fe80::344b:6259:4dbe:eabb/64 scope link
  21. valid_lft forever preferred_lft forever

让我来 ping 一下新 IP 地址:

  1. # ping 192.168.56.202 -c 4
  2. PING 192.168.56.202 (192.168.56.202) 56(84) bytes of data.
  3. 64 bytes from 192.168.56.202: icmp_seq=1 ttl=64 time=0.019 ms
  4. 64 bytes from 192.168.56.202: icmp_seq=2 ttl=64 time=0.087 ms
  5. 64 bytes from 192.168.56.202: icmp_seq=3 ttl=64 time=0.034 ms
  6. 64 bytes from 192.168.56.202: icmp_seq=4 ttl=64 time=0.042 ms
  7.  
  8. --- 192.168.56.202 ping statistics ---
  9. 4 packets transmitted, 4 received, 0% packet loss, time 3068ms
  10. rtt min/avg/max/mdev = 0.019/0.045/0.087/0.026 ms

【编辑推荐】

  1. 「实用工具」介绍几款Windows系统与Linux服务器传递文件的工具
  2. Linux用户应该换到BSD的6个理由
  3. Linux中sudo,su与su命令的区别
  4. Linux运维常见问题及解决的32个锦囊妙计
  5. 如何在Linux中不使用功能键在TTY之间切换
【责任编辑:庞桂玉 TEL:(010)68476606】
点赞 0

(编辑:ASP站长网)

网友评论
推荐文章
    热点阅读