diff --git a/drivers/net/tun.c b/drivers/net/tun.c                                                                                                                        
index cc09b67..d8a53c3 100644                                                                                                                                             
--- a/drivers/net/tun.c                                                                                                                                                   
+++ b/drivers/net/tun.c                                                                                                                                                   
@@ -438,6 +438,9 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
                sock_put(&tfile->sk);                                                                                                                                     
        }                                                                                                                                                                 
                                                                                                                                                                          
+       if (tun && tun->numqueues == 0)                                                                                                                                   
+               netif_carrier_off(tun->dev);                                                                                                                              
+                                                                                                                                                                         
        if (clean) {                                                                                                                                                      
                if (tun && tun->numqueues == 0 && tun->numdisabled == 0 &&                                                                                                
                    !(tun->flags & TUN_PERSIST))                                                                                                                          
@@ -473,6 +476,7 @@ static void tun_detach_all(struct net_device *dev)
        BUG_ON(tun->numqueues != 0);                                                                                                                                      
                                                                                                                                                                          
        synchronize_net();                                                                                                                                                
+       netif_carrier_off(dev);                                                                                                                                           
        for (i = 0; i < n; i++) {                                                                                                                                         
                tfile = rtnl_dereference(tun->tfiles[i]);                                                                                                                 
                /* Drop read queue */                                                                                                                                     
@@ -531,6 +535,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file)
                sock_hold(&tfile->sk);                                                                                                                                    
                                                                                                                                                                          
        tun_set_real_num_queues(tun);                                                                                                                                     
+       netif_carrier_on(tun->dev);                                                                                                                                       
                                                                                                                                                                          
        /* device is allowed to go away first, so no need to hold extra                                                                                                   
         * refcnt.                                                                                                                                                        
