Bright Zhao
2017-May-26 01:30 UTC
What/why this event happens: Can't write to Linux tun/tap device (tun mode) /dev/net/tun: Input/output error
Hi, All Due to some routing rotation purpose, I use crontab to add below info: 0 * * * * echo Subnet = 54.169.128.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp 0 * * * * echo Subnet = 54.169.0.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp 1 * * * * /usr/sbin/tincd -n myvpn -k 1 * * * * /usr/sbin/tincd -n myvpn --debug=3 30 * * * * sed -i '/54.169.128.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp 30 * * * * sed -i '/54.169.0.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp 31 * * * * /usr/sbin/tincd -n myvpn -k 31 * * * * /usr/sbin/tincd -n myvpn --debug=3 But after it get runs, the tinc log shows everything fine, but some how it get below error message, is it an accidental error, or is there anything wrong? Can't write to Linux tun/tap device (tun mode) /dev/net/tun: Input/output error
Bright Zhao
2017-May-26 01:33 UTC
What/why this event happens: Can't write to Linux tun/tap device (tun mode) /dev/net/tun: Input/output error
Should I change to this in order to avoid the issue? 0 * * * * echo Subnet = 54.169.128.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp 0 * * * * echo Subnet = 54.169.0.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp 1 * * * * /usr/sbin/tincd -n myvpn -k 2 * * * * /usr/sbin/tincd -n myvpn --debug=3 30 * * * * sed -i '/54.169.128.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp 30 * * * * sed -i '/54.169.0.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp 31 * * * * /usr/sbin/tincd -n myvpn -k 32 * * * * /usr/sbin/tincd -n myvpn --debug=3> On 26 May 2017, at 9:30 AM, Bright Zhao <startryst at gmail.com> wrote: > > Hi, All > > Due to some routing rotation purpose, I use crontab to add below info: > > 0 * * * * echo Subnet = 54.169.128.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp > 0 * * * * echo Subnet = 54.169.0.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp > 1 * * * * /usr/sbin/tincd -n myvpn -k > 1 * * * * /usr/sbin/tincd -n myvpn --debug=3 > > 30 * * * * sed -i '/54.169.128.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp > 30 * * * * sed -i '/54.169.0.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp > 31 * * * * /usr/sbin/tincd -n myvpn -k > 31 * * * * /usr/sbin/tincd -n myvpn --debug=3 > > > But after it get runs, the tinc log shows everything fine, but some how it get below error message, is it an accidental error, or is there anything wrong? > > Can't write to Linux tun/tap device (tun mode) /dev/net/tun: Input/output error > > >
Guus Sliepen
2017-May-26 10:03 UTC
What/why this event happens: Can't write to Linux tun/tap device (tun mode) /dev/net/tun: Input/output error
On Fri, May 26, 2017 at 09:30:44AM +0800, Bright Zhao wrote:> Due to some routing rotation purpose, I use crontab to add below info: > > 0 * * * * echo Subnet = 54.169.128.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp > 0 * * * * echo Subnet = 54.169.0.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp > 1 * * * * /usr/sbin/tincd -n myvpn -k > 1 * * * * /usr/sbin/tincd -n myvpn --debug=3 > > 30 * * * * sed -i '/54.169.128.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp > 30 * * * * sed -i '/54.169.0.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp > 31 * * * * /usr/sbin/tincd -n myvpn -k > 31 * * * * /usr/sbin/tincd -n myvpn --debug=3This is not the right way to do it. Cronjobs are being run in parallel. So if you both stop and start tinc at the same time, there is no guarantee that it will happen in the right order. The easiest way is to create two scripts, one that adds the Subnets and the other that removes them, and the other that adds them. Another issue is that with tinc 1.0, the -k option sends a TERM signal to the running tinc daemon, but it might take a little time before it actually stops. So add a sleep command inbetween, or check for /var/run/tinc.myvpn.pid to disappear. -- Met vriendelijke groet / with kind regards, Guus Sliepen <guus at tinc-vpn.org> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://www.tinc-vpn.org/pipermail/tinc/attachments/20170526/5e388849/attachment.sig>
Bright Zhao
2017-May-26 13:10 UTC
What/why this event happens: Can't write to Linux tun/tap device (tun mode) /dev/net/tun: Input/output error
Hi, Guus Thanks a lot for your suggestion, actually I did something else as below. But one question here is if I don’t add "/sbin/ifconfig myvpn 10.0.0.1 netmask 255.255.255.0”, it seems the crontab wouldn’t trigger tinc-up, and then the ip addr of myvpn wouldn’t be configured, then it will prompt the error of "Can't write to Linux tun/tap device (tun mode) /dev/net/tun: Input/output error” So I have to manually add that ifconfig command, so how can I avoid to do that, and let the tincd to invoke the tinc-up script? crontab -e (under root): 0 * * * * /root/add.sh >> /tmp/out.log 2>&1 30 * * * * /root/remove.sh >> /tmp/out.log 2>&1 /root/add.sh: #!/bin/sh echo Subnet = 54.169.128.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp echo Subnet = 54.169.0.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp /usr/sbin/tincd -n myvpn -k sleep 1s /usr/sbin/tincd -n myvpn --debug=3 /sbin/ifconfig myvpn 10.0.0.1 netmask 255.255.255.0 /root/remove.sh: #!/bin/sh sed -i '/54.169.128.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp sed -i '/54.169.0.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp /usr/sbin/tincd -n myvpn -k sleep 1s /usr/sbin/tincd -n myvpn --debug=3 /sbin/ifconfig myvpn 10.0.0.1 netmask 255.255.255.0> On 26 May 2017, at 6:03 PM, Guus Sliepen <guus at tinc-vpn.org> wrote: > > On Fri, May 26, 2017 at 09:30:44AM +0800, Bright Zhao wrote: > >> Due to some routing rotation purpose, I use crontab to add below info: >> >> 0 * * * * echo Subnet = 54.169.128.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp >> 0 * * * * echo Subnet = 54.169.0.0/17 >> /etc/tinc/myvpn/hosts/aws_sgp >> 1 * * * * /usr/sbin/tincd -n myvpn -k >> 1 * * * * /usr/sbin/tincd -n myvpn --debug=3 >> >> 30 * * * * sed -i '/54.169.128.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp >> 30 * * * * sed -i '/54.169.0.0\/17/d' /etc/tinc/myvpn/hosts/aws_sgp >> 31 * * * * /usr/sbin/tincd -n myvpn -k >> 31 * * * * /usr/sbin/tincd -n myvpn --debug=3 > > This is not the right way to do it. Cronjobs are being run in parallel. > So if you both stop and start tinc at the same time, there is no > guarantee that it will happen in the right order. The easiest way is to > create two scripts, one that adds the Subnets and the other that removes > them, and the other that adds them. > > Another issue is that with tinc 1.0, the -k option sends a TERM signal > to the running tinc daemon, but it might take a little time before it > actually stops. So add a sleep command inbetween, or check for > /var/run/tinc.myvpn.pid to disappear. > > -- > Met vriendelijke groet / with kind regards, > Guus Sliepen <guus at tinc-vpn.org> > _______________________________________________ > tinc mailing list > tinc at tinc-vpn.org > https://www.tinc-vpn.org/cgi-bin/mailman/listinfo/tinc-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.tinc-vpn.org/pipermail/tinc/attachments/20170526/3f08c182/attachment.html>
Possibly Parallel Threads
- What/why this event happens: Can't write to Linux tun/tap device (tun mode) /dev/net/tun: Input/output error
- What/why this event happens: Can't write to Linux tun/tap device (tun mode) /dev/net/tun: Input/output error
- config help & pid file not existing issue
- Show the subnets learnt and update configuration without reset?
- Tinc1.0pre4 & kernel 2.4.5 & tun/tap