Kali Linux 网络配置
临时 IP 地址
以下操作,重启失效。
# 自动获取 IP 地址
dhclient eth0
# 指定 IP 地址
ipconfig eth0 192.168.1.10/24
# 指定网关
route add default gw 192.168.1.1
# 添加静态路由
route add -net 172.16.0.0/24 gw 192.168.1.100 eth0
# 查看路由表
netstat -nr
route -n
# 配置 DNS 服务器地址,也可以直接在配置文件中添加多个
echo nameserver 192.168.1.1 > /etc/resolv.conf
固定 IP 地址
# 编辑配置文件
vi /etc/network/interfaces
interfaces文件:
默认:
# 就是 127.0.0.1
auto lo
iface lo inet loopback
# eth0,默认使用 dhcp 自动获取
allow-hotplug eth0
iface eth0 inet dhcp
改成静态 IP:
auto eth0
iface eth0 inet static
address 192.168.20.1
netmask 255.255.255.0
gateway 192.168.20.2
# 网络地址
network 192.168.20.0
# 广播地址
broadcast 192.168.20.255
# 可以直接指定 DNS 服务器
dns-nameservers 192.168.1.1 192.168.1.2
# 当网卡启动后向网卡里添加静态路由
up route add-net 172.16.5.0/24 gw 192.168.10.100 eth1
# 当网卡关闭后删掉路由
down route del-net 172.4.0.0/24

浙公网安备 33010602011771号