Ubuntu的问题与IP

我有一个非常奇怪的问题,其中ifconfig和我的/ etc / network / interfaces不同意。 我configuration了/ etc / network / interfaces,eth0的静态IP为192.168.2.5; 但是,ifconfig说eth0的IP是192.168.2.198(在我的DHCP范围内)。 就我的networking其余部分而言,该机器位于192.168.2.198。 我试过两次重新启动networking(/etc/init.d/networking restart),并没有解决问题。

的/ etc /networking/接口

auto lo iface lo inet loopback iface ppp0 inet ppp provider ppp0 auto ppp0 iface eth0 inet static address 192.168.2.5 netmask 255.255.255.0 gateway 192.168.2.1 

使用ifconfig

 eth0 Link encap:Ethernet HWaddr 00:19:b9:6d:a2:b1 inet addr:192.168.2.198 Bcast:192.168.2.255 Mask:255.255.255.0 inet6 addr: fe80::219:b9ff:fe6d:a2b1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:301767 errors:0 dropped:0 overruns:0 frame:0 TX packets:76931 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:153435880 (146.3 MB) TX bytes:9934052 (9.4 MB) Interrupt:22 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:23150 errors:0 dropped:0 overruns:0 frame:0 TX packets:23150 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:9998881 (9.5 MB) TX bytes:9998881 (9.5 MB) wlan0 Link encap:Ethernet HWaddr 00:19:7e:60:e7:b5 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:16 Memory:ecffc000-ed000000 

/etc/network/interfaces没有将eth0标记为“auto”。 这意味着重新启动networking会忽略该接口,并且只会保留已有的configuration(显然是DHCP分配的地址)。

尝试这个:

  1. 运行“ ifconfig eth0 0 down
  2. 编辑/etc/network/interfaces并在eth0接口的定义之上添加auto eth0
  3. 运行“ ifup eth0 ”。 它应该拿出你在/etc/network/interfaces分配的地址。

你也可能想检查你的进程表中的dhclient实例。 如果它在那里,杀死它。

你可以发布的输出:

 cat /etc/network/interfaces 

 ifconfig 

编辑:哎呀,我错过了一个:

 nm-tool 

我敢打赌,NetworkManager是为什么你的接口拉DHCP。 检查首选项>networking连接。

下面是运行Ubuntu的静态IP的/etc/network/interfaces文件:

 # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 10.10.100.17 netmask 255.255.255.0 network 10.10.100.0 broadcast 10.10.100.255 gateway 10.10.100.1 

你能确认你有意使用点对点协议吗? 另外,你想PPP或PPPoE? 如果您需要使用PPP,以下工作?

 auto lo iface lo inet loopback iface ppp0 inet ppp provider myisp auto eth0 iface eth0 inet static address 192.168.2.5 netmask 255.255.255.0 broadcast 192.168.2.255 gateway 192.168.2.1 

在上面,你需要用你的特定的isp信息replacemyisp。 另外,如果你使用PPP,你可以发布的输出:

 cat /etc/ppp/options # or any other interesting files in this directory cat ~/.ppprc