window查看ip:ipconfig
window查看路由:route print
window添加路由:route add 10.5.0.0 mask 255.255.0.0 -p 10.87.22.254
window删除路由:route delete 10.5.0.0 mask 255.255.0.0 -p 10.87.22.254
window路由追踪:tracert 10.5.5.1
window查看dns服务器:nslookup
window刷新dns:
输入:ipconfig /flushdns 释放DNS缓存;
输入:netsh winsock reset 重置Winsock目录;
mac查看ip信息:ipconfig
mac查看路由:netstat -nr
mac添加路由:route add -net 10.5.0.0/16 10.87.22.254
mac删除路由:route delete -net 10.5.0.0/16 10.87.22.254
mac查看dns:cat /etc/resolv.conf
mac刷新dns缓存:
sudo killall -HUP mDNSResponder
echo macOS DNS Cache Reset
- (mac添加永久路由要用下面的方式:
-
- ```
- $ networksetup -listallnetworkservices #查看网口设备
- $ networksetup -setadditionalroutes "Ethernet" 10.188.12.0 255.255.255.0 192.168.8.254
- 10.73.82.0 255.255.225.0 192.168.8.254 #添加路由,会覆盖,所以需要添加多条路由的话,一次性添加,这里添加了2条路由
- $ networksetup -setadditionalroutes Ethernet #清空路由
- $ networksetup -getadditionalroutes Ethernet #查看路由
- ```
-
- )
linux查看ip:ifconfig 或者ip a
linux路由追踪:traceroute 10.5.5.1
linux添加路由 route add -net 10.5.0.0/16 gw 10.87.22.254
linux查看dns:cat /etc/resolv.conf
linux刷新dns:linux本身没有dns缓存服务,如果有开启相关dns服务,grep dns服务后重启即可;
nmcli命令配置IP
|
假设DNS是200.200.10.199
|
linux添加永久路由:
在/etc/sysconfig/static-routes文件里面写入:
如果该文件不存在,则手动创建,添加内容格式为:
参照/etc/init.d/network文件里面的shell语句:
- ```
- # Add non interface-specific static-routes.
-
- if [ -f /etc/sysconfig/static-routes ]; then
-
- grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
-
- /sbin/route add -$args
-
- done
-
- fi
- ```
则,如果要添加一条静态路由,命令为:
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth1
那么,在/etc/sysconfig/static-routes文件中添加格式为:
any net 192.56.76.0/255.255.255.0 gw 192.56.76.254 dev eth0