debian 设置ip

设置ip  打开 /etc/network/interfaces 添加如下内容

luomb@debian:/$ vi /etc/network/interfaces
M
# 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
#allow-hotplug eth0
#iface eth0 inet dhcp
auto eth0
iface eth0 inet static
address 192.168.50.165
netmask 255.255.255.0
gateway 192.168.50.1

设置DNS服务器:

 luomb@debian:/$ vi /etc/resolv.conf
nameserver 202.96.128.86
nameserver 8.8.8.8

用下面的命令使网络设置生效

sudo /etc/init.d/networking restart

也可以在命令行下直接输入下面的命令来获取地址

sudo dhclient eth0

IP关闭

ifconfig eth0 up

IP打开

ifconfig eth0 down

猜你喜欢

转载自meaijuan.iteye.com/blog/1608198