如何在OSX上设置TUN接口的IP地址(无目的地址)?(How do I set an ip address for TUN interface on OSX (without destination

编程入门 行业动态 更新时间:2024-10-18 12:33:35
如何在OSX上设置TUN接口的IP地址(无目的地址)?(How do I set an ip address for TUN interface on OSX (without destination address)?)

如何在OSX上为TUN界面设置IP地址? 我无法弄清楚如何在没有指定目的IP的情况下为我的接口设置一个IP地址。 我不想这样做 - 我想或多或少地在稍后的时间点建立一个隧道到任意地址。 以前的问题是无益的:

有一个问题有一个不清楚的答案,所以我试着按照参考。 这个问题为tun设备设置了一个指向ip地址的点,所以它有一个目的地,这正是我不想要的。

在osxtuntap的页面上说:

ifconfig tap0 10.1.2.3 up

我无法在TUN界面的OSX 10.6上进行这项工作:

$ sudo ifconfig tun0 10.1.2.3 up ifconfig: ioctl (SIOCAIFADDR): Destination address required

添加网络掩码并没有帮助--OSX似乎需要一个目标地址:

$ ifconfig tun0 10.0.0.1/24 netmask 255.255.255.0 ifconfig: ioctl (SIOCAIFADDR): Destination address required

对于Linux,我知道它是如何工作的。 根据这个页面 ,你打开()该接口,并使用ip命令,并执行此操作,并且我已经完成了此操作,出现了零问题:

$ ip link set tun0 up $ ip addr add 10.0.0.1/24 dev tun0

我想要做的与我在Linux中可以做的是一样的。


编辑:

我正在写一个小型的UDP隧道应用程序。 像这样:

tun1 - > udp app#1 - > udp tunnel - > udp app#2 - > tun2

如果udp应用程序在不同的计算机上(比如说本地和远程),我想将它们各自的tun设备与一个ip地址关联起来,这样我就可以通过将数据包发送到删除机器上tun设备的ip地址。

为了借用linux教程中的更多内容,作者在本地和远程上设置了tun设备,并关联了ips,然后运行一个简单的隧道应用程序,然后ping通道的另一端:

[remote]# ip link set tun3 up [remote]# ip addr add 192.168.0.2/24 dev tun3 [remote]$ ./simpletun -i tun3 -s # server blocks waiting for the client to connect [local]# ip link set tun11 up [local]# ip addr add 192.168.0.1/24 dev tun11 [local]$ ./simpletun -i tun11 -c 10.2.3.4 # nothing happens, but the peers are now connected [local]$ ping 192.168.0.2

How do I set an IP address for a TUN interface on OSX? I cannot figure out how to set up an ip address for my interface without specifying a destination IP. I don't want to do that- I'm want to more or less build a tunnel to an arbitrary address at a later point in time. Prior questions which are unhelpful:

There's a question that has an unclear answer, so I tried following the reference. This question sets a point to point ip address for a tun device, so it has a destination, which is exactly what I don't want.

On the page for osxtuntap it says:

ifconfig tap0 10.1.2.3 up

I cannot make this work on OSX 10.6 for a TUN interface:

$ sudo ifconfig tun0 10.1.2.3 up ifconfig: ioctl (SIOCAIFADDR): Destination address required

Adding a netmask doesn't help- OSX seems to demand a destination address:

$ ifconfig tun0 10.0.0.1/24 netmask 255.255.255.0 ifconfig: ioctl (SIOCAIFADDR): Destination address required

For linux, I get how it works. According to this page, you open() the interface, and use the ip command, and do this, and I've done this before with zero issues:

$ ip link set tun0 up $ ip addr add 10.0.0.1/24 dev tun0

All I want to do is the same thing that I can do in linux.


EDIT:

I'm writing a little UDP tunnel app. Like so:

tun1 -> udp app #1 -> udp tunnel -> udp app #2 -> tun2

If the udp apps are on different computers (let's say local and remote), I'd like to associate their respective tun devices with an ip address, so I can send a packet from local to remote via the tunnel by sending the packet to the ip address of the tun device on the remove machine.

To borrow more from the linux tutorial, the author sets up a tun device on local and remote, associates ips, and runs a simple tunneling app, and then pings the other end of the tunnel:

[remote]# ip link set tun3 up [remote]# ip addr add 192.168.0.2/24 dev tun3 [remote]$ ./simpletun -i tun3 -s # server blocks waiting for the client to connect [local]# ip link set tun11 up [local]# ip addr add 192.168.0.1/24 dev tun11 [local]$ ./simpletun -i tun11 -c 10.2.3.4 # nothing happens, but the peers are now connected [local]$ ping 192.168.0.2

更多推荐

本文发布于:2023-07-04 17:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1026979.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:地址   接口   无目的   如何在   TUN

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!