您的位置:首页 > 运维架构 > Linux

linux (debian) 配置静态ip

2017-07-07 09:32 453 查看
在局域网内使用动态ip分配,机器动态的获取

ip地址。可是我使用ssh登录的时候。总是断线。

后来发现,原来机器总是在两个ip地址192.168.2.203

和192.168.2.228之间切换。用ssh登录老师断线,实在

在是受不了了。所以决定配置静态ip。

配置静态ip涉及到两个文件,/etc/network/interface

和/etc/resolv.conf,两个文件的配置例如以下:

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

/etc/network/interface文件配置:

# 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

auto eth2

iface eth2 inet static

address 192.168.2.2 # 注 :静态ip必须在100之前

netmask 255.255.255.0

gateway 192.168.2.1

broadcast 192.168.2.255

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

/etc/resolv.conf文件配置:

nameserver 192.168.2.1 # 一般和gateway的地址是一致的

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

重新启动网络: sudo /etc/init.d/networking restart
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: