kali設置靜態ip地址


1、查看網卡:

root@kali:~# ifconfig

如果ifconfig命令不可用,使用apt-get安裝:

root@kali:~# apt-get -y install net-tools

或者使用ip addr查看:

root@kali:~# ip addr

2、修改network配置文件

文件位置:

/etc/network/interfaces

原始文件內容(修改前):

root@kali:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

修改后文件內容:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static  
address 192.168.0.66
netmask 255.255.255.0
gateway 192.168.0.1

主要是在文件末尾增加以下內容:

auto eth0  //指定網卡(根據ifconfig結果修改)
iface eth0 inet static  //啟動靜態ip
address 192.168.0.66  // 設置靜態ip
netmask 255.255.255.0  //子網掩碼
gateway 192.168.0.1  //指定網關

3、重啟網絡:

service networking restart
或者:
systemctl restart networking

# start、status、stop、restart分別表示:啟動、查看狀態、停止、重啟

查看networking狀態:

root@kali:~# systemctl status networking
● networking.service - Raise network interfaces
     Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
     Active: active (exited) since Mon 2020-07-20 13:06:57 CST; 22s ago

# 看到active (exited)表示正常啟動了

4、查看ip

可以看到ip變成了我們設置的ip

root@kali:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.66  netmask 255.255.255.0  broadcast 192.168.0.1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM