• linux网络 (一):网络配置


    1.liunx网络

    1.1接口和命名规则

      eth[0-9]   以太网接口

      wlan[0-9]   无线网卡接口

      lo      本地回环接口

    1.2linux常规网络配置文件

      1. /etc/hosts       主机文件

      2. /etc/resolv.conf        DNS文件

      3. etc/sysconfig/network-scripts/ifcfg-eth0  网卡配置文件

    2.网络配置相关命令

    2.1.ifconfig

    ifconfig:用于配置和显示linux内核中网络接口的网络参数,包括ip地址、网络掩码、广播地址等。

    redhat网卡配置文件:/etc/sysconfig/network-scripts/ifcfg-eth0

    常用命令:

      1.启动/关闭网卡:     ifconfig eth0 down/up

      2.设置网络接口及掩码:   ifconfig eth0 192.168.1.1 netmask 255.255.255.0

      3.在一个网卡上增加多个ip:  ifconfig eth0:0 192.168.1.99

      4.修改MAC地址:      ifconfig eth0 hw ether 00:00:00:00:00:00:00           

      5.获得ip:            ifconfig | grep inet

    实例:

    2.2.route

    Redhat配置文件:/etc/sysconfig/netwrk-scripts/route-eth0

    route:用来显示和设置linux内核中的网络路由表

      1.显示路由表:      route -n

      2.查看缓冲表:      route -C

      3.添加路由:             route add[-net | -host] ... 

      4.删除路由:        route del[-net | -host] ...

    实例:

      route add -net 192.168.1.5 gw 192.168.1.1 

    2.3.ifdown/ifup

    ifdown/ifup:禁用或启用网络接口

      1.ifdown eth0  禁用网络接口eth0

      2.ifup eth0    激活网络接口eth0

    2.4.hostname

    Redhat主机名配置文件:/etc/sysconfig/network

    hostname:显示和设置linux系统的主机名称

    2.5.ip

    ip是iproute2软件包里的一个网络配置工具。

    常用命令:

    • ip link set dev NAME { up | down }           改变设备属性
    • ip link show DEVICE                                显示设备属性
    • ip addr { add | del }   dev NAME { local | peer | broadcast ..}                         添加/删除协议地址(IP/IPv6)
    • ip route { add | del | change | append | replace | monitor }                            改变路由属性
    2.6.重启网络服务

    service network restart

    /etc/init.d/network {start | stop | restart | status}

  • 相关阅读:
    OpenResty
    Jmeter
    kubernetes 中部署 metrics-server
    Jenkins 灰度
    socat管理haproxy以及haproxy调优
    代码质量测试工具SonarQube安装配置
    Jenkins+主从+Pipeline+Webhook
    xtrabackup 实现MySQL数据库备份
    idea Error:java: Compilation failed: internal java compiler error
    使用TableSnapshotInputFormat读取Hbase快照数据
  • 原文地址:https://www.cnblogs.com/smstars/p/3066585.html
Copyright © 2020-2023  润新知