zoukankan      html  css  js  c++  java
  • 00-服务配置准备知识

    1.修改网络连接标识
    vim /etc/udev/rules.d/70-persistent-net.rules
    reboot

    2.修改启动运行级别
    vim /etc/inittab
    id:3:initdefault:
    reboot

    3.修改SSH远程连接
    vim /etc/ssh/sshd_config
    UseDNS no
    GSSAPIAuthentication no
    GSSAPICleanupCredentials no
    service sshd restart

    4.配置YUM仓库
    umount /dev/sr0
    mkdir /iso
    mount /dev/sr0 /iso
    vim /etc/yum.repos.d/dvd.repo
    [dvd]
    name=dvd
    baseurl=file:///iso
    gpgcheck=0
    yum clean all
    yum makecache
    yum repolist all

    5.配置开机自动挂载
    vim /etc/fstab
    /dev/sr0 /iso iso9660 defaults,ro 0 0
    mount -a

    6.关闭防火墙
    service iptables stop
    chkconfig iptables off

    7.关闭SELINUX
    getenforce
    setenforce 0
    vim /etc/selinux/config
    SELINUX=disabled
    reboot

    8.修改主机名
    hostname
    vim /etc/sysconfig/network
    reboot

    9.设置主机IP地址
    ifconfig eth0 A.B.C.D
    vim /etc/sysconfig/network-scripts/ifcfg-eth0
    service network restart

    10.服务器配置步骤
    (1) {检查,安装}服务软件包
    (2) 修改服务配置文件
    (3) 检测服务状态;启动服务&&开机启动
    (4) 调试||排错

    11.网络相关命令与工具
    ifconfig 查询和配置网卡
    格式1:ifconfig [interface]
    格式2:ifconfig interface address | options...
    options...
    up
    down
    netmask addr
    mtu N
    例如:
    # ifconfig
    # ifconfig eth0
    # ifconfig eth0 192.168.1.1
    # ifconfig eth0 192.168.1.1 netmask 255.255.255.128
    # ifconfig eth0:0 192.168.1.2
    # ifconfig eth0:0 down
    配置立即生效,重启失效

    ifup 启动网络接口
    格式:ifup IFACE
    例如:
    # ifup eth0

    ifdown 关闭网络接口
    格式:ifdown IFACE
    例如:
    # ifdown eth0

    route 查询和配置本地路由表
    格式1:route [-n]
    格式2: route {add | del} [-net|-host] target [netmask Nm] [gw Gw] [[dev] If]

    例如:
    # route -n
    Flags:
    U:有效路由
    H:主机路由
    G:网络路由
    R:路由重置(过程状态)
    D:动态路由
    M:路由修改(过程状态)
    !:无效路由

    # route add -net 192.168.100.0 netmask 255.255.255.0 dev eth0
    # route add -net 192.168.100.0 netmask 255.255.255.0 via 192.168.1.254
    # route add default gw 192.168.1.254

    注意删除路由表时,需要将路由表上面出现的信息都写入
    # route -n
    # route del -net 192.168.101.0 network 255.255.255.0 dev eth0

    ip命令
    格式1:ip route { list | flush }
    格式2:ip route { add | del } ROUTE
    例如:
    # ip route show
    # ip route add 192.168.100.0/24 via 192.168.1.254 dev eth0
    # ip route default via 192.168.1.254 dev eth0
    # ip route del 192.168.100.0/24

    dhclient 手动使用DHCP自动获得IP参数
    格式:dhclient [ -r | -x ] [ if0 [ ...ifN ] ]
    例如:
    # dhclient
    # dhclient eth0
    # dhclient -r

    ping 连通性测试
    格式:ping [ -c count] [ -s packetsize] [ -W timeout] destination
    例如:
    # ping -c 4 192.168.1.254
    # ping -W 2 192.168.1.254

    并发连接测试脚本
    # vim pingtest.sh
    !#/bin/bash
    network=192.168.1
    for host in $(seq1 254)
    do
    {
    ip=${network}.${host}
    ping -c 1 -W 1 $ip &> /dev/null
    if [ $? -eq 0 ]; then
    echo "$ip is UP."
    else
    echo "$ip ip DOWN."
    fi
    }&
    done
    wait
    echo "finish..."
    #此处列表也可写为`seq 1 254`或{1..254}

    变量名=赋值
    "" 弱引用
    '' 强引用
    `` 命令运行

    [] 测试

    $() 命令运行
    $[] 数值计算
    ${} 变量引用

    1> 正确输出重定向
    1>> 追加
    2> 错误输出重定向
    2>> 追加
    &> 正确和错误输出重定向
    /dev/null 黑洞
    /dev/zero 零发射器
    &> /dev/null 屏蔽屏幕显示

    traceroute 路由跟踪
    格式:traceroute [-n] host
    例如:
    # traceroute -n www.baidu.com

    netstat 端口查看
    格式:netstat [--tcp|-t] [--udp|-u] [--listening|-l] [--all|-a] [--numeric|-n] [--program|-p] [--route|-r]
    -t: TCP端口
    -u: UDP端口
    -n: 数字形式
    -l: 监听的端口
    -p: 显示PID和进程名称
    -a: 所有端口,包括TCP和UDP和正在通信连接的端口
    -r: 显示路由表
    例如:
    # netstat -rn 显示路由表
    # netstat -an 显示所有端口
    # netstat -tunlp 显示监听的TCP和UDP端口
    # netstat -tunap

    host 名称解析
    格式:host [-t type] {name} [server]
    例如:
    # host www.test.com
    # host www.baidu.com 8.8.8.8

    nslookup命令
    格式:nslookup [name | -] [server]
    例如:
    # nslookup www.test.com
    # nslookup 192.168.6.1
    # nslookup
    server
    set type=a[mx|ns]

    telnet 远程连接
    格式:telnet [host|IP [port]]
    例如:
    # telnet 192.168.6.1
    # telnet 192.168.6.1 110

    ftp
    格式:ftp [host|IP] [port]
    例如:
    # ftp 192.168.6.1

    你猜以下程序是干嘛的?
    pidgin
    elinks
    firefox
    mutt

  • 相关阅读:
    node lesson2
    二级联动(list对象中存list对象)
    Spring的注解@Qualifier注解
    @Service(value = "aaaa") 和@Service( "a")的区别
    oracle分页
    Oracle数据导入导出imp/exp
    oracle截取某个字符前面的字符串
    oracle中截取某个字符前面和后面的值
    解决Eclipse启动报错Failed to create the Java Virtual Machine
    成功秘诀就是拿出勇气和坚定的信念去做自己喜欢并且擅长的事情
  • 原文地址:https://www.cnblogs.com/freecd/p/8471302.html
Copyright © 2011-2022 走看看