superman@mi-appserver:~$ sudo vi /etc/network/interfaces

auto ens160

iface ens160 inet static

address 10.125.11.12

netmask 255.255.255.0

gateway 10.125.11.1

dns-nameservers 223.5.5.5 223.6.6.6



superman@mi-appserver:~$ ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1

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: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

link/ether 00:50:56:b8:cc:33 brd ff:ff:ff:ff:ff:ff

inet 10.125.11.12/24 brd 10.125.11.255 scope global ens160

valid_lft forever preferred_lft forever

inet6 fe80::250:56ff:feb8:cc33/64 scope link

valid_lft forever preferred_lft forever



superman@mi-appserver:~$ sudo /etc/init.d/networking restart



##修改ip时出现多个ip可按下操作(scope global secondary)

sudo ip addr flush dev ens160

sudo ifdown ens160

sudo ifup ens160