Linux静态iP设置
来源:互联网 发布:智程网络怎么样 编辑:程序博客网 时间:2024/05/19 14:51
系统环境:ubuntu 12.0 server
1,用ifconfig -a插卡网卡有几种类型。用ifconfig查看系统认出的网卡(本机是只用 lo , 没有eth0)
2,首先为了显示eth0。
#vi /etc/network/interfaces
在
auto lo
iface lo inet loopback
下行写入:
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.33
gateway 192.168.0.1
netmask 255.255.255.0
#network 192.168.0.0
#broadcast 192.168.0.255
3,#cd /etc/resolvconf/resolv.conf.d/
#vi base
添加 nameserver 8.8.8.8
nameserver 8.8.4.4
4,#sudo /etc/init.d/networking restart
重启网卡。
5,再ifconfig 一般就可以看到eth0网卡信息。(不行重启既可)
6,重启后可以查看resolv.conf
#cat /etc/resolv.conf
就看到了我们刚在固定的dns地址。(网上教程老是先改resolv.conf ,明明知道重启后会失效的。。。无语了)
************************************************************************
如果ifconfig -a 有eth0,还有eth1。如何区分有线网插在eth0还是eth1呢?
本人方法:修改/etc/network/interface
在
auto lo
iface lo inet loopback
下行写入:
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.33
gateway 192.168.0.1
netmask 255.255.255.0
#network 192.168.0.0
#broadcast 192.168.0.255
# The primary network interface
auto eth1
iface eth1 inet static
address 192.168.0.33
gateway 192.168.0.1
netmask 255.255.255.0
#network 192.168.0.0
#broadcast 192.168.0.255
然后#sudo /etc/init.d/networking restart
ifconfig 查看eth1是否出现(不行重启)
出现后:分别试试 #route add default gw 192.168.0.1 dev eth0 和#route add defualt gw 192.168.0.1 dev eth1(未差网线的会有提示,网管正确的无异常)
*****************************************************************************************************
如果是在局域网(网关:192.168.1.1.),想用DHCP 自动分配ip地址:
则修改vi /etc/network/interfaces
在
auto lo
iface lo inet loopback
下行写入:
# The primary network interface
auto eth0
iface eth0 inet dhcp
然后sudo /etc/init.d/networking restart
再用ifconfig 查看ip相关信息。(不行重启)
局域网出现ping不通外网:ping www.baidu.com 出现:unknow host
输入命令:#route add default gw 192.168.1.1 dev eth0 既可以解决。
但好像不能永久解决,你可以试试修改 /etc/init.d/resolvconf/resolv.conf.d/base 文件,添加一段
nameserver 192.168.1.1
重启网卡或者重启。
****************************************************************************************************
2014,9月1 &Am3
1,用ifconfig -a插卡网卡有几种类型。用ifconfig查看系统认出的网卡(本机是只用 lo , 没有eth0)
2,首先为了显示eth0。
#vi /etc/network/interfaces
在
auto lo
iface lo inet loopback
下行写入:
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.33
gateway 192.168.0.1
netmask 255.255.255.0
#network 192.168.0.0
#broadcast 192.168.0.255
3,#cd /etc/resolvconf/resolv.conf.d/
#vi base
添加 nameserver 8.8.8.8
nameserver 8.8.4.4
4,#sudo /etc/init.d/networking restart
重启网卡。
5,再ifconfig 一般就可以看到eth0网卡信息。(不行重启既可)
6,重启后可以查看resolv.conf
#cat /etc/resolv.conf
就看到了我们刚在固定的dns地址。(网上教程老是先改resolv.conf ,明明知道重启后会失效的。。。无语了)
************************************************************************
如果ifconfig -a 有eth0,还有eth1。如何区分有线网插在eth0还是eth1呢?
本人方法:修改/etc/network/interface
在
auto lo
iface lo inet loopback
下行写入:
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.33
gateway 192.168.0.1
netmask 255.255.255.0
#network 192.168.0.0
#broadcast 192.168.0.255
# The primary network interface
auto eth1
iface eth1 inet static
address 192.168.0.33
gateway 192.168.0.1
netmask 255.255.255.0
#network 192.168.0.0
#broadcast 192.168.0.255
然后#sudo /etc/init.d/networking restart
ifconfig 查看eth1是否出现(不行重启)
出现后:分别试试 #route add default gw 192.168.0.1 dev eth0 和#route add defualt gw 192.168.0.1 dev eth1(未差网线的会有提示,网管正确的无异常)
*****************************************************************************************************
如果是在局域网(网关:192.168.1.1.),想用DHCP 自动分配ip地址:
则修改vi /etc/network/interfaces
在
auto lo
iface lo inet loopback
下行写入:
# The primary network interface
auto eth0
iface eth0 inet dhcp
然后sudo /etc/init.d/networking restart
再用ifconfig 查看ip相关信息。(不行重启)
局域网出现ping不通外网:ping www.baidu.com 出现:unknow host
输入命令:#route add default gw 192.168.1.1 dev eth0 既可以解决。
但好像不能永久解决,你可以试试修改 /etc/init.d/resolvconf/resolv.conf.d/base 文件,添加一段
nameserver 192.168.1.1
重启网卡或者重启。
****************************************************************************************************
2014,9月1 &Am3
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
- C++ 中 make_pair 的简易实现
- Project Euler 8
- android adb常用指令
- Java 并发编程之任务取消(七)
- GTK3学习笔记4 Drawing
- Linux静态iP设置
- GA 跨域追踪
- Oracle 层次查询(Connect By)
- 微信公众平台消息类型处理php版(方蓓工作室)
- 【卡特兰数】【数论】
- Reverse Nodes in k-Group leetcode
- UVA10905
- HBase性能优化方法总结
- 【面试准备】堆排