zoukankan      html  css  js  c++  java
  • kali_网络配置

    前提

    查看设置的vmware网络模式

    NAT模式

    1.打开虚拟网络编辑器

    2.管理员更改设置

    3.根据自己的需要更改虚拟机的网段

    4.设置网关IP

    5.查看物理机上的虚拟网络适配器是否启动(很多时候虚拟机的网络出现问题就是这个导致的)

    6.进入kali虚拟机设置网络
    vim打开网络配置文件

    root@kali:~# vim /etc/network/interfaces
    

    按i写入如下的配置文件,保存退出

    source /etc/network/interfaces.d/*
    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet static
    address 你的IP地址
    netmask 你的子网掩码
    gateway 你的网关
    nameserver 你的DNS地址
    

    然后重启网络,生效配置

    root@kali:~# systemctl restart networking
    
    

    临时配置网络(重启系统就会失效)

    临时设置IP地址

    root@kali:~# ifconfig eth0 192.168.139.222/24
    
    

    临时设置网关地址

    root@kali:~# route add default gw 192.168.139.140
    
    

    配置DNS地址

    root@kali:~# echo nameserver 8.8.8.8 >/etc/resolv.conf
    
    

    脚本

    在测试情况中,可能需要频繁的修改网络设置,这里我写的有一个简单的脚本

    #!/bin/bash
    net_path=/etc/network/interfaces
    
    echo -e "e[1;32;41m The default network acquisition mode is static acquisition, if you want to modify it, please enter DHCPe[0m"
    read connection
    if [ "$connection"  = "DHCP" ];then
        connection="dhcp"
    else
        connection="static"
    fi
    echo -e "e[1;32;41m Please enter IP addresse[0m"
    read IP
    echo -e "e[1;32;41m If you need to specify a DNS address press y,Or press any key to use the default address(114.114.114.114)e[0m"
    read DNS_var
    if [ "$DNS_var"  = "y" ];then
        echo "OK!Please enter DNS address"
    	read DNS
    else
        DNS=114.114.114.114
    fi
    echo -e "e[1;32;41m Please enter Gateway addresse[0m"
    read GATEWAY
    echo -e "e[1;32;41m If you need to specify a subnet mask press y,Or press any key to use the default address(255.255.255.0)e[0m"
    read NETMASK_var
    if [ "$NETMASK_var"  = "yes" ];then
        echo "OK!Please enter subnet mask address"
    	read NETMASK
    else
        NETMASK=255.255.255.0
    fi
    
    
    echo "source /etc/network/interfaces.d/*" >$net_path
    echo "auto lo" >>$net_path
    echo "iface lo inet loopback" >>$net_path
    echo "auto eth0" >>$net_path
    echo "iface eth0 inet "$connection"" >>$net_path
    echo "address "$IP"" >>$net_path
    echo "netmask "$NETMASK"" >>$net_path
    echo "gateway "$GATEWAY"" >>$net_path
    echo "nameserver "$DNS"" >>$net_path
    
    systemctl restart networking
    
    ping -c 1 www.baidu.com >/dev/null 2>&1
    if [ "$?" = 0 ];then
        echo "Your network configuration is successful!"
    else
        echo "YYour network configuration failed, please check and try again!"
    fi
    

    拉到kali里面运行就好了

  • 相关阅读:
    数据仓库的直白概述
    Google准实时数据仓库Mesa(一)
    活动预告丨易盾CTO朱浩齐将出席2018 AIIA大会,分享《人工智能在内容安全的应用实践》
    3招搞定APP注册作弊
    【0门槛】PR稿的自我修养
    Hive中文注释乱码解决方案(2)
    Hive中文注释乱码解决方案
    网易考拉Android客户端网络模块设计
    有运气摇号来不及挑选?网易有数帮你科学选房
    selenium下拉框踩坑埋坑
  • 原文地址:https://www.cnblogs.com/hxlinux/p/14456855.html
Copyright © 2011-2022 走看看