:em11: 最近总有好多人问怎么上网怎么配置,可我们答完了还是上不去 :em14: :em14: 因此我就找了篇关于网络的文章大家先学学打好基础 :em11: :em11: :em11: 见笑了 :mrgreen: :mrgreen:
第一章 网络地址和掩码
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.conf; it 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缺省地以本地服务器为目标。响应中包括目标服务器的名字和地址。
>是提示符,这意味着可以开始发送名字服务询问或配置。
请大家好好学习,在为新人指点,我们一起努力 :em11: :em11:
golden_armor 回复于:2004-10-21 23:17:02 |
真是世风日下阿 |
billquick 回复于:2004-10-22 00:41:12 |
thanks |
songyupo 回复于:2004-10-22 09:25:32 |
斑竹怎没给加个精, :em11: :em11: :mrgreen: :mrgreen: 谢谢斑竹支持 |
SUNfan 回复于:2004-10-22 09:37:30 |
UP
其实这些大家都知道一点,但是全面就很难说,希望做SA的朋友好好学习! |
ywsun 回复于:2004-10-22 09:46:57 |
不知道在做什么? |
roman_pan 回复于:2004-10-22 10:20:06 |
应该大力支持一下的 |
songyupo 回复于:2004-10-22 11:10:07 |
[quote:5c813099ea="SUNfan"]UP
其实这些大家都知道一点,但是全面就很难说,希望做SA的朋友好好学习![/quote:5c813099ea][b:5c813099ea]所以我把他全面的总结了一下[/b:5c813099ea][img][/img] |
harbor2002 回复于:2004-10-22 11:16:32 |
solaris9 里面resolv.conf 不在/etc 下吧 |
songyupo 回复于:2004-10-22 11:31:00 |
[quote:90ab20507a="harbor2002"]solaris9 里面resolv.conf 不在/etc 下吧[/quote:90ab20507a]是自己建的文件夹,里面没有要自己建明白了吗 |
Linux@初学者 回复于:2004-10-22 12:54:12 |
[quote:3e494defd5="songyupo"]亲约航ǖ奈募校锩婷挥幸约航靼琢寺餥/quote:3e494defd5]
是文件,不是文件夹! :em02: |
lonman 回复于:2004-10-22 16:05:29 |
很全面嘛,3X |
风之幻想 回复于:2004-10-22 17:00:14 |
好东西。 |
puma_soft 回复于:2004-10-22 17:10:59 |
已经打印出来,谢谢 |
mgsun 回复于:2004-10-22 17:42:30 |
3ks. 太及时 |
hrcxf 回复于:2004-10-22 21:46:46 |
很快又会有很多人问同样的问题的 |
zhangleii 回复于:2004-10-23 14:32:45 |
真是感谢! |
jackylau 回复于:2004-10-24 16:38:43 |
搞的不错。 |
jf408 回复于:2004-10-24 21:09:07 |
good |
smdlyu 回复于:2004-10-25 11:00:15 |
谢谢楼主,提供如此全面的网络配置,帮了大忙。。。 |
yangjunma 回复于:2004-10-26 09:18:33 |
:em02: :em02: :em02: 这么好的东东,应该项一下。偶正在准备学solaris |
llc107 回复于:2004-10-26 11:01:40 |
支持一下 |
Philmoon 回复于:2004-10-26 12:43:34 |
不错!一份很全面的参考资料了! |
joeandjane 回复于:2004-10-27 12:53:49 |
SOLARIS9下面,nslookup可以解析,但是还是不能上网?请问大家遇到过这种问题没有? |
icebreak 回复于:2004-10-28 10:31:12 |
好东西啊 |
gjmark 回复于:2004-10-28 11:23:43 |
支持一下!! |
songyupo 回复于:2004-10-28 12:56:06 |
[quote:3069e99733="joeandjane"]SOLARIS9下面,nslookup可以解析,但是还是不能上网?请问大家遇到过这种问题没有?[/quote:3069e99733]你的dns设了吗?网关写了吗 |
within0713 回复于:2004-11-06 21:37:02 |
好东西,3x |
hitzhou 回复于:2005-01-27 20:44:35 |
[quote:620f595fe3="songyupo"]dns设了吗?网关写了吗[/quote:620f595fe3]
我在resolv.conf已经配了nameserver,但是还是不能上网,但是可以利用nameserver里的地址解析 |
xjiang1_8699 回复于:2005-01-28 17:26:19 |
在论坛里见到不止n次了 |
kenny.ding 回复于:2005-01-28 18:09:41 |
顶一下! |
liucaomin 回复于:2005-02-25 15:33:54 |
有没有起用代理呢
路由是否正确 是否有生效 |
ux_jeep 回复于:2005-02-25 21:21:18 |
比如:
一新装solaris9环境,配置网络使之能上网,需要做哪些设置。 已知: IP地址 子网掩码 网关 DNS地址 |
songyupo 回复于:2005-02-25 22:19:42 |
[quote:e203b7661f="ux_jeep"]比如:
一新装solaris9环境,配置网络使之能上网,需要做哪些设置。 已知: IP地址 子网掩码 网关 DNS地址[/quote:e203b7661f]啊,你们看明白呀,加一个/etc/resolv.conf /etc/defaultrouter两个文件,改/etc/nsswitch.conf 就行了 |
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/