[Kali] 設定 Kali Linux 取得 DHCP IP

[Kali] 設定 Kali Linux 取得 DHCP IP

今天的訓練課程中,要跑一個 Kali Linux~

之前就有裝過,網路沒什麼問題,不過這次的 Kali Linux 是講師提供的,

不知道為什麼一開始是連不上網的…

 

對於 Linux 的網路設定算是蠻不熟的 (都是有 UI 設定才會用),

找到了 Setup DHCP or static IP address from command line in Linux 這篇很有用,

照著做之後,果然成功讓網卡拿到了 DHCP 的 IP 囉~

 

1. 重新啟動網路相關服務

執行下面的指令,重啟 networking 和 network-manager 等服務:

/etc/init.d/networking stop
/etc/init.d/networking start
/etc/init.d/network-manager stop
/etc/init.d/network-manager start

 

2. 設定使用 DHCP

打開 /etc/network/interfaces 檔案,看一下 eth0 的設定,

像我的預設是 iface eth0 inet static,把它改成 dhcp:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
# Change "static" to "dhcp" below and restart to enable DHCP
#iface eth0 inet static
iface eth0 inet dhcp
# This is an autoconfigured IPv6 interface
iface eth0 inet6 auto

 

3. 啟用 eth0 網卡

執行 ifup eth0 把網卡叫起來~

文章裡有寫說也可以用 ifconfig eth0 up,不過在我的 Kali Linux 裡面是無效的,要用 ifup 才行:

 

網卡起來之後,再用 ifconfig 確定有拿到 IP 囉:

root@kali:~/lab/day1# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:c4:68:ec
inet addr:192.168.27.131  Bcast:192.168.27.255  Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec4:68ec/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:5528 errors:0 dropped:0 overruns:0 frame:0
TX packets:1023 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3282583 (3.1 MiB)  TX bytes:90769 (88.6 KiB)
Interrupt:19 Base address:0x2000

 

(本頁面已被瀏覽過 4,635 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料