kali设置静态ip地址

本文介绍了在Kali Linux中设置静态IP地址的步骤,包括查看网卡、修改network配置文件、重启网络服务以及验证IP设置。通过修改配置文件并在网络服务重启后,系统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

简书原文

END.

微信公众号:程序员的一天
程序员的一天

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员的一天

~呀哈,感谢支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值