我在 /etc/network/interfaces 中配置静态 ip
$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.121
netmask 255.255.255.0
gateway 192.168.1.1
并重新启动 eth0 接口
$ sudo ifconfig eth0 down
$ sudo ifconfig eth0 up
但 eth0 接口没有改变。
$ ifconfig -a
eth0 Link encap:Ethernet HWaddr 90:e6:ba:22:6a:f2
inet addr:192.168.1.104 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::92e6:baff:fe22:6af2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7908 errors:0 dropped:0 overruns:0 frame:0
TX packets:10112 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5452712 (5.4 MB) TX bytes:1534077 (1.5 MB)
Interrupt:46 Base address:0x4000
答案1
尝试以下命令:sudo /etc/init.d/networking restart