如何开始在 Oracle Solaris 11 中配置网络

如何开始在 Oracle Solaris 11 中配置网络,第1张

修改主机名:

# svccfg-s system/identity:node setprop config/nodename="MYHOSTNAME"

另,显示属性

# svccfg-s system/identity:node listprop config

配置网卡

显示物理网卡 dladm

配置端口:

# ipadm create-ip net0

# ipadm delete-ip net0

修改IP地址:

# ipadm show-addr

ADDROBJ TYPE STATE ADDR

lo0/v4 static ok 127.0.0.1/8

net0/v4 static ok 10.0.0.14/24

# ipadm delete-addr net0/v4

# ipadm create-addr -T static -a local=192.168.19.77/24 net0

路由网关设置

# route –p show (显示路由设置)

# route –p add destination gateway (增加路由)

例如 route –p add10.1.16.0/24 192.168.19.1

一.识别网卡

1. 使用 /usr/X11/bin/scanpci 查看系统上的PCI设备:

....vendor 0x8086 device 0x1050 Intel Corporation PRO/100 VE Network Connection

2. 编辑/etc/driver_aliases,增加以下内容

iprb "pci8086,1050" (iprb是intel网卡的接口名,后面的id是刚刚用scanpic查到的 8086是venderid)

3. /boot/solaris/devicedb/master文件,加入以下内容:

pci8086,1050 pci8086,1050 net pci iprb.bef "Intel Pro/100 VE Network Connection"

4. 运行devlinks

5. 运行touch /reconfigure

6.编辑/etc/hostname.iprb0, 文件内容是你的主机名。(如果用的是IPv6,那么要编辑的是hostname6.iprb0文件)

7. 重新启动系统

二.配置相关文件

1.配置网关,新建/etc/defaultrouter文本文档,内容为网关ip:

192.168.1.1(换为你的网关地址,局域网路由器一般是这个)

2.配置DNS:

修改/etc/nsswitch.conf ,将 hosts: files 这一行 修改为 hosts: files dns

新建 /etc/resolv.conf文本文档,内容为:nameserver 202.96.128.166 (换为你的DNS)

3.修改/etc/hosts文件,内容:

127.0.0.1 localhost

192.168.1.2 loghost

4.设置掩码:修改/etc/netmasks文件

最后添加一行:192.168.1.1 255.255.255.0

5.重启

6.ifconfig iprb0 unplumb down 停用网卡

ifconfig iprb0 plumb up 激活网卡

ifconfig iprb0 dhcp 配置动态分配ip

Solaris网络管理员培训

第一章 网络地址和掩码

1. /etc/hostname.interface

Interface是网卡的型号,有le、hme等。Le是十兆网卡,hme为百兆网卡等等。后面跟一个数字,第一个十兆网卡为le0,第二个为le1;第二个百兆网卡为hme0,第二个为hme1等等。

文件的内容是这块网卡的名字,如Sunrise、Sunny。

#more /etc/hostname.le0

Sunrise

# more /etc/hostname.hme0

Sunny

2. /etc/hosts文件

系统名与IP地址的映射

与/etc/hostname.interface 协同工作,配置本机网卡地址

# more /etc/hosts

127.0.0.1 localhost loghost

172.16.255.1 Sunrise

172.18.255.1 Sunny

系统名不是机器名,机器名是唯一的,要更改机器名,用命令:hostname。

有了/etc/hostname.interface和/etc/hosts两个文件,系统就知道如何配置网卡了,如第一个百兆网卡的名字是Sunny,其对应的地址是172.18.255.1。

3. /etc/netmasks文件

将网络的IP地址与网络地址联系一起,划分子网

如果是标准网段,则不需要配置

标准网段:

A类网:0-127(127用于本地地址) 掩码:255..0.0.0

B类网:128-191 掩码:255.255.0.0

C类网:192-223 掩码:255.255.255.0

D类网:224-254(用于多址广播)

要配一个B类地址:172.16.255.1掩码为:255.255.255.0,则在/etc/netmasks文件中写:172.16.255.0 255.255.255.0

4. ifconfig命令

检测网络端口状态

#ifconfig -a

配置网络端口地址

#ifconfig le0 172.16.255.1 netmask 255.255.255.0

配置网络端口状态

#ifconfig le0 up/down

配置网络端口是否可用

#ifconfig le0 plumb/unplumb

5. ping命令

检测网络状态

测试网络速度

第二章 网络服务

1. /etc/services文件

网络服务协议的端口号

网络协议的服务类型

#cat /etc/inet/services

ftp-data 20/tcp

ftp 21/tcp

telnet 23/tcp

smtp 25/tcp mail

sunrpc 111/udp rpcbind

sunrpc 111/tcp rpcbind

每个TCP/IP应用层服务如(FTP、Telnet)都在传输层有一个端口号。/etc/services文件包含了每个能识别出的服务协议所对应的静态端口号。应用应使用唯一分配的端口号向传输提供者和远程对等实体标识自己。

文件中每一项都由服务名及其相关的端口号、传输协议提供者组成。有些服务可以在TCP和UDP上都可以运行。这时,此服务被列出两次。

2. /etc/inetd.conf文件

# cat /etc/inet/inetd.conf

ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd

telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd

login stream tcp nowait root /usr/sbin/in.rlogind in.rlogind

talk dgram udp wait root /usr/sbin/in.talkd in.talkd

...

UNIX并不是让每种服务的守护进程都在自己的端口上等待请求,而是将代表各个服务守护进程等待请求的任务交给一个叫inetd的服务进程。这样就可以大大减少对系统资源的占用。只有当超级服务进程发现一个服务请求时,它才调用该服务的守护进程。/etc/inetd.conf配置文件允许inetd在启动时决定自己将代表哪些服务等待服务请求。如果一种服务的守护进程没有包含在inetd.conf文件中,那么当inetd接收到该服务的请求时,会把该请求丢弃。

文件的字段:

service_name 这是文件/etc/services中列出的服务的标志符。

socket_type 用来标志使用的数据传输服务的类型。

proto 标识传输协议的名字。是UPD和TCP

flags 可以被设为"等待"和"非等待"。如果被设为"等待" 状态,inetd在恢复监听端口上的其他请求时,必须等待服 务协议释放将其连接到网络的连接。"非等待"可以使 inetd立即监听其他的请求。大多数TCP协议的采用"非等 待"方式,而UDP采用"等待"方式。

user 表示调用服务的用户名。

server_pathname 表示inetd在响应相关服务请求时必须调用的 服务程序的完整路径名。

Args 该域包括服务的程序所使用的命令行参数。即以程序名开 始,然后跟随用户设置的参数。

第三章 路由和网关

1. /etc/defaulrouter文件

配置缺省网关

防止不必要的路由进程

适用于只有一个路由器通向其它网段

单一路由占用较小的路由表资源

该文件保存了缺省路由得信息。系统安装时并没有该文件,是用户自己创建的。文件内容是缺省路由的地址。

#cat /etc/defaultrouter

172.16.255.254

优点:

占用资源少,只有一条路由条目。

2. /etc/gateways文件

路由表文件

net gateway metric

dest. net 目标网段

router 下一跳路由器的地址

count 跳数

3. route命令

route add|delete [host|net] destination [gateway ]

Add a route

#route add net 128.50.3.0 192.168.1.1 1

Delete a route

#route delete net 128.50.2.0 192.168.12.2

4. 查看路由表

# netstat -r

Routing Table:

Destination Gateway Flags Ref Use Interface

----------- ---------- ----- --- --- ---------

localhost localhost UH 0 2272 lo0

202.96.0.0 192.168.12.1 U 3 562 le0

10.103.0.0 192.168.12.2 U 3 562 le0

#

Destination 目标网络或主机

Gateway 转发数据包的主机

Flags 这条路由的状态,这个参数有这样几个选项:

U 端口处于激活状态(up)

H 目标是个主机,而不是网段

Ref 同一个网络接口地址拥有的路由条目数量

Use 通过这条路由的包数量,对于localhost来说,这个数字代表 所有接收的包数量

Interface 路由的网络接口

第四章 DNS客户端的设置

1. /etc/resolv.conf文件

记录DNS服务器的地址和域名

关键字:

domainname

nameserver

# more /etc/resolv.conf

nameserver 172.16.255.3

domainname sunrise.com.cn

2. /etc/nsswitch.conf文件

记录主机名的搜索顺序等信息

# more /etc/nsswitch.conf

#

# /etc/nsswitch.dns:

#

# An example file that could be copied over to /etc/nsswitch.confit uses

# DNS for hosts lookups, otherwise it does not use any other naming service.

#

# "hosts:" and "services:" in this file are used only if the

# /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.

passwd: files

group: files

# You must also set up the /etc/resolv.conf file for DNS name

# server lookup. See resolv.conf(4).

hosts: files dns

ipnodes: files

将这个文件的hosts记录配置成hosts: files dns

3. nslookup命令

用于查询DNS服务器

用于验证客户端的设置

用于下载DNS数据库

# nslookup

Default Server: ns.zjhzptt.net.cn

Address: 202.96.96.68

>www.sun.com

Server: ns.zjhzptt.net.cn

Address: 202.96.96.68

Non-authoritative answer:

Name: www.sun.com

Address: 192.18.97.241

>

启动时,nslookup缺省地以本地服务器为目标。响应中包括目标服务器的名字和地址。

>是提示符,这意味着可以开始发送名字服务询问或配置

最后还要配置一下hosts文件,将服务器地址加近来


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/11125119.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存