日期:2014-05-16  浏览次数:20622 次

Oracle 管理之 Linux 网络基础
1、TCP/IP 网络配置文件
2、使用命令配置网络
3、网络诊断工具


TCP/IP 网络配置文件
IP配置文件:/etc/sysconfig/network-scripts/ifcfg-eth0
网管配置文件:/etc/sysconfig/network
域名解析:/etc/host.conf
主机配置:/etc/hosts
路由配置:/etc/resolv.conf
服务端口配置:/etc/services


网络接口启动脚本:
[root@asm ~]#  more /etc/sysconfig/network-scripts/ifcfg-eth0 
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.8.255
HWADDR=00:0C:29:8B:86:65
IPADDR=192.168.8.160
NETMASK=255.255.255.0
NETWORK=192.168.8.0
ONBOOT=yes


[root@asm ~]# more /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=asm.oracle.com
GATEWAY=192.168.8.1


/etc/hosts


该文件是系统本地的主机名称解析数据库


[root@asm ~]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
192.168.8.160   asm.oracle.com  asm


/etc/host.conf 文件用于指定如何解析主机名,可用选项:
order:设置主机名解析的可用方法及顺序,可用方法包括hosts(使用/etc/hosts文件进行解析)、bind
(使用DNS服务器解析)、nis(使用网络信息服务NIS解析)


multi:设置是否从 /etc/hosts 文件中返回主机的多个 IP 地址,取值为 on/off


/etc/resolv.conf 文件是 DNS (DNS域名服务的客户端配置文件):


[root@asm ~]# more /etc/resolv.conf
nameserver 192.168.8.11 
search oracle.com
domain oracle.com


/etc/services 设置网络服务默认使用的 TCP 或 UDP 端口




使用命令行工具或GUI工具配置 Linux 网络:
[root@asm ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:8B:86:65  
          inet addr:192.168.8.160  Bcast:192.168.8.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23894 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1864 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1708719 (1.6 MiB)  TX bytes:309503 (302.2 KiB)
          Interrupt:75 Base address:0x2000 


lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:18747 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18747 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1215290 (1.1 MiB)  TX bytes:1215290 (1.1 MiB)
          
[root@asm ~]# ifconfig eth0 192.168.8.161 netnask 255.255.255.0 up
[root@asm ~]# ifconfig eth0 192.168.8.160 netnask 255.255.255.0 up




[root@asm ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:8B:86:65  
          inet addr:192.168.8.160  Bcast:192.168.8.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24260 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2001 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1736070 (1.6 MiB)  TX bytes:327830 (320.1 KiB)