首页 > 系统服务 > 详细

Linux网络属性配置详解

时间:2015-10-09 18:23:12      阅读:210      评论:0      收藏:0      [点我收藏+]

一、配置主机接入TCP/IP网络

路由:

    主机路由:host

    网络路由:net

    默认路由(网关):default

DNS服务器:

    主DNS服务器

    备用DNS服务器

主机名:


配置IP:

网络设备如何表示:

内核识别设备:驱动

设备:别名

以太网设备:ethX,

PPP网络:pppX

本地回环:lo

ip配置在内核上,显示在网卡上

静态指定:

        IP/Netmask

动态配置:

        DHCP服务器

        Dynamic Host Configuration Protocol

1)用户空间工具

立即通知内核生效,关机失效

ifconfig

ip

2)网络设备服务配置文件

长久有效

3)GUI/TUI

用户空间的命令行工具:立即生效,但不会长久有效

ifconfig

iproute2(ip,ss)


ifconfig


ifconfig(ip addr,ip link)   显示所有活动接口的相关信息

ifconfig Interface  仅显示指定接口的相关信息

ifconfig Interface Address

                   IP/MASK

                         长格式:255,255.0.0

                                ifconfig Interface Ip netmask MASK

                           CIDR:16(1的个数)                          

                                 ifconfig Interface IP/MASK

[root@localhost ~]# ifconfig eth0 192.168.100.10 netmask 255.255.255.0
[root@localhost ~]# ifconfig eth0 192.168.100.100/24

route              


route(ip route)   显示路由信息

             -n  使用数字格式显示,不反解地址到主机名

route add -host HOST_IP gw Next_Hop [dev Device]

          -net  Net_ADDR gw Next_Hop [dev Device]

          -net  0.0.0.0 目标地址为任意地址

route del -host HOST_IP

          -net Net_ADDR

[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.100.0   *               255.255.255.0   U     0      0        0 eth0
[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
                                                U表示启用状态   度量值:0表示到达该网络不需要经过路由器
                                                G表示默认网关
                                                H表示主机路由                            [root@localhost ~]# route add -net 172.16.0.0/16 gw 192.168.100.1
[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.100.0   *               255.255.255.0   U     0      0        0 eth0
172.16.0.0      192.168.100.1   255.255.0.0     UG    0      0        0 eth0
[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.100.100  192.168.100.2   255.255.255.255 UGH   0      0        0 eth0
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
172.16.0.0      192.168.100.1   255.255.0.0     UG    0      0        0 eth0
[root@localhost ~]# route add -net 0.0.0.0 gw 192.168.100.3
[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.100.100  192.168.100.2   255.255.255.255 UGH   0      0        0 eth0
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
172.16.0.0      192.168.100.1   255.255.0.0     UG    0      0        0 eth0
0.0.0.0         192.168.100.3   0.0.0.0         UG    0      0        0 eth0
[root@localhost ~]# route add default gw 192.168.100.4
[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.100.100  192.168.100.2   255.255.255.255 UGH   0      0        0 eth0
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
172.16.0.0      192.168.100.1   255.255.0.0     UG    0      0        0 eth0
0.0.0.0         192.168.100.4   0.0.0.0         UG    0      0        0 eth0
0.0.0.0         192.168.100.3   0.0.0.0         UG    0      0        0 eth0


DNS服务器指向

配置文件:/etc/resolv.conf

最多三个:

nameserver DNS_SERVER_IP


CentOS 5/6:

服务脚本:/etc/rc.d/init.d/network

CentOS 6:

服务脚本:/etc/rc.d/init.d/NetworkManager

Linux网络属性配置详解

原文:http://xiexiaojun.blog.51cto.com/2305291/1701296

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!