免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
KaLi添加路由問題,設(shè)置開機(jī)自啟動腳本rc.local文件不存在問題

由于項(xiàng)目需要,需要在kali上添加一條路由,并且保證重啟后仍然生效。

經(jīng)查找發(fā)現(xiàn)有兩種可行的方法:

1、修改/etc/network/interfaces配置文件,添加一行,如:

up route add -net 10.105.10.0 netmask 255.255.255.255 gw 192.168.1.1 eth0

-net指這是一條網(wǎng)絡(luò)路由(ip地址主機(jī)位為0)

gw指下一跳

2、修改rc.local,添加:

route add -net 192.168.114.0/24 dev eth0

route add -net 192.168.114.0/24 gw 192.168.3.254

那么,為了保證重啟仍然生效需要將它寫入rc.local配置文件。

--------------------------------------------分割線--------------------------------------------------------

第一個方法添加路由后,使用route命令查看路由表;的確是添加了,但實(shí)際測試中發(fā)現(xiàn)沒有起作用,目標(biāo)仍然不可訪問。(玄學(xué)問題)

第二個方法遇到一個問題,kali把rc.local“ 服務(wù)化”了,并沒有rc.local配置文件怎么辦呢?

解決方法:

vim /etc/systemd/system/rc-local.service

將內(nèi)容替換為

[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local

[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99

[Install]
 WantedBy=multi-user.target

然后

touch /etc/rc.local(正常情況下/etc/rc.local并不是配置文件本身,而是/etc/rc.d/rc.local的軟連接;但徒增麻煩不建議那么做)

記得賦予執(zhí)行權(quán)限

chmod +x /etc/rc.local

vim /etc/rc.local

添加

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

exit 0 

插入腳本就在exit 0之前即可

重啟rc-local服務(wù)

systemctl restart rc-local.service

設(shè)置開機(jī)自啟動

systemctl enable rc-local

---------------------------------------你以為這樣就結(jié)束了?-------------------------------------------

我將添加路由的shell命令添加到rc.local之后重啟發(fā)現(xiàn),并沒有成功添加路由;

執(zhí)行systemctl status rc-local.service發(fā)現(xiàn)報(bào)錯顯示“網(wǎng)絡(luò)未啟動”。。。。

在檢查了各種錯誤之后我斷定,是啟動優(yōu)先級沒有起作用

無奈曲線解決,在啟動腳本里添加sleep命令延遲執(zhí)行腳本

詳見我的shell腳本:

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
/usr/local/bin/route-eth0
exit 0 
/usr/local/bin/route-eth0:
#!/bin/bash
sleep 15s
route add -net 192.168.114.0/24 dev eth0
exit0

最終問題解決,目的是給更多人帶來方便。

 
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
在centos中 將apache httpd 服務(wù)加入系統(tǒng)服務(wù)
CentOS設(shè)置hadoop程序開機(jī)自啟動的方法
Linux的rc.local自啟動服務(wù)
linux服務(wù)自動啟動功能
apache的源碼安裝詳細(xì)過程全紀(jì)錄
Redis雙機(jī)熱備方案
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服