• linux tips


    • 允许 IP 转发
      # To enable IP packet forwarding please edit /etc/sysctl.conf with your editor of choice and set:
      
      # Controls IP packet forwarding
      net.ipv4.ip_forward = 1
      
      
      # You can then verify your settings with:
      /sbin/sysctl -p
      View Code
    • 创建虚拟 IP 地址
      cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33:0
      
      # 删除
      ONBOOT=YES
      
      # 添加
      ONPARENT=YES
      
      # 目的:父接口启动时才启动。
      # ONBOOT=YES 会把父接口启动
      View Code
    • 单网卡多Ip
      TYPE=Ethernet
      PROXY_METHOD=none
      BROWSER_ONLY=no
      BOOTPROTO=static
      DEFROUTE=yes
      IPV4_FAILURE_FATAL=no
      IPV6INIT=no
      IPV6_AUTOCONF=yes
      IPV6_DEFROUTE=yes
      IPV6_FAILURE_FATAL=no
      IPV6_ADDR_GEN_MODE=stable-privacy
      NAME=ens32
      UUID=0d6815b3-b400-47cf-a418-df8c914568a0
      DEVICE=ens32
      ONBOOT=yes
      IPADDR0=192.168.10.130
      NETMASK0=255.255.255.0
      GATEWAY0=192.168.10.1
      IPADDR1=172.20.10.3
      NETMASK1=255.255.255.240
      GATEWAY1=172.20.10.1
      View Code

      ip地址设置

      ip addr add 172.20.10.5/28 dev enp0s3
      View Code

      默认路由添加

      ip route add default via 172.20.10.1
      View Code
    • 关闭ipv6
      为内核加载添加选项“ipv6.disable=1”
      vi /etc/default/grub
      grub2-mkconfig -o /boot/grub2/grub.cfg
      View Code


      模块加载级别关闭ipv6

      vi /etc/sysctl.conf
      net.ipv6.conf.all.disable_ipv6 = 1
      net.ipv6.conf.default.disable_ipv6 = 1
      sysctl -p
      View Code

      运行时关闭 IPv6

      echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
      echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
      View Code
      sysctl -w net.ipv6.conf.all.disable_ipv6=1
      sysctl -w net.ipv6.conf.default.disable_ipv6=1
      View Code
    • 修改运行级别
      systemctl set-default multi-user
      systemctl get-default
      View Code
    • 修改时区
      cat /etc/timezone
      timedatectl list-timezones
      timedatectl list-timezones | grep -i shanghai
      timedatectl set-timezone Asia/Shanghai
      View Code

      时间同步

      timedatectl set-ntp true
      View Code

    CentOS

    一切代码都是为了生活,一切生活都是调剂
  • 相关阅读:
    面试题:区分List中remove(int index)和remove(Object obj)
    Collection的子接口之一:List 接口
    面试题:ArrayList、LinkedList、Vector三者的异同?
    jdk 5.0 新增的foreach循环(用于遍历集合、数组)
    Iterator迭代器接口(遍历Collection的两种方式之一)
    哈希值
    Collection接口方法
    集合框架的概述
    注解(Annotation)
    System类、Math类、BigInteger与BigDecimal的使用
  • 原文地址:https://www.cnblogs.com/argor/p/7919015.html
Copyright © 2020-2023  润新知