Debian_修改IP地址或DNS

Debian_修改IP地址或DNS
Debian_修改IP地址或DNS

Debian 修改IP地址或DNS

IP地址配置文件: /etc/network/interfaces

如果ping不通自己IP则使用

ifconfig lo up

进行启用即可

// 动态DHCP获得

# 启动系统激活设备

# Loop回环地址

auto lo

iface lo inet loopback

# 启动系统激活设备

# 网卡eth0设置为DHCP类型

auto eth0

iface eth0 inet dhcp

// 静态Static获得

# 启动系统激活设备

# Loop回环地址

auto lo

iface lo inet loopback

# 启动系统激活设备

# 网卡eth0设置为Static类型

auto eth0

iface eth0 inet static

# 指定IP地址、子网掩码、广播、网关address 192.168.0.1

netmask 255.255.255.0

network 192.168.0.0

broadcast 192.168.0.255

gateway 192.168.0.1

# 指定DNS服务器地址

dns-nameservers 202.103.0.117

dns-search https://www.360docs.net/doc/1e9603875.html,

========================

DNS服务器配置文件: /etc/resolv.conf

// 必须设置.否则无法访问任何URL

nameserver 202.103.0.117

nameserver 211.95.193.97

例子:

# 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 static

address 192.168.0.190

netmask 255.255.255.0

gateway 192.168.0.1

# dns-* options are implemented by the resolvconf package, if installed #dns-nameservers 202.96.128.166

#dns-nameservers 202.96.134.133

debian 网络设置

三个配置文件 configure file:

/etc/hostname

/etc/network/interfaces //最好把DNS comment

/etc/resolv.conf //dns server

ifconfig

ifconfig -a

ifconfig eth0 up

ifconfig eth0 down

一、使用命令设置ubuntu的ip地址

1. 设置IP

ifconfig eth0 203.171.239.155 netmask 255.255.255.224

这样就算设置好了网卡eth0的IP地址和子网掩码

2. 设置网关 sudo route add default gw 20

3.171.239.129

3. 设置DNS 修改/etc/resolv.conf,在其中加入 nameserver DNS的地址1 nameserver DNS 的地址2 完成。

不过,这样设置之后,下次开机时候似乎IP又不存在了。

编辑文件/etc/network/interfaces:

并用下面的行来替换有关eth0的行:

# The primary network interface - use DHCP to find our address

auto eth0

iface eth0 inet dhcp

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

sudo /etc/init.d/networking restart

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

sudo dhclient eth0

静态IP设置:

bjcl:~# vi /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

#allow-hotplug eth0

iface eth0 inet static

address 192.168.1.10

netmask 255.255.255.0

gateway 192.168.1.1

bjcl:~# /etc/init.d/networking restart

Reconfiguring network interfaces...done.

DNS服务器设置:

bjcl:~# vi /etc/resolv.conf

nameserver 192.168.1.10

nameserver 202.106.46.151

相关主题
相关文档
最新文档