• Linux_RHEL_设置网络


    目录

    Selinux

    是Linux的一种权限管理,可以有效限制Root权限。SELinux可能会使网络连接的相关服务无法访问,建议关闭。
    关闭SElinux
    #修改配置 永久关闭
    vim /etc/selinux/config
    SELINUX=disabled
    #SELINUX=permissive force enforce
    #命令行 临时关闭
    getenforce #enforcing
    setenforce 0
    getenforce #permissive

    Iptable

    iptable防火墙以后会详细介绍,前期实验建议关闭,会影响很多服务之间的通信。
    iptables -nvL #查看防火墙规则
    iptables -F #清空防火墙
    service iptables save
    service iptables restart

    NetworkManager

    关闭网络管理员 ,这是RHEL6很鸡肋的功能。
    service NetworkManager stop
    chkconfig NetworkManager off 禁止开机启动该服务

    基本网络配置

    1.ifconfig 显示当前网络设置
    2.关闭iptables
    3.关闭NetworkManager
    4.关闭Selinux

    5.编辑网卡
    vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=”eth0”
    HWADDR=”00:0C:29:64:13:00”
    NM_CONTROLLED=”no”
    ONBOOT=”yes”
    BOOTPROTO=static #设置静态方式获取IP,也可以是DHCP方式
    IPADDR=”192.168.1.181”
    NETMASK=”255.255.255.0” #地址掩码
    GATEWAY=”192.168.1.1” #网关
    DNS1=”192.168.1.181”
    5.service network restart #重启网络服务,使配置生效

    编辑网卡子接口

    实现一个MAC地址(网卡)可以对应多个IP地址。
    1.生成网卡子接口配置文件
    cp -p ifcfg-eth0 ifcfg-eth0:0
    2.编辑网卡子接口配置文件
    vim /etc/sysconfig/network-scripts/ifcfg-eth0:0
    DEVICE=”eth0:0”
    HWADDR=”00:0C:29:64:13:00”
    NM_CONTROLLED=”no”
    ONBOOT=”yes”
    IPADDR=”172.168.1.190”
    NETMASK=”255.255.255.0”
    GATEWAY=”172.168.1.1”
    DNS1=”192.168.1.181”

    ip指令

    ip addr show dev eth0 显示网卡中的ip
    ip addr add dev eth0 192.168.0.100/24 增加网卡ip
    ip addr del dev eth0 192.168.0.100/24 删除网卡ip

    ifconfig指令

    ifconfig eth0 172.16.0.100 netmask 255.255.0.0 临时设定网卡eth的IP和掩码
    ifconfig eth0 172.16.0.100/24 临时设定ip和24位掩码
    ifconfig eth0 up
    ifconfig eth0 down

    ifconfig eth0 | grep HWaddr 管道服务
    ifconfig eth0 down
    ifconfig eth0 hw ether 00:0C:29:64:13:01 硬件地址
    service network restart
    ifconfig eth0 hw ether 00:0C:29:64:13:00

    修改主机名

    vim /etc/sysconfig/network 永久修改主机名文件
    hostname www.jmilk.com

    服务端口

    Vim /etc/services
    cat /etc/services | grep ” 80/tcp”

    相关阅读:

  • 相关阅读:
    mysql触发器的实战经验
    mysql存储程序查看
    索引性能优化(待整理)
    MySQL性能测试工具
    列级触发器 SQL Server
    synthetic division
    This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its de
    mysql触发器和定时器
    数据库触发器有以下的作用
    mysql 日志
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13311045.html
Copyright © 2020-2023  润新知