ubuntu网络配置初步/etc/network

本文详细介绍了Ubuntu系统的网络配置,包括Ethernet接口地址、IP地址设定(使用ip, ifconfig and route工具)、DHCP动态IP、静态IP配置、环回地址以及Name Resolution。还讲解了网络故障排除的基础知识,如ifconfig、route命令的使用,以及如何通过修改/etc/network/interfaces文件来设置静态IP。此外,文章提到了网络服务设置和网络故障排查的基本步骤,以及实战中的网络配置操作。" 132821619,19687622,PPF方法在物体识别与6D位姿估计中的应用,"['计算机视觉', '深度学习', '3D识别', '物体检测', '位姿估计']
摘要由CSDN通过智能技术生成

索引 说明
网络配置常用 网络接口设定,IP地址设定,MAC与接口名修改,DHCP动态IP,静态IP,命名主机名,环回地址设定
IP网络基础 IP网络初级知识,底层网络设置,DHCP配置网络接口,PPP,WLANi等配置
常用配置命令 常用配置命令
实战  
网络故障排除基础  


网络配置:

1.Ethernet Interfaces网络接口地址:


Ethernet interfaces are identified by the system using the naming convention of ethX, where X represents a numeric value. The first Ethernet interface is typically identified as eth0, the second as eth1, and all others should move up in numerical order.


查找方式:


ifconfig -a | grep eth eth0      Link encap:Ethernet  HWaddr 00:15:c5:4a:16:5a


或者#sudo lshw -class network


网络即可逻辑命名或者MAC地址设定:/etc/udev/rules.d/70-persistent-net.rules,NAME,ATTR{address}分别代表逻辑命名与MAC地址。


SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:c5:4a:16:5a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:c5:4a:16:5b", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


网络接口设定工具:


sudo apt-get install ethtool


sudo ethtool eth0


2. IP地址设定:工具ip, ifconfig and route,


sudo ifconfig eth0 10.0.0.100 netmask 255.255.255.0


ifconfig eth0

修改默认网关


sudo route add default gw 10.0.0.1 eth0

查看修改


route -n

配置DNS服务。


If you require DNS for your temporary network configuration, you can add DNS server IP addresses in the file/etc/resolv.conf. The example below shows how to enter two DNS servers to/etc/resolv.conf, which should be changed to servers appropriate for your network. A more lengthy description of DNS client configuration is in a following section.


nameserver 8.8.8.8

nameserver 8.8.4.4

清除所有IP配置ip addr flush eth0



3. DHCP Client: Dynamic IP Address Assignment (DHCP Client)动态IP


To configure your server to use DHCP for dynamic address assignment, add the dhcp method to the inet address family statement for the appropriate interface in the file/etc/network/interfaces.The example below assumes you are configuring your first Ethernet interface identified as eth0.

auto eth0

iface eth0 inet dhcp

By adding an interface configuration as shown above, you can manually enable the

interface through the ifup command which initiates the DHCP process via dhclient.


sudo ifup eth0

sudo ifdown eth0

 

4.静态IP:

配置文件:/etc/network/interfaces

auto eth0

iface eth0 inet static

address 10.0.0.100

netmask 255.255.255.0

gateway 10.0.0.1

然后

sudo ifup eth0

sudo ifdown eth0


5.环回地址:Loopback Interface

环回地址的标识为:lo,IP地址为:127.0.0.1

查看:ifconfig lo

配置/etc/network/interfaces:

auto lo

iface lo inet loopback


6.Name Resolution


处理从IP地址到主机名的映射。


DNS client配置:


/etc/resolv.conf


a server on the domain "example.com" and using two public DNS servers.


search example.com

nameserver 8.8.8.8

nameserver 8.8.4.4


search example.com sales.example.com dev.example.com

nameserver 8.8.8.8

nameserver 8.8.4.4


静态主机名:


配置文件:/etc/hosts,IP到主机名的映射


127.0.0.1 localhost

127.0.1.1 ubuntu-server

10.0.0.11 server1.example.com server1 vpn

10.0.0.12 server2.example.com server2 mail

10.0.0.13 server3.example.com server3 www

10.0.0.14 server4.example.com s

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值