• linux学习笔记基础篇(一)


    一、IP操作

    1、临时修改IP ,执行命令  ifconfig  网卡名称  新ip :例如 ifconfg  nescc 192.168.1.110 ,重启失效

    2、重启网络 ,执行命令 systemctl  restart network,如果是centOs6 则是 service network restart

    3、直接查看某个网卡ip ,执行命令 ifconfig 网卡名 ,例如 ifconfig ens33

    4、同时增加多个ip:ifconfig 网卡名:0 192.168.1.110 network 255.255.255.0 up

    5、删除ip:ifconfig 网卡名:0 del  192.168.1.110

    6、永久修改ip:文本形式修改:nmtui ,文件形式:vi /etc/sysconfig/network-scripts/ifcfg-网卡名

    7、查看网络服务状态 :systemctl status NetworkManager 只适用于7以上版本

    8、网络配置文件:ls /etc/sysconfig/network-scripts/,DNS文件 ls /etc/resolv.conf,设置主机和ip绑定文件 cat /etc/hosts,设置主机名 cat /etc/hostname

    二、防火墙操作

    1、查看防火墙状态 systemctl status firewalld

    2、关闭防火墙 systemctl stop firewalld.service

    3、启动防火墙 systemctl start firewalld.service

    4、开机不启动 systemctl disable firewalld.service

    5、开机启动 systemctl enable firewalld.service  如果是6的话 执行 chkconfig --list|grep network

    6、使用 getenforce命令判断防火墙开机状态,返回disabled 开机不启动,否则就是启动

    7、setenforce 0 临时开机不启动

    8、永久关闭 vi /etc/selinux/config 将SELINUX值改为disabled 修改完毕 执行reboot 命令重启

    9、开放22端口 

    iptables -A INPUT -p tcp --dport 22 -j ACCEPT
    iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
    再执行 iptables -L -n 命令查看有无添加进去。
    最后执行 service iptables save,保存操作

     10、禁止某个ip访问  iptables -A INPUT -p tcp -s 192.168.1.2 -j DROP ,再执行 service iptables save 保存操作

    11、删除某个规则 ,先进行查看 iptables -L -n --line-number,再执行 iptables -D INPUT 2,就可以删除num为2的那条规则 ,最后执行 service iptables save保存操作

  • 相关阅读:
    Mac基本操作记录
    flutter vscode+第三方安卓模拟器
    git一些基本操作
    获取点击元素的绝对位置
    windows下提交前检测操作
    VGG网络学习
    MySQL数据库中文乱码
    配深度学习环境中的小tips(tensorflow+anaconda+keras+cuda)
    Docker安装指定的anaconda
    yolov1阅读
  • 原文地址:https://www.cnblogs.com/szy-wang/p/8819106.html
Copyright © 2020-2023  润新知