Tag: router

为使用JSch通过SSH执行的命令提供输入/子命令

我正在尝试使用Jcraft Jsch库通过Java应用程序管理路由器。 我正在尝试通过TFTP服务器发送Router Config。 问题出在我的Java代码中,因为这适用于PuTTY。 这是我的Java代码: int port=22; String name =”R1″; String ip =”192.168.18.100″; String password =”root”; JSch jsch = new JSch(); Session session = jsch.getSession(name, ip, port); session.setPassword(password); session.setConfig(“StrictHostKeyChecking”, “no”); System.out.println(“Establishing Connection…”); session.connect(); System.out.println(“Connection established.”); ChannelExec channelExec = (ChannelExec)session.openChannel(“exec”); InputStream in = channelExec.getInputStream(); channelExec.setCommand(“enable”); channelExec.setCommand(“copy run tftp : “); //Setting the ip of TFTP […]

如何在Java中确定路由器/网关的IP?

如何在Java中确定路由器/网关的IP? 我可以轻松地获得我的IP。 我可以使用网站上的服务获取我的互联网IP。 但是如何确定网关的IP? 如果你了解自己的方式,这在.NET中有点容易。 但是你如何用Java做到这一点?