zoukankan      html  css  js  c++  java
  • 网络

    1.临时配置网络(ip,网关,dns)+永久配置

    #修改IP
    [root@python-web3 ~]# ifconfig ens33 192.168.16.88/24
    #修改网关
    [root@python-web3 ~]# route add default gw 192.168.16.1 netmask 255.255.255.0
    #增加dns
    [root@python-web3 ~]# echo "nameserver 202.106.0.20" >> /etc/resolv.conf
    
    #永久配置
    [root@web01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
    TYPE=Ethernet
    BOOTPROTO=dhcp
    IPADDR=192.168.123.123
    NETMASK=255.255.255.0
    GATEWAY=192.168.123.1
    DNS1=202.106.0.20
    DEFROUTE=yes
    PEERDNS=yes
    PEERROUTES=yes
    IPV4_FAILURE_FATAL=no
    NAME=ens32
    UUID=9eff3909-2614-4df9-80c9-a6a7d9f1eeee
    DEVICE=ens33
    ONBOOT=yes
    [root@web01 ~]# systemctl restart network
    

    02.为集群内的机器设定主机名,利用/etc/hosts文件来解析自己的集群中所有的主机名,相应的,集群的配置应该改成使用主机名的方式

    [root@bogon ~]# hostnamectl set-hostname oldboy
    [root@bogon ~]# hostnamectl set-hostname oldgirl
    
    [root@oldboy ~]# echo "192.168.8.8       oldboy" >> /etc/hosts
    [root@oldboy ~]# echo "192.168.8.9       oldgirl" >> /etc/hosts
    

    03.ssh登录,scp上传、下载,ssh秘钥登录,修改ssh server端的端口为8888然后进行登录和scp测试

    #ssh登scp录
    bogon:~ centos$ ssh root@192.168.16.116
    root@192.168.16.116's password:
    Last login: Tue Mar 21 17:04:28 2017 from 192.168.16.117
    
    #scp上传
    [root@oldboy ~]# scp /etc/passwd root@oldgirl:/tmp
    The authenticity of host 'oldgirl (192.168.16.171)' can't be established.
    ECDSA key fingerprint is 0b:68:fe:1d:66:4f:00:e9:92:da:8f:2f:65:f8:b9:90.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'oldgirl,192.168.16.171' (ECDSA) to the list of known hosts.
    root@oldgirl's password:
    passwd                                                                                          100% 1451     1.4KB/s   00:00
    
    #scp下载
    [root@oldboy ~]# scp  root@oldgirl:/etc/passwd /tmp/
    root@oldgirl's password:
    passwd                                                                                          100% 1451     1.4KB/s   00:00
    
    #ssh秘钥登录
    #服务端创建密钥
    [root@oldboy ~]# ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    97:68:03:f7:2a:5c:78:d3:48:81:0b:92:5a:ed:14:31 root@oldboy
    The key's randomart image is:
    +--[ RSA 2048]----+
    |   oEo ..        |
    |  + +..  .       |
    | o + ...o        |
    |.   . .= = .     |
    |      . S =      |
    |     . + =       |
    |      o .        |
    |       .         |
    |                 |
    +-----------------+
    #服务端将私钥传到客户端
    [root@oldboy ~]# ssh-copy-id -i oldgirl
    The authenticity of host 'oldgirl (192.168.16.171)' can't be established.
    ECDSA key fingerprint is 0b:68:fe:1d:66:4f:00:e9:92:da:8f:2f:65:f8:b9:90.
    Are you sure you want to continue connecting (yes/no)? yes
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    root@oldgirl's password:
    
    Number of key(s) added: 1
    
    Now try logging into the machine, with:   "ssh 'oldgirl'"
    and check to make sure that only the key(s) you wanted were added.
    
    #连接oldgirl
    [root@oldboy .ssh]# ssh oldgirl
    Last login: Tue Mar 21 17:26:49 2017 from 192.168.16.117
    
    
    #加端口远程
    [root@oldboy .ssh]# ssh oldgirl -p 8888
    Last login: Tue Mar 21 18:21:17 2017 from oldboy
    
    #加端口传输
    [root@oldboy .ssh]# scp -P 8888 /etc/passwd oldgirl:/mnt/
    passwd                                                                                          100% 1451     1.4KB/s   00:00
    

      

  • 相关阅读:
    appium 环境安装windows
    解决windows7无法连接CentOS7系统中oracle问题:ORA-12514 TNS 监听程序当前无法识别
    linux系统(CentOS7)虚拟机上安装oracle 11g,解决oracle图形界面卡住无法点击next问题
    python自动化测试框架学习
    VSCode + GDBServer 远程调试C/C++流水账
    IDEA 16注册
    VS2008非托管C++调用wcf(WebService)服务
    python 从数据库表生成model
    2015年工作总结
    dlib库学习之一
  • 原文地址:https://www.cnblogs.com/golangav/p/6595243.html
Copyright © 2011-2022 走看看