快速设置debian的静态IP

例如想要设置网络的信息如下

IP地址:192.168.1.1
子网掩码:255.255.255.0
网关:192.168.1.1

广播地址:10.10.10.255
DNS:114.114.114.114,114.114.115.115

我们需要编辑2个文件

/etc/network/interfaces(配置IP和网关)

/etc/resolv.conf(配置DNS服务器)

先vi /etc/network/interfaces



auto eth0 #开机自动连接网络
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static #static表示使用固定ip,dhcp表述使用动态ip(如果没有删除dhcp这一行,需要在前面增加#号注释,还有就是auto eht0如果没有设置重启后无法找到网络,一定注意!!)
address 192.168.1.1 #设置ip地址
netmask 255.255.255.0 #设置子网掩码
gateway 192.168.1.1 #设置网关

broadcase 0.0.0.0#设置广播地址(也可以不写)

在配置/etc/resolv.conf

vi /etc/resolv.conf

nameserver 192.168.1.1#设置首选dns
nameserver 114.114.114.114 #设置备用dns,我这里是给大家演示,我自己是使用的本机作为网关服务器,所以IP地址是本机

备用DNS可以填写也可以不填写看自己需求

service networking restart #重启网络 搞定!

未经允许不得转载:OZ分享-吉家大宝官方博客 » 快速设置debian的静态IP

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

置顶文章


Warning: error_log(/www/wwwroot/oowz.com/wp-content/plugins/spider-analyser/#log/log-0122.txt): failed to open stream: No such file or directory in /www/wwwroot/oowz.com/wp-content/plugins/spider-analyser/spider.class.php on line 2900