在Ubuntu的networking服务启动/停止混乱

我准备移动并取下我的两台服务器,只留下一台运行一些基本服务的服务器。 我忽略了一个问题,那就是DHCP服务器(当有人联系我时,我意识到他们无法连接。 所以,因为我在这个小networking上只有几个主机,我select静态configuration它们。 其中之一是一个新的Ubuntu 11.04服务器,我有很less的经验。

我编辑了/etc/network/interfaces/etc/hosts来反映我的改变。

我跑了

 $sudo /etc/init.d/networking stop *deconfiguring network interfaces ... 

所以,耶 然后,我试着开始,它给了我关于使用服务的巨无霸(为什么没有这样做的停止?)所以,而是我跑…

 $sudo service networking start networking stop/waiting 

现在,对我来说,服务的状态已经停止。 但是当我平了另一台电脑,我得到了一个成功的答复。 那么它是不是真的停止了? 更重要的是,我做错了什么?

编辑

 daniel@FOOBAR:~$ sudo service networking status networking stop/waiting daniel@FOOBAR:~$ sudo service networking stop stop: Unknown instance: daniel@FOOBAR:~$ sudo service networking status networking stop/waiting daniel@FOOBAR:~$ sudo service networking start networking stop/waiting daniel@FOOBAR:~$ sudo service networking status networking stop/waiting 

所以你可以看到为什么我运行/etc/init.d/networking stop。 出于某种原因暴发户(这是什么“服务”是,对不?) stop工作。

cat /etc/hosts

 127.0.0.1 localhost 127.0.1.1 FOOBAR 198.3.9.2 FOOBAR #Added entry July 19 2011 # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 

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 # hostname FOOBAR auto eth0 iface eth0 inet static address 198.3.9.2 netmask 255.255.255.0 network 198.3.9.0 broadcast 198.3.9.255 gateway 198.3.9.15 

没有,我没有保存备份,这只是一个小的改变,所以我只是评论了旧的DHCP设置。

编辑我将所有设置恢复到原始设置并设置DHCP服务器。 “开始”networking做同样的事情。 我只能假设这是正常的,我只是不知道为什么。 它不能与configuration文件有关,因为它们已经被恢复。

使用/sbin/ifconfig查看你当前的networking状态。

使用/sbin/ifup <name>/etc/network/interfaces定义的/etc/network/interfaces 。 同样,使用/sbin/ifdown <name>将接口closures。


如果接口的实际状态与ifconfig不同,请执行以下操作:

不要在networking上做这件事。 做这个从控制台。 如果您丢失访问您的盒子您的血液在您的头上。

  1. 清除/etc/network/run/ifstate
  2. 对于该接口上的每个IP,运行/sbin/ip addr del 1.2.3.4/24 dev eth0 (显然使用适当的IP和接口名称)。
  3. 对于接口本身,运行/sbin/ip link set eth0 down (再次使用相应的接口名称)。

完成之后,您应该可以干净地使用/sbin/ifup <name>来使接口启动。

尝试

 sudo service network-interface restart INTERFACE=eth0 

编辑该命令以在必要时使用您的接口而不是eth0

(我用ifconfig检查过我的,但我的是。)

来源: http : //ubuntuforums.org/showthread.php?t=1706192