此外,我们不需要添加子接口(我们之前在 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
【编辑推荐】
- 「实用工具」介绍几款Windows系统与Linux服务器传递文件的工具
- Linux用户应该换到BSD的6个理由
- Linux中sudo,su与su命令的区别
- Linux运维常见问题及解决的32个锦囊妙计
- 如何在Linux中不使用功能键在TTY之间切换
【责任编辑:庞桂玉 TEL:(010)68476606】
点赞 0
(编辑:ASP站长网)
|