博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ubuntu配置和修改IP地址
阅读量:7240 次
发布时间:2019-06-29

本文共 1831 字,大约阅读时间需要 6 分钟。

1、修改配置文件/etc/network/interfaces

:~# sudo gedit /etc/network/interfaces

添加以下内容:

auto eth0                  #设置自动启动eth0接口
iface eth0 inet static     #配置静态IP
address 192.168.11.88      #IP地址
netmask 255.255.255.0      #子网掩码
gateway 192.168.11.1        #默认网关

2、修改DNS

sudo gedit /etc/resolve.conf

nameserver 127.0.0.1 #记得加上

nameserver 8.8.8.8 #当地dns服务器(用ipconfig /all 查看本地dns,第一个dns是默认的,共有2个dns)

注:#后面的注释信息不要加进去。

3、重启网络,使配置生效

sudo /etc/init.d/networking restart

4、查看ip是否配置成功 :~# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0c:29:2d:89:40 
          inet addr:192.168.11.88  Bcast:192.168.11.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe2d:8940/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:223 errors:0 dropped:0 overruns:0 frame:0
          TX packets:253 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:24219 (24.2 KB)  TX bytes:22960 (22.9 KB)
          Interrupt:19 Base address:0×2024

lo        Link encap:Local Loopback 

          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:48 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3964 (3.9 KB)  TX bytes:3964 (3.9 KB)

:~#

注:红字加粗“192.168.11.88”跟上面配置的ip一样,表示ip配置成功。

如果网络无法启动或不稳定,可尝试如下操作:

gedit /etc/NetworkManager/NetworkManager.conf

managed=false设置成managed=true

 

Ubuntu的参数保存在文件 /etc/network/interfaces中,默认使用dhcp,内容如下:

# The primary network interface

auto eth0

iface eth0 inet dhcp

 

静态ip的如下:

(1)编辑 /etc/network/interfaces

1.1)将dhcp 一行屏蔽

# The primary network interface

auto eth0

#iface eth0 inet dhcp

 

1.2)添加和静态ip有关的参数

# The primary network interface

iface eth0 inet static

address 192.168.0.10

netmask 255.255.255.0

gateway 192.168.0.1

 

(2)编辑 /etc/resolv.conf,dns

nameserver 202.96.134.133

nameserver 202.106.0.20

 

(3)执行下面两个命令,启用新

$sudo ifdown eth0

$sudo ifup eth0

转载地址:http://geybm.baihongyu.com/

你可能感兴趣的文章
在Windows Mobile和Wince(Windows Embedded CE)下使用.NET Compact Framework进行GPS NMEA data数据分析的开发...
查看>>
网络基础知识:(一)网络分层和网络设备
查看>>
android布局 - fill_parent/match_paren/wrap_content的区别
查看>>
论go语言中goroutine的使用
查看>>
解决td标签上的position:relative属性在各浏览器中的兼容性问题
查看>>
H5图片上传插件
查看>>
iOS5问题汇总
查看>>
[译]Chipmunk教程 - 3 初始化
查看>>
也谈WebKit、Gecko使用图形库
查看>>
6个寓言故事
查看>>
android用sharepreference保存输入框中的内容
查看>>
C# 鼠标穿透窗体功能
查看>>
Windows平台上C++开发内存泄漏检查方法
查看>>
hbase 0.96 java 示例
查看>>
XML与Web Service基础知识点
查看>>
visual studio使用技巧
查看>>
C#几个经常犯错误汇总
查看>>
jQuery data(key, value)函数 在匹配的元素上随心所欲的存放数据 (2
查看>>
经典排序之 冒泡排序
查看>>
PHP 定义栈结构,实现min函数,获取栈最小元素,要求时间复杂度为O(1)
查看>>