在Linux中,iproute
是一個(gè)用于配置、控制以及查詢Linux內(nèi)核中IP路由表的工具。它可以幫助你進(jìn)行網(wǎng)絡(luò)維護(hù),包括配置網(wǎng)絡(luò)接口、設(shè)置路由規(guī)則、查看網(wǎng)絡(luò)狀態(tài)等。以下是一些使用iproute
進(jìn)行網(wǎng)絡(luò)維護(hù)的基本命令:
配置網(wǎng)絡(luò)接口:
ip addr
sudo ip link set <interface> up
sudo ifconfig <interface> up
或使用 ip link set <interface> up
(在某些Linux發(fā)行版中)sudo ip link set <interface> down
sudo ifconfig <interface> down
或使用 ip link set <interface> down
設(shè)置路由規(guī)則:
ip route
sudo ip route add <destination> via <gateway> dev <interface>
sudo ip route del <destination> via <gateway> dev <interface>
sudo ip route add default via <gateway> dev <interface>
sudo ip route replace <old_route> <new_route>
查看網(wǎng)絡(luò)狀態(tài):
sudo netstat -tuln
或 ss -tuln
sudo netstat -tunlp
或 ss -tunlp
ip route
或 route -n
(在某些Linux發(fā)行版中)其他網(wǎng)絡(luò)維護(hù)命令:
sudo arp -a
或 sudo ip neigh show
sudo systemctl restart networking
或類似的命令cat /proc/sys/net/ipv4/ip_forward
(如果已啟用IP轉(zhuǎn)發(fā))請(qǐng)注意,這些命令可能因Linux發(fā)行版而異。建議查閱你所使用的Linux發(fā)行版的文檔以獲取更準(zhǔn)確的命令和用法信息。此外,進(jìn)行網(wǎng)絡(luò)維護(hù)時(shí)務(wù)必謹(jǐn)慎操作,以免意外中斷網(wǎng)絡(luò)連接或造成其他安全問題。