LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > Linux教程 >

Debian下设置 IP 地址、网关、DNS

时间:2015-07-07 09:19来源:未知 编辑:linuxeye 点击:
1、设置IP地址、网关 cp /etc/network/interfaces /etc/network/interfaces.bak # 备份原有配置文件 vi /etc/network/interfaces # 编辑网网卡配置文件 # The loopback network interface auto lo iface lo inet loopback # The prim
1、设置IP地址、网关
cp /etc/network/interfaces /etc/network/interfaces.bak  # 备份原有配置文件
vi /etc/network/interfaces   # 编辑网网卡配置文件

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0                       # 开机自动连接网络
allow-hotplug eth0
iface eth0 inet static       # static表示使用固定ip,dhcp表述使用动态ip
address 192.168.21.166   # 设置ip地址
netmask 255.255.255.0   # 设置子网掩码
gateway 192.168.21.2     # 设置网关

按 ESC 键,然后输入 :eq 保存并退出。

下面的版本便于复制, 因为配置文件里最好不要有中文:
# 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.21.166
netmask 255.255.255.0
gateway 192.168.21.1

2、设置dns
cp  /etc/resolv.conf /etc/resolv.conf.bak    # 备份原有dns配置文件
vi /etc/resolv.conf        # 编辑配置文件
nameserver 127.0.0.1
nameserver 8.8.8.8       # 设置首选dns
nameserver 8.8.4.4       # 设置备用dns

按 ESC 键,然后输入 :eq 保存并退出。

下面的版本便于复制, 因为配置文件里最好不要有中文:
nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4

3、重启网络
service networking restart   # 重启网络
至此,IP地址、网关、DNS配置完成,现在系统已经可以上网了。

转载请保留固定链接: https://linuxeye.com/Linux/2683.html

------分隔线----------------------------
标签:Debian
栏目列表
推荐内容