Kali Linux 设置动/静态IP地址以及修改DNS

一. 设置IP地址

动/静态 IP 地址设置路径:

vim /etc/network/interfaces

1.1 动态IP

配置文件:

# 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 dhcp

dhcp 是自动获取 IP 地址。

1.2 静态IP

配置内容:

# 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.7.53
netmask 255.255.255.0
gateway 192.168.7.1

其中,static 为获取静态 IP;
address 为静态 IP 地址;
netmask 为子网掩码;
gateway 为网关。
网关为 192.168.7.1,则静态 IP 地址要为192.168.7.xxx 。

1.3 总结

auto lo 与 auto eth0 说明 lo 接口跟 eth0 接口会在系统启动时被自动配置;
iface lo inet loopback 将 lo 接口设置为一个本地回环( loopback )地址;
iface eth0 inet static 设置 eth0 接口具有一个静态的( static )IP配置,dhcp 为自动获取 IP。
address、 network、netmask、broadcast、gateway 分别设置 eth0 接口的 IP、网络号、掩码、广播地址和网关。
修改好 IP 之后要重启网卡:

/etc/init.d/networking restart

参考:Debian 系网络配置,更详细内容点击查看。

二. 修改DNS

路径:

cat /etc/resolv.conf 

内容:

domain lan
search lan
nameserver 8.8.8.8

/etc/resolv.conf 文件是 DNS 客户机配置文件,用于设置 DNS 服务器的 IP 地址及 DNS 域名,还包含了主机的域名搜索顺序。该文件是由域名解析器(resolver :一个根据主机名解析IP地址的库)使用的配置文件。
resolv.conf 的关键字主要有四个,分别是:

nameserver    //定义DNS服务器的IP地址
domain       //定义本地域名
search        //定义域名的搜索列表
sortlist        //对返回的域名进行排序

参考:DNS 域名解析的配置

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值