1. Check the network card:
root@kali:~# ifconfig
If the ifconfig command is not available, use apt-get to install:
root@kali:~# apt-get -y install net-tools
Or use ip addr to view:
root@kali:~# ip addr
2. Modify the network configuration file
File location:
/etc/network/interfaces
Original file content (before modification):
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
File content after modification:
# 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
Mainly add the following content at the end of the file:
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. Restart the network:
service networking restart
或者:
systemctl restart networking
# start、status、stop、restart分别表示:启动、查看状态、停止、重启
View network status:
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. View ip
You can see that the ip has become the ip we set
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
END.
WeChat public account: a programmer's day