设置linux静态IP
来源:互联网 发布:手机吉他软件下载 编辑:程序博客网 时间:2024/05/16 12:29
Ubuntu 默认是DHCP自动获取IP。设定好静态IP,重启了也会变。
Ubuntu的网络配置信息是保存在 /etc/network/interfaces 文件中,使用Vim打开配置文件,默认是自动获取IP的配置.如下:
# The primary network interface
auto eth0
iface eth0 inet dhcp
下面我们将其设置成静态IP.
第一步:屏蔽掉自动获取IP的设置
iface eth0 inet dhcp将这一行屏蔽掉
修改之后的内容如下:
# The primary network interface
auto eth0
#iface eth0 inet dhcp
第二步:添加静态IP的信息
# The primary network interface
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
1。设定IP
sudo gedit /etc/network/interfaces
auto lo
iface lo inet loopback #lo 是本地回环地址:127.1
auto eth0
iface eth0 inet static
address 192.168.1.152
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255 #设定eth0的IP
这样,IP并没有立即生效。
sudo /etc/init.d/networking restart
2。这时候就能ping到局域网中的电脑了。但是上不了Internet,是因为没有设置DNS的原因。DNS信息保存在/etc/resolv.conf中,一旦更改,立即生效。
sudo gedit /etc/resolv.conf
nameserver 208.67.222.222
nameserver 208.67.220.220
现在可以上网了。
附网卡设置相关命令:
查看网卡信息: ifconfig
设定一个网卡IP:ifconfig eth1 192.168.1.10 netmask 255.255.255.0
重启网卡使设定生效:sudo /etc/init.d/networking restart
Ubuntu的网络配置信息是保存在 /etc/network/interfaces 文件中,使用Vim打开配置文件,默认是自动获取IP的配置.如下:
# The primary network interface
auto eth0
iface eth0 inet dhcp
下面我们将其设置成静态IP.
第一步:屏蔽掉自动获取IP的设置
iface eth0 inet dhcp将这一行屏蔽掉
修改之后的内容如下:
# The primary network interface
auto eth0
#iface eth0 inet dhcp
第二步:添加静态IP的信息
# The primary network interface
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
1。设定IP
sudo gedit /etc/network/interfaces
auto lo
iface lo inet loopback #lo 是本地回环地址:127.1
auto eth0
iface eth0 inet static
address 192.168.1.152
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255 #设定eth0的IP
这样,IP并没有立即生效。
sudo /etc/init.d/networking restart
2。这时候就能ping到局域网中的电脑了。但是上不了Internet,是因为没有设置DNS的原因。DNS信息保存在/etc/resolv.conf中,一旦更改,立即生效。
sudo gedit /etc/resolv.conf
nameserver 208.67.222.222
nameserver 208.67.220.220
现在可以上网了。
附网卡设置相关命令:
查看网卡信息: ifconfig
设定一个网卡IP:ifconfig eth1 192.168.1.10 netmask 255.255.255.0
重启网卡使设定生效:sudo /etc/init.d/networking restart
0 0
- Linux设置静态IP
- Linux静态IP设置
- Linux静态IP设置
- Linux静态IP设置
- Linux静态IP设置
- Linux静态IP设置
- Linux静态IP设置
- linux 设置静态IP
- Linux静态IP设置
- linux设置静态ip
- linux 静态ip 设置
- Linux静态IP设置
- Linux设置静态ip
- Linux静态iP设置
- Linux静态IP设置
- linux静态ip设置
- Linux静态IP设置
- Linux 设置静态IP
- ViewPager,Bundle,类的解析
- Two Substrings
- Android自定义View学习笔记04
- poj 3468 A Simple Problem with Integers(线段树区间更新)
- 新手报到
- 设置linux静态IP
- Preparing Olympiad
- Linux 压缩与解压缩相关
- php本地文件上传到远程服务器
- 线程间通讯和等待唤醒机制
- java内置数据结构--Map典型应用
- Android 后台Service : 向服务器发送心跳包
- OJ刷题---简单密码破解
- 内核中的中断函数request_irq()