terça-feira, setembro 27, 2016

NFSv4Howto nfs mount and export

NFSv4Howto - Community Help Wiki





fstab nfs4 mount

fstab nfs





NFSv4Howto

I have started moving this information to https://help.ubuntu.com/community/SettingUpNFSHowTo



Contents



Installation

NFSv4 without Kerberos

NFSv4 Server

NFSv4 Client

NFSv4 and Autofs

NFSv4 and NFSv3 simultaneously

NFSv4 with Kerberos

Create and distribute credentials

NFSv4 Server with Kerberos

NFSv4 Client with Kerberos

Troubleshooting

Links

Installation

The required packages are different depending on if the system is a client or a server. In this Howto, the server is the host that has the files you want to share and the client is the host that will be mounting the NFS share.



NFSv4 client

sudo apt-get install nfs-common

NFSv4 server

sudo apt-get install nfs-kernel-server

After you finish installing nfs-kernel-server, you might see failure to start nfs-kernel-server due to missing entries in /etc/exports. Remember to restart the service when you finish configuring.



For the error message:



mount.nfs4: No such device

You will have to load the nfs module with the command



modprobe nfs

NFSv4 without Kerberos

NFSv4 Server



NFSv4 exports exist in a single pseudo filesystem, where the real directories are mounted with the --bind option. Here is some additional information regarding this fact.



Let's say we want to export our users' home directories in /home/users. First we create the export filesystem:



sudo mkdir /export

sudo mkdir /export/users

and mount the real users directory with:



sudo mount --bind /home/users /export/users

To save us from retyping this after every reboot we add the following line to /etc/fstab:



/home/users    /export/users   none    bind  0  0

In /etc/default/nfs-kernel-server we set:



NEED_SVCGSSD=no # no is default

because we are not activating NFSv4 security this time.

To export our directories to a local network 192.168.1.0/24

we add the following two lines to /etc/exports



/export       192.168.1.0/24(rw,fsid=0,no_subtree_check,sync)

/export/users 192.168.1.0/24(rw,nohide,insecure,no_subtree_check,sync)

Be aware of the following points:

there is no space between the IP address and the options

you can list more IP addresses and options; they are space separated as in:

/export/users 192.168.1.1(rw,no_subtree_check) 192.168.1.2(rw,no_root_squash)

using the insecure option allows clients such as Mac OS X to connect on ports above 1024. This option is not otherwise "insecure".

Setting the crossmnt option on the main psuedo mountpoint has the same effect as setting nohide on the sub-exports: It allows the client to map the sub-exports within the psuedo filesystem. These two options are mutually exclusive.

Note that when locking down which clients can map an export by setting the IP address, you can either specify an address range (as shown above) using a subnet mask, or you can list a single IP address followed by the options. Using a subnet mask for single client's full IP address is **not** required. Just use something like 192.168.1.123(rw). There are a couple options for specifying the subnet mask. One style is 255.255.255.0. The other style is /24 as shown. Both styles should work. The subnet mask marks which part of IP address must be evaluated.

Restart the service



sudo service nfs-kernel-server restart

On ubuntu 11.04 or later you may also need to start or restart the idmapd with:



sudo service idmapd restart

NFSv4 Client



On the client we can mount the complete export tree with one command:



sudo mount -t nfs4 -o proto=tcp,port=2049 nfs-server:/ /mnt

We can also mount an exported subtree with:



sudo mount -t nfs4 -o proto=tcp,port=2049 nfs-server:/users /home/users

To save us from retyping this after every reboot we add the following

line to /etc/fstab:



nfs-server:/   /mnt   nfs4    _netdev,auto  0  0

where the auto option mounts on startup and the _netdev option can be used by scripts to mount the filesystem when the network is available. Under NFSv3 (type nfs) the _netdev option will tell the system to wait to mount until the network is available. With a type of nfs4 this option is ignored, but can be used with mount -O _netdev in scripts later. Currently Ubuntu Server does not come with the scripts needed to auto-mount nfs4 entries in /etc/fstab after the network is up.



Note with remote NFS paths

They don't work the way they did in NFSv3. NFSv4 has a global root directory and all exported directories are children to it. So what would have been nfs-server:/export/users on NFSv3 is nfs-server:/users on NFSv4, because /export is the root directory.

Note regarding UID/GID permissions on NFSv4 without Kerberos

To make UID/GUD work as with NFSv3, set sec=sys both in the server's /etc/export and in the client's /etc/fstab. This will make NFSv4 work with the old host-based security scheme.

They do not work. Can someone please help investigating? Following this guide will result in UID/GID on the export being generic despite having same UID on client and server. (According to my experience it works at least with "precise", if uid/gid are equal on both sides. hwehner) Mounting same share on NFSv3 works correctly with regards to UID/GID. Does this need Kerberos to work fully? According to http://arstechnica.com/civis/viewtopic.php?f=16&t=1128994 and http://opensolaris.org/jive/thread.jspa?threadID=68381 you need to use Kerberos for the mapping to have any effect.



This is a possibly related bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=500778



Not clear what is meant by UID/GID on the export being generic. This guide does not explicitly state that idmapd must also run on the client side, i.e. /etc/default/nfs-common needs the same settings as described in the server section. If idmapd is running the UID/GID are mapped correctly. Check with ps ax|grep rpc that rpc.idmapd is running.



If all directory listings show just "nobody" and "nogroup" instead of real user and group names, then you might want to check the Domain parameter set in /etc/idmapd.conf. NFSv4 client and server should be in the same domain. Other operating systems might derive the NFSv4 domain name from the domain name mentioned in /etc/resolv.conf (e.g. Solaris 10).



If you have a slow network connection and are not establishing mount at reboot, you can change the line in etc/fstab:



nfs-server:/    /mnt   nfs4    noauto  0  0

and execute this mount after a short pause once all devices are loaded. Add the following lines to /etc/rc.local



# sleep 5

# mount /mnt

In Ubuntu 11.10 or earlier, f you experience Problems like this:

Warning: rpc.idmapd appears not to be running.

         All uids will be mapped to the nobody uid.

mount: unknown filesystem type 'nfs4'

(all directories and files on the client are owned by uid/gid 4294967294:4294967294) then you need to set in /etc/default/nfs-common:



NEED_IDMAPD=yes

and restart nfs-common.

# service idmapd restart

The "unknown Filesystem" Error will disappear as well. (Make sure you restart the idmapd on both client and server after making changes, otherwise uid/gid problems can persist.)

NFSv4 and Autofs

Automount (or autofs) can be used in combination with NFSv4. Details on the configuration of autofs can be found in the AutofsHowto. The configuration is identical to NFSv2 and NFSv3 except that you have to specify -fstype=nfs4 as option. Automount supports NFSv4's feature to mount all file systems exported by server at once. The exports are then treated as an entity, i.e. they are "all" mounted when you step into "one" directory on the NFS server's file systems. When auto-mounting each file system separately the behavior is slightly different. In that case you would have to step into "each" file system to make it show up on the NFS client.



NFSv4 and NFSv3 simultaneously

NFSv4 and NFSv3 can be used simultaneously on a NFS server as well as on a NFS client. You have to setup NFSv3 on your NFS server (see SettingUpNFSHowTo). You can then export a file system with NFSv4 and NFSv3 simultaneously. Just put the appropriate export statements into /etc/exports and you are done. You might want to do this when you have NFS clients that don't support NFSv4, e.g. Mac OS X and Windows clients. But don't forget about the security risks of NFS with clients that can not be trusted.



NFSv4 with Kerberos

When using NFS without kerberos the security of all data in the NFS share depends on the integrity of all clients and the security of the network connections. If you use kerberos the security doesn't depend on all client machines because the server gives access to users with a valid kerberos ticket only. The security isn't completely delegated to the client machines (unlike without kerberos). Therefore you need a principal in your kerberos realm for each user who want's to access the NFS share. See Kerberos in the Ubuntu Server Guide on this topic. The section "Kerberos Linux Client" applies also to Ubuntu 8.04.



You need a working Kerberos (MIT or Heimdal) KDC (Key Distribution Center) before continuing. NFS4 and Kerberos work fine with Ubuntu 8.04; they do not seem to work with the (much) older Ubuntu 6.06, or at least I couldn't get Heimdal to work correctly.



Please note, that we have three different entities: the Kerberos-server; the NFS-server and the NFS-client. Your Kerberos-server (or KDC) and NFS-server could be the same machine, but they could also very well be separate entities. We will use separate "prompts" to distinguish, i.e. if you see



KDC$ echo "hello"

... this means you need to type echo "hello" on the KDC.



Please note that you can now (with Ubuntu 8.04 and later) use any encryption type you want, there is no more need to extract only des-cbc-crc, as most sites suggest. See [http://mailman.mit.edu/pipermail/kerberos/2008-May/013698.html this mailinglist message].



Please also note, that des-cbc-crc encryption is depreciated and, starting with Ubuntu 10.04, is no longer supported by default in the Kerberos libraries. For nfs4 to work, you need to add allow_weak_crypto = true to /etc/krb5.conf



MIT

On the nfs-server and nfs-client you need at least the krb5-user and optional libpam-krb5 if you wish to authenticate against krb5.



# apt-get install krb5-user

# apt-get install libpam-krb5

Heimdal

On the nfs-server and nfs-client you need heimdal-clients and optional libpam-krb5 if you wish to authenticate against krb5.



# apt-get install heimdal-clients

# apt-get install libpam-krb5

You need the gss kernel modules on nfs-servers and nfs-clients.

# modprobe rpcsec_gss_krb5

Add rpcsec_gss_krb5 to /etc/modules to have it loaded automatically. (I'm pretty sure they're loaded automatically though).



Create and distribute credentials



NFSv4 needs machine credentials for the server and every client, which wants to use the NFSv4 security features.



Create the credentials for the nfs-server and all nfs-clients on the Kerberos KDC and distribute the extraced keys with scp to the destination



You can make sure that only this entry has been created by executing "sudo klist -e -k /etc/krb5.keytab".



Create nfs/ principals

Authenticate as your admin user. You can do this from any machine in your kerberos-domain, as long as your kadmind is running; then add principals for your server and client machines. Replace "nfs-server.domain" with the fully qualified domain name of the machines. For example, if your server is called "snoopy" and your domain is "office.example.com", you would add a principal named "nfs/snoopy.office.example.com" for the server. Note: kadmin must be run with -l (locally) on the KDC if there is no kadmind. Please be aware of https://bugs.launchpad.net/ubuntu/+source/heimdal/+bug/309738/



Heimdal



$ kinit kadmin/admin

$ kadmin add -r nfs/nfs-server.domain

$ kadmin add -r nfs/nfs-client.domain

Now add these to the keytab-files on your NFS-server and client. Log in to your NFSserver (as root, because you will need to edit the /etc/krb5.keytab file) and initialize as Kerberos administrator. If your domain is fully kerberized, logging in as root will automatically give you the right access, in which case you don't need to use "kinit" anymore.



NFSserver# kinit kadmin/admin

NFSserver# ktutil get nfs/nfs-server.domain

And add it to the client's keytab file:



NFSclient# kinit kadmin/admin

NFSclient# ktutil get nfs/nfs-client.domain

MIT



$ kinit admin/admin

$ kadmin -q "addprinc -randkey nfs/nfs-server.domain"

$ kadmin -q "addprinc -randkey nfs/nfs-client.domain"

Now add these to the keytab-files on your NFS-server and client. Log in to your NFSserver (as root, because you will need to edit the /etc/krb5.keytab file) and initialize as Kerberos administrator.



NFSserver# kadmin -p admin/admin -q "ktadd nfs/nfs-server.domain"

And add it to the client's keytab file:



NFSclient# kadmin -p admin/admin -q "ktadd nfs/nfs-client.domain"

NFSv4 Server with Kerberos



Check your machine credentials in /etc/krb5.keytab. Use "ktutil" (MIT) or "ktutil list" (Heimdal)



MIT:



# ktutil

ktutil:  rkt /etc/krb5.keytab

ktutil:  list

slot KVNO Principal

---- ---- ---------------------------------------------------------------------

   1    2 nfs/nfs-server.domain@DOMAIN

Heimdal:



# ktutil list

FILE:/etc/krb5.keytab:



Vno  Type                     Principal

  6  des-cbc-md5              nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM

  6  des-cbc-md4              nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM

  6  des-cbc-crc              nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM

  6  aes256-cts-hmac-sha1-96  nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM

  6  des3-cbc-sha1            nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM

  6  arcfour-hmac-md5         nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM

etcetera (I removed the krb4 entries as you probably won't use them anyway).



MIT extra information:



# sudo klist -e -k /etc/krb5.keytab

Keytab name: FILE:/etc/krb5.keytab

KVNO Principal

---- --------------------------------------------------------------------------

   1 nfs/nfs-server.domain@DOMAIN (DES cbc mode with CRC-32)

In /etc/default/nfs-kernel-server we set:



NEED_SVCGSSD=yes

To export our directories from the example above to a local network 192.198.1.0/24 and addt

we add the following two lines to /etc/exports



/export       192.168.1.0/24(rw,fsid=0,insecure, \

  no_subtree_check,async,anonuid=65534,anongid=65534)

/export       gss/krb5(rw,fsid=0,insecure, \

  no_subtree_check,async,anonuid=65534,anongid=65534)

/export/users 192.168.1.0/24(rw,nohide,insecure, \

  no_subtree_check,async,anonuid=65534,anongid=65534)

/export/users gss/krb5(rw,nohide,insecure, \

  no_subtree_check,async,anonuid=65534,anongid=65534)

Please note that you can specify allowed hosts only in the any authentication flavor. gss/krb5 flavours are accessible from anywhere, if you do not use additional firewall rules.



To export only with secure authentication flavors do not include a host(...) line in /etc/exports



The gss/krb5 flavours are:



krb5: users are authenticated

krb5i: this includes krb5. Additionaly data integrity is provided.

krb5p: this includes krb5i. Additionaly privacy is provided.

To display your exports enter:



# exportfs -v

NFSv4 Client with Kerberos



Check your machine credentials in /etc/krb5.keytab



MIT:



# ktutil

ktutil:  rkt /etc/krb5.keytab

ktutil:  list

slot KVNO Principal

---- ---- ---------------------------------------------------------------------

   1    2 nfs/nfs-client.domain@DOMAIN

Heimdal:



# ktutil list

FILE:/etc/krb5.keytab:



Vno  Type                     Principal

  6  des-cbc-md5              nfs/client.office.example.com@OFFICE.EXAMPLE.COM

  6  des-cbc-md4              nfs/client.office.example.com@OFFICE.EXAMPLE.COM

  6  des-cbc-crc              nfs/client.office.example.com@OFFICE.EXAMPLE.COM

  6  aes256-cts-hmac-sha1-96  nfs/client.office.example.com@OFFICE.EXAMPLE.COM

  6  des3-cbc-sha1            nfs/client.office.example.com@OFFICE.EXAMPLE.COM

  6  arcfour-hmac-md5         nfs/client.office.example.com@OFFICE.EXAMPLE.COM

We can secure mount the complete export tree with:



# mount -t nfs4 -o sec=krb5 nfs-server:/ /mnt

We can also secure mount an exported subtree with:



# mount -t nfs4 -o sec=krb5 nfs-server:/users /home/users

If your client is NATed, use the clientaddr option (see "man 5 nfs"), assuming your client public ip address is a.b.c.d:

# mount -t nfs4 -o sec=krb5,clientaddr=a.b.c.d nfs-server:/users /home/users

Troubleshooting

First, take care of proper logging - by default almost nothing is logged.



To enable debug messages from NFS, edit /etc/default/nfs-kernel-server (quotes are important here):



RPCMOUNTDOPTS="--manage-gids --debug all"

To enable ipmapd debug output, edit /etc/idmpad.conf, and change the Verbosity level:



Verbosity = 5

To enable 3rd level verbose logging for rpc.gssd, run the following command as root:





echo 'exec rpc.gssd -vvv' > /etc/init/gssd.override

After restarting gssd (service gssd restart) check that the daemon has received new arguments:





ps xuwa | grep grep rpc.gssd

root      9857  0.0  0.4   2496  1220 ?        Ss   02:17   0:00 /usr/sbin/rpc.gssd -vvv

Then look for its log output in damon.log:





tail -f /var/log/daemon.log

For the server, you can e.g. raise rpc.svcgssd log level in /etc/default/nfs-kernel-server:





RPCSVCGSSDOPTS="-vvv"

Browse the /etc/init.d/nfs-* init scripts to see other variables that you can set in /etc/defaults.



If using Kerberos, enable logging in /etc/krb5.conf:





[logging]

     kdc = SYSLOG:INFO:DAEMON

     admin_server = SYSLOG:INFO:DAEMON

     default = SYSLOG:INFO:DAEMON

It's possible to increase verbosity in /etc/idmapd.conf . It can be useful to study the sources for better understandig error messages:





apt-get source nfs-common nfs-kernel-server libgssapi2-heimdal librpcsecgss3 libnfsidmap2

segunda-feira, setembro 19, 2016

Pfsense 2.3.1 with OpenDNS (Web filtering)

Pfsense 2.3.1 with OpenDNS (Web filtering)



How to configure Pfsense with OpenDNS (Web filtering)

Requirements
1. Install pfsense 2.3.1 (More than one Dynamic DNS included in this version)
2. Sign up with OpenDNS
3. Configure your network on OpenDNS and don’t forget to configure your web filter settings)

Pointing your network to OpenDNS

Assuming that you have completed the above requirements, first you have to change your DNS on pfsense to OPENDNS. To do this, go to Systems > General Setup. Under DNS Server Settings
DNS Server 1: 208.67.222.222
DNS Server 2: 208.67.220.220
DNS Server Override: Unchecked
Disable DNS Forwarder: Checked
Once you finished, click Save to save all the setting you entered

DNS Resolver & Forwarder

Once you completed the above process, you need to disable DNS Resolver and enable DNS Forwarder.
(I am not sure if DNS Resolver can be configured with OpenDNS, I tried to configure it but no luck. With DNS Forwarder, everything work well. Maybe someone can help out to explaining it WHY)
To do this, you need to go to Services > DNS Resolver > Enable: (Unchecked)
After that, Go to Services > DNS Forwarder > Enable: Checked
Interfaces: All
Click Save

Dynamic DNS

When finished, Go to Services > Dynamic DNS > Add
In this case, I’ll be using OpenDNS but you can pick any services that you like.
Service Type: OpenDNS
Interface to Monitor: WAN
Hostname: opendns.com
MX: leave blank
Wildcards: Unchecked
Verbose Logging: Checked
Username: email address that you registered with on OpenDNS
Password: Your Password
Confirm: Your Password again
Description: You can enter “OpenDNS Account”
Save setting.

Note: If the cached ip is not available, check you settings again. If you see a green ip, everything is okay.

Redirecting all DNS Requests to Pfsense

In some cases, some users can bypass a configured DNS by changing their local DNS to other DNS ips. To avoid it, go to this link: https://doc.pfsense.org/index.php/Redirecting_all_DNS_Requests_to_pfSense

Another option is to block Local DNS configured on a Computer.
To do this, you have to create two LAN Firewall Rules. One rule that allow all requests from pfsense local DNS and the second one will block all requests from external DNS.
Firewall > Rules > LAN > Add with up arrow
Action: Pass
Interface: Lan
Address Family: IPv4
Protocol: TCP/UDP
Source: Invert match-Unchecked/ ANY
Destination: LAN Address
Destination port range: DNS (53)
Log: Checked if you like
Description: Enter smth related to this rule.
Click Save
After that, copy the same rule and change the following settings.
Action: Block and Destination: Any. Other settings remain the same.

I hope that this howto help you alot.

Secondly, big thanks to pfsense team for releasing pfsense 2.3.1
You guys are the best.

sábado, setembro 17, 2016

Squid DansGuardian and squidGuard proxy filter - content filter

Squidblacklist.org - About

http://urlblacklist.com/



Blacklists and Phraselists

If you want an up-to-date URL blacklist then you have two options:

  • Buy Smoothwall (blocklist only compatible with Smoothwall software)
  • Or, URLBlacklist.com. (blacklist compatible with DansGuardian and squidGuard)
You can get the latest phraselists from The Phrase Master to improve the content filtering.

quinta-feira, setembro 15, 2016

kvm - debian - linux - virtualization in linux

What I've learned so far is here ...

Check if your computer supports...


egrep '^flags.*(vmx|svm)' /proc/cpuinfo
virt-host-validate (only after apt-get)

  
apt-get -y install qemu-kvm libvirt-bin virtinst
#install a lot Xwindows files
apt-get -y install virt-manager 

Show all systems list KVM supports
virt-install    \
--name=win-10-off-base    \
--disk path=/kvm/vms/win-10-off-base.qcow2,size=80,cache=writethrough    \
--ram=3072    \
--cdrom=/kvm/iso/W10X64.v1607.MULTi-8.Aug2016.iso    \
--network bridge=br0    \
--os-type=windows    \
--os-variant=win7

virt-install \
   --name=win2012R2 \
   --disk path=/kvm/vms/win-10-off-base.qcow2,size=80,cache=writethrough    \
   --ram=3072 \
   --cdrom=/kvm/iso/2012.R2VL.ESD.ENU.June2016.iso \
   --network bridge=br0 \
   --os-variant=win2k8

virt-install \
   --name=mykvm \
   --file=/kvm/vms/mykvm.qcow2 \
   --file-size=4 \
   --vcpus=1 --ram=512 \
   --cdrom=/tmp/debian-8.5.0-amd64-netinst.iso \
   --network bridge=br0 \
   --os-variant=debianwheezy

use existent partition ...



virt-install --name win-10-off --ram 1024 --os-variant=win7 --disk /kvm/vms/win-10-off.qcow2,device=disk,bus=ide --network bridge=br0 --import


 Useful commands


Let us see some useful commands.
Change memory
$ setmaxmem win-10-off-base 2G —config (changes max memory in config)
$  setmem 1G --config
$ setmem 1G --live (changes only while started)
Find the list of the accepted OS variants
$ osinfo-query os | less
$ osinfo-query os | grep debian
$ osinfo-query os | grep freebsd

List a running vms/domains
$ sudo virsh list

Shutodwn a vm/domain called openbsd
$ sudo virsh shutdown openbsd

Start a vm/domain called openbsd
$ sudo virsh start openbsd

Suspend a vm/domain called openbsd
$ sudo virsh suspend openbsd

Reboot (soft & safe reboot) a vm/domain called openbsd
$ sudo virsh reboot openbsd

Reset (hard reset/not safe) a vm/domain called openbsd
$ sudo virsh reset openbsd

Delete/remove a vm/domain called openbsd
$ sudo virsh destroy openbsd (force shutdown)
$ sudo virsh undefine openbsd 
-- delete --
$ destroy vmName
$ undefine vmName (undefine a domain)
$ vol-list default
$ vol-delete --pool default xxx.qcow2

To see a complete list of virsh command type
$ virsh help | less
$ virsh help | grep reboot

List all media/disks

domblklist vm1 


Media CdRom
change-media vm1 hda --eject --config 
change-media vm1 hda /var/lib/libvirt/images/cd2.iso --insert --config


boot from cd
virsh edit guest-vm

add 
   
     
     
     
     
     
   


   
      hvm
            
     
   









access linux console from virsh
$ vi /etc/default/grub
change line GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8 serial"
$ update-grub


http://wiki.libvirt.org/page/Networking#Debian.2FUbuntu_Bridging

cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp
# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.1.2
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 192.168.1.1
        dns-search mydomain

auto br0
iface br0 inet dhcp
    bridge_ports    eth0
    bridge_stp      off
    bridge_maxwait  0
    bridge_fd       0


Finally add the '/etc/sysctl.conf' settings

net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0


And then load the settings with

sysctl -p /etc/sysctl.conf 




kvm cloning different server
backup restore - different server

Okay so the way I was doing it actually did work just fine. The problem is just that I didn't have enough resources to run that VM. So just to answer my own question... here are the details to how I did the VM duplication across different servers without shared disk.

Because you don't have a shared disk, you can't do a typical 'clone' and then 'migration'. Instead you do a typical clone

Here's the command to do the cloning (/local/vm/ is the path to your VM images, usually /var/something/):

virt-clone --original=vm-to-clone --name=cloned-vm -f /local/vm/cloned-vm.img --mac=xx:xx:xx:xx:xx:xx
Now copy that img file from one server to the other... my servers can't talk directly to eachother, so I use this little SSH redirect to do the trick:

ssh -n server1 '(cd /local/vm/; cat cloned-vm.img)' | ssh server2 '(cd /local/vm/; cat > cloned-vm.img)'
Then copy the config for that VM over:

ssh -n server1 '(cd /etc/libvirt/qemu/; cat cloned-vm.xml)' | ssh server2 '(cd /etc/libvirt/qemu/; cat > cloned-vm.xml)'
Update the config with any new changes. In my case (and this was what was causing my problem), I needed to lower the "memory" and "currentMemory" attributes.
Add the new VM to libvirt:

virsh define /etc/libvirt/qemu/cloned-vm.xml
Run it:


virsh create /etc/libvirt/qemu/cloned-vm.xml


Running virt-install to Build the KVM Guest System
virt-install must be run as root and accepts a wide range of command-line arguments that are used to provide configuration information related to the virtual machine being created. Some of these command-line options are mandatory (specifically name, ram and disk storage must be provided) while others are optional. A summary of these arguments is outlined in the following table:
Argument Description
-h, --help Show the help message and exit
--connect=CONNECT Connect to a non-default hypervisor.
-n NAME, --name=NAME Name of the new guest virtual machine instance. This must be unique amongst all guests known to the hypervisor on the connection, including those not currently active. To re-define an existing guest, use the virsh(1) tool to shut it down (’virsh shutdown’) & delete (’virsh undefine’) it prior to running "virt-install".
-r MEMORY, --ram=MEMORY Memory to allocate for guest instance in megabytes. If the hypervisor does not have enough free memory, it is usual for it to automatically take memory away from the host operating system to satisfy this allocation.
--arch=ARCH Request a non-native CPU architecture for the guest virtual machine. The option is only currently available with QEMU guests, and will not enable use of acceleration. If omitted, the host CPU architecture will be used in the guest.
-u UUID, --uuid=UUID UUID for the guest; if none is given a random UUID will be generated. If you specify UUID, you should use a 32-digit hexadecimal number. UUID are intended to be unique across the entire data center, and indeed world. Bear this in mind if manually specifying a UUID
--vcpus=VCPUS Number of virtual cpus to configure for the guest. Not all hypervisors support SMP guests, in which case this argument will be silently ignored
--check-cpu Check that the number virtual cpus requested does not exceed physical CPUs and warn if they do.
--cpuset=CPUSET Set which physical cpus the guest can use. "CPUSET" is a comma separated list of numbers, which can also be specified in ranges. If the value ’auto’ is passed, virt-install attempts to automatically determine an optimal cpu pinning using NUMA data, if available.
--os-type=OS_TYPE Optimize the guest configuration for a type of operating system (ex. ’linux’, ’windows’). This will attempt to pick the most suitable ACPI & APIC settings, optimally supported mouse drivers, virtio, and generally accommodate other operating system quirks. See "--os-variant" for valid options. For a full list of valid options refer to the man page (man virt-install).
--os-variant=OS_VARIANT Further optimize the guest configuration for a specific operating system variant (ex. ’fedora8’, ’winxp’). This parameter is optional, and does not require an "--os-type" to be specified. For a full list of valid options refer to the man page (man virt-install).
--host-device=HOSTDEV Attach a physical host device to the guest. HOSTDEV is a node device name as used by libvirt (as shown by ’virsh nodedev-list’).
--sound Attach a virtual audio device to the guest. (Full virtualization only).
--noacpi Override the OS type / variant to disables the ACPI setting for fully virtualized guest. (Full virtualization only).
-v, --hvm Request the use of full virtualization, if both para & full virtualization are available on the host. This parameter may not be available if connecting to a Xen hypervisor on a machine without hardware virtualization support. This parameter is implied if connecting to a QEMU based hypervisor.
-p, --paravirt This guest should be a paravirtualized guest. If the host supports both para & full virtualization, and neither this parameter nor the "--hvm" are specified, this will be assumed.
--accelerate When installing a QEMU guest, make use of the KVM or KQEMU kernel acceleration capabilities if available. Use of this option is recommended unless a guest OS is known to be incompatible with the accelerators. The KVM accelerator is preferred over KQEMU if both are available.
-c CDROM, --cdrom=CDROM File or device use as a virtual CD-ROM device for fully virtualized guests. It can be path to an ISO image, or to a CDROM device. It can also be a URL from which to fetch/access a minimal boot ISO image. The URLs take the same format as described for the "--location" argument. If a cdrom has been specified via the "--disk" option, and neither "--cdrom" nor any other install option is specified, the "--disk" cdrom is used as the install media.
-l LOCATION, --location=LOCATION Installation source for guest virtual machine kernel+initrd pair. The "LOCATION" can take one of the following forms:
  • DIRECTORY - Path to a local directory containing an installable distribution image
  • nfs:host:/path or nfs://host/path - An NFS server location containing an installable distribution image
    1. http://host/path - An HTTP server location containing an installable distribution image
    1. ftp://host/path - An FTP server location containing an installable distribution image
--pxe Use the PXE boot protocol to load the initial ramdisk and kernel for starting the guest installation process.
--import Skip the OS installation process, and build a guest around an existing disk image. The device used for booting is the first device specified via "--disk" or "--file".
--livecd Specify that the installation media is a live CD and thus the guest needs to be configured to boot off the CDROM device permanently. It may be desirable to also use the "--nodisks" flag in combination.
-x EXTRA, --extra-args=EXTRA Additional kernel command line arguments to pass to the installer when performing a guest install from "--location".
--disk=DISKOPTS Specifies media to use as storage for the guest, with various options.
--disk opt1=val1,opt2=val2,... To specify media, one of the following options is required:
  • path - A path to some storage media to use, existing or not. Existing media can be a file or block device. If installing on a remote host, the existing media must be shared as a libvirt storage volume. Specifying a non-existent path implies attempting to create the new storage, and will require specifyng a ’size’ value. If the base directory of the path is a libvirt storage pool on the host, the new storage will be created as a libvirt storage volume. For remote hosts, the base directory is required to be a storage pool if using this method.
  • pool - An existing libvirt storage pool name to create new storage on. Requires specifying a ’size’ value.
  • vol - An existing libvirt storage volume to use. This is specified as ’poolname/volname’.
  • device - Disk device type. Value can be ’cdrom’, ’disk’, or ’floppy’. Default is ’disk’. If a ’cdrom’ is specified, and no install method is chosen, the cdrom is used as the install media.
  • bus - Disk bus type. Value can be ’ide’, ’scsi’, ’usb’, ’virtio’ or ’xen’. The default is hypervisor dependent since not all hypervisors support all bus types.
  • perms - Disk permissions. Value can be ’rw’ (Read/Write), ’ro’ (Readonly), or ’sh’ (Shared Read/Write). Default is ’rw’
  • size - size (in GB) to use if creating new storage
  • sparse - whether to skip fully allocating newly created storage. Value is ’true’ or ’false’. Default is ’true’ (do not fully allocate). The initial time taken to fully-allocate the guest virtual disk (spare=false) will be usually by balanced by faster install times inside the guest. Thus use of this option is recommended to ensure consistently high performance and to avoid I/O errors in the guest should the host filesystem fill up.
  • cache - The cache mode to be used. The host pagecache provides cache memory. The cache value can be ’none’, ’writethrough’, or ’writeback’. ’writethrough’ provides read caching. ’writeback’ provides read and write caching. See the examples section for some uses. This option deprecates "--file", "--file-size", and "--nonsparse".
-f DISKFILE, --file=DISKFILE Path to the file, disk partition, or logical volume to use as the backing store for the guest’s virtual disk. This option is deprecated in favor of "--disk".
-s DISKSIZE, --file-size=DISKSIZE Size of the file to create for the guest virtual disk. This is deprecated in favor of "--disk".
--nonsparse Fully allocate the storage when creating. This is deprecated in favort of "--disk"
--nodisks Request a virtual machine without any local disk storage, typically used for running ’Live CD’ images or installing to network storage (iSCSI or NFS root).
-w NETWORK, --network=NETWORK Connect the guest to the host network. The value for "NETWORK" can take one of 3 formats:
  • bridge:BRIDGE - Connect to a bridge device in the host called "BRIDGE". Use this option if the host has static networking config & the guest requires full outbound and inbound connectivity to/from the LAN. Also use this if live migration will be used with this guest.
  • network:NAME - Connect to a virtual network in the host called "NAME". Virtual networks can be listed, created, deleted using the "virsh" command line tool. In an unmodified install of "libvirt" there is usually a virtual network with a name of "default". Use a virtual network if the host has dynamic networking (eg NetworkManager), or using wireless. The guest will be NATed to the LAN by whichever connection is active.
  • user - Connect to the LAN using SLIRP. Only use this if running a QEMU guest as an unprivileged user. This provides a very limited form of NAT.
  • If this option is omitted a single NIC will be created in the guest. If there is a bridge device in the host with a physical interface enslaved, that will be used for connectivity. Failing that, the virtual network called "default" will be used. This option can be specified multiple times to setup more than one NIC.
-b BRIDGE, --bridge=BRIDGE Bridge device to connect the guest NIC to. This parameter is deprecated in favour of the "--network" parameter.
-m MAC, --mac=MAC Fixed MAC address for the guest; If this parameter is omitted, or the value "RANDOM" is specified a suitable address will be randomly generated. For Xen virtual machines it is required that the first 3 pairs in the MAC address be the sequence ’00:16:3e’, while for QEMU or KVM virtual machines it must be ’54:52:00’.
--nonetworks Request a virtual machine without any network interfaces.
--vnc Setup a virtual console in the guest and export it as a VNC server in the host. Unless the "--vncport" parameter is also provided, the VNC server will run on the first free port number at 5900 or above. The actual VNC display allocated can be obtained using the "vncdisplay" command to "virsh" (or virt-viewer(1) can be used which handles this detail for the use).
--vncport=VNCPORT Request a permanent, statically assigned port number for the guest VNC console. Use of this option is discouraged as other guests may automatically choose to run on this port causing a clash.
--sdl Setup a virtual console in the guest and display an SDL window in the host to render the output. If the SDL window is closed the guest may be unconditionally terminated.
--nographics No graphical console will be allocated for the guest. Fully virtualized guests (Xen FV or QEmu/KVM) will need to have a text console configured on the first serial port in the guest (this can be done via the --extra-args option). Xen PV will set this up automatically. The command ’virsh console NAME’ can be used to connect to the serial device.
--noautoconsole Don’t automatically try to connect to the guest console. The default behaviour is to launch a VNC client to display the graphical console, or to run the "virsh" "console" command to display the text console. Use of this parameter will disable this behaviour.
-k KEYMAP, --keymap=KEYMAP Request that the virtual VNC console be configured to run with a non- English keyboard layout.
-d, --debug Print debugging information to the terminal when running the install process. The debugging information is also stored in "$HOME/.virtinst/virt-install.log" even if this parameter is omitted.
--noreboot Prevent the domain from automatically rebooting after the install has completed.
--wait=WAIT Amount of time to wait (in minutes) for a VM to complete its install. Without this option, virt-install will wait for the console to close (not neccessarily indicating the guest has shutdown), or in the case of --noautoconsole, simply kick off the install and exit. Any negative value will make virt-install wait indefinitely, a value of 0 triggers the same results as noautoconsole. If the time limit is succeeded, virt-install simply exits, leaving the virtual machine in its current state.
--force Prevent interactive prompts. If the intended prompt was a yes/no prompt, always say yes. For any other prompts, the application will exit.
--prompt Specifically enable prompting. Default prompting is off (as of virtinst 0.400.0)


Example virt-install Command

With reference to the above command-line argument list, we can now look at an example command-line construct using the virt-install tool.
The following command creates a new KVM virtual machine configured to run Windows XP. It creates a new, 6GB disk image, assigns 512MB of RAM to the virtual machine, configures a CD device for the installation media and uses VNC to display the console:
virt-install --name myWinXP --ram 512 --disk path=/tmp/winxp.img,size=6 \
      --network network:default --vnc --os-variant winxp --cdrom /dev/sr0


Once the guest system has been created, the virt-viewer screen will appear containing the operating system installer loaded from the specified installation media:









Reference.




segunda-feira, setembro 12, 2016

Bohemian Blog » Blog Archive » Sublime Text 2: Find and Replace with Regular Expressions for Idiots

Bohemian Blog » Blog Archive » Sublime Text 2: Find and Replace with Regular Expressions for Idiots



Good article about regexp on Sublime text

sublime text regular expression

sublime text find first number



regexp
for: .+ 
what: \t - $0


So, that works in this instance! But why and how? Let’s break it down:
  • [ ]   Whatever expression is inside these brackets will match ONE character.
  • [a-z]   This expression means “ONE character that is any lowercase letter, a through z.”
  • [A-Z]   This expression means “ONE character that is any uppercase letter, A through Z.”
  • The “space” in between these two expressions is a literal “space” character.
  • ( )   Parenthesis surrounding an expression make a “group”. Groups can be referred to by variables. In this case we defined two groups. Without any effort on your part, these groups are numbered, starting with variable “1” on the left-most group and counting upward to the right. This will come in handy when we fill in the REPLACE field.

Get only first group of numbers numbers
Find.: ([0-9].*[0-9])*([A-z])


For.: $1

domingo, setembro 11, 2016

android marshmallow turn off vibrate notifications

Any way to turn off vibration for notifications? - Android Forums at AndroidCentral.com



Como desligar vibrar em notificações no android 6.0 marshmallow

Any way to turn off vibration for notifications?







Notifications are handled per app I. E. Gmail, SMS, Facebook. Check the app's settings. 



Ou seja, cada aplicativo cuida da sua notificação, seja ela com som, sem som, para vibrar ou não.



Estranho, mas funciona!!!


Network Location - Set to Private or Public in Windows 10 - Windows 10 Forums

Network Location - Set to Private or Public in Windows 10 - Windows 10 Forums



windows 10 set private network

windows 10 alterar para rede privada

windows 10 change network to private





How to Set Network Location to be Public or Private in Windows 10


information   Information
A network location identifies the type of network that a PC is connected to with a network adapter.

The first time you connect to a network, you might be asked if you want to find PCs, devices, and content on the network, and automatically connect to devices like printers and TVs. Turning on this setting prepares your PC for sharing files and devices on a network. It also automatically sets the appropriate Windows Firewall and security settings for the type of network that you connected to. You can change the network location anytime.

This tutorial will show you how to set the network on your PC to be connected to a domainpublic, or private type of location for all users in Windows 10.

You must be signed in as an administrator to be able to change the network location of a network adapter.
Note   Note
Public network = By default, the public network location type is assigned to any new networks when they are first connected. A public network is considered to be shared with the world, with no protection between the local computer and any other computer. Therefore, the Windows Firewall rules associated with the public profile are the most restrictive. This blocks the following apps and services from working: PlayTo, file sharing, network discovery, and automatic setup of network printers, TVs, and other devices.

Private network = A private network location type can be for home or small office networks, or when you know and trust the people and devices on the network. This setting allows your PC to connect to a homegroup and devices on the network, such as printers.

Domain network = The domain network location type is detected when the local computer is a member of an Active Directory domain, and the local computer can authenticate to a domain controller for that domain through one of its network connections.

CONTENTS:

  • Option One: To Change a Network Location in Settings app
  • Option Two: To Change a Network Location in Registry Editor
  • Option Three: To Change a Network Location Local Security Policy
  • Option Four: To Change a Network Location in PowerShell
  • Option Five: To Change Network Location of Current Network Connection in PowerShell
  • Option Six: To Change Network Location of Current Network Connection using a VBS file



EXAMPLE: Network Location of adapter in "Network and Sharing Center"
Click image for larger version. 

Name: Public_network.png 
Views: 4494 
Size: 36.7 KB 
ID: 20994
Click image for larger version. 

Name: Private_network.png 
Views: 2329 
Size: 37.3 KB 
ID: 20993
Click image for larger version. 

Name: Domain_network.png 
Views: 1452 
Size: 37.0 KB 
ID: 20980







Network Location - Set to Private or Public in Windows 10 OPTION ONE Network Location - Set to Private or Public in Windows 10
To Change a Network Location in Settings app

1. Do step 2 or step 3 below for how you would like to open Network settings.

2. Click/tap on your network system icon in the taskbar notification area, click/tap on the Network settings link, and go to step 4below. (see screenshot below)

Name:  Network_Settings_taskbar.png
Views: 384068
Size:  114.4 KB

3. Open Settings, click/tap on the Network & Internet icon, and go to step 4 below.

4. Do step 5 (Ethernet) or step 6 (Wi-Fi) below for you currently connected network.


 5. To Change Network Location of Ethernet Network

A) Click/tap on Ethernet on the left side, click/tap on the Ethernet connection (ex: Brink-Router2) on the right side you arecurrently connected to, and go to step 7 below. (see screenshot below)
Click image for larger version. 

Name: Network_Location_Ethernet_Settings-1.png 
Views: 9798 
Size: 34.5 KB 
ID: 20981


 6. To Change Network Location of Wi-Fi Network

A) Click/tap on Wi-Fi on the left side, click/tap on the Manage known networks link. (see screenshot below)

Click image for larger version. 

Name: Metered_Network_Settings-1.png 
Views: 3598 
Size: 63.1 KB 
ID: 71575

B) Click/tap on the wireless network name (ex: Brink-Router2) you are currently connected to, click/tap on Properties, and go tostep 7 below. (see screenshot below)

Name:  Metered_Network_Settings-2.png
Views: 177690
Size:  19.0 KB


7. Do step 8 (Private) or step 9 (Public) below for the network location you want.
Note   Note
Make this PC discoverable settings will not be available if you have UAC set to Always notify. Setting UAC to a different level will allow Make this PC discoverable settings to be available.

Make this PC discoverable settings will not be available if you have a Hyper-V virtual switch with this Ethernet connection.

Click image for larger version. 

Name: Hyper-V_virtual_switch_network_connection.png 
Views: 625 
Size: 23.8 KB 
ID: 76388


 8. To Change to a Private Network Location

A) Turn on Make this PC discoverable, and go to step 10 below. (see screenshots below)
Click image for larger version. 

Name: Network_Location_Settings-2.png 
Views: 4743 
Size: 188.2 KB 
ID: 52093

 9. To Change to a Public Network Location

A) Turn off Make this PC discoverable, and go to step 10 below. (see screenshots below)
Click image for larger version. 

Name: Network_Location_Settings-3.png 
Views: 1967 
Size: 189.4 KB 
ID: 52094

10. When finished, you can close Settings if you like.







Network Location - Set to Private or Public in Windows 10 OPTION TWO Network Location - Set to Private or Public in Windows 10
To Change a Network Location in Registry Editor

1. Type regedit in the search box (Windows+Q) on Start or taskbar, and press Enter to open Registry Editor.

2. If prompted by UAC, click/tap on Yes.

3. In Registry Editor, navigate to the location below. (see screenshot below)

 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles

Click image for larger version. 

Name: Network_Location_registry-1.png 
Views: 2228 
Size: 24.0 KB 
ID: 20986

4. Double click/tap on the Profiles key in the left pane to expand it. Click/tap on each long GUID number subkey, and look at it'sProfileName string value in the right pane to see if it has the current network name (ex: Network) until found. (see screenshot below)

Click image for larger version. 

Name: Network_Location_registry-2.png 
Views: 1838 
Size: 41.3 KB 
ID: 20987

5. When you find the correct ProfileName for your network name, double click/tap on the Category DWORD value in the same right pane to modify it. (see screenshot below)

Click image for larger version. 

Name: Network_Location_registry-3.png 
Views: 1373 
Size: 41.0 KB 
ID: 20988

6. Type in a new data value number for the network location you want, and click/tap on OK. (see screenshot below)

Network LocationData Value
Public0 (zero)
Private1
Domain2

Name:  Network_Location_registry-4.png
Views: 379940
Size:  10.5 KB

7. When finished, you can now close Registry Editor if you like.

8. Sometimes you may need to sign out and in of your user account to apply the new network location.







Network Location - Set to Private or Public in Windows 10 OPTION THREE Network Location - Set to Private or Public in Windows 10
To Change a Network Location Local Security Policy


Note   Note
This option will override Option One and Option Two above.

1. Open the Local Security Policy (secpol.msc).

2. In the left pane, click/tap on Network List Manager Policies. (see screenshot below)

Click image for larger version. 

Name: Network_Location_local_security_policy-1.png 
Views: 1404 
Size: 36.0 KB 
ID: 20982

3. In the right pane of Network List Manager Policies, double click/tap on your network name (ex: Network). (see screenshot above)
Note   Note
You can click/tap on All Networks if you wanted to apply this to all networks on your PC instead of a single network.


4. Do step 5 (Not configured), step 6 (Private), or step 7 (Public) below for what you would like to do.


 5. To Allow Network Location to be changed by OPTION ONE and OPTION TWO

NOTE: This is the default setting.

A) Click/tap on the Network Location tab. (see screenshot below)

B) Under Location type, select (dot) Not configured.

C) Under User permissions, select (dot) Not configured.

D) Click/tap on OK, and go to step 8 below.

Name:  Network_Location_local_security_policy-4.png
Views: 379571
Size:  17.0 KB


 6. To Change to a Private Network Location

A) Click/tap on the Network Location tab. (see screenshot below)

B) Under Location type, select (dot) Private.

C) Under User permissions, select (dot) User cannot change location.

D) Click/tap on OK, and go to step 8 below.

Name:  Network_Location_local_security_policy-3.png
Views: 379095
Size:  17.0 KB


 7. To Change to a Public Network Location

A) Click/tap on the Network Location tab. (see screenshot below)

B) Under Location type, select (dot) Public.

C) Under User permissions, select (dot) User cannot change location.

D) Click/tap on OK, and go to step 8 below.

Name:  Network_Location_local_security_policy-4.png
Views: 379571
Size:  17.0 KB

8. You can now close Local Security Policy if you like.







Network Location - Set to Private or Public in Windows 10 OPTION FOUR Network Location - Set to Private or Public in Windows 10
To Change a Network Location in PowerShell


Note   Note
Thank you to our member sm156 for pointing out this option.

1. Open an elevated Windows PowerShell.

2. Do step 3 (see current location), step 4 (Private), or step 5 (Public) below for what you would like to do.


 3. To See your Current Network Location

A) Copy and paste the command below into the elevated PowerShell, and press Enter. (see screenshot below)

 Get-NetConnectionProfile

B) Make note of the name of your network. For example: Brink-Router3

C) Go to step 4 (Private) or step 5 (Public) below for what you would like to set your network location as.

Click image for larger version. 

Name: network_location_PowerShell-1.png 
Views: 1039 
Size: 38.5 KB 
ID: 34862


 4. To Set Network Location to Private

A) Type the command below into the elevated PowerShell, press Enter, and go to step 6 below. (see screenshot below)

 Set-NetConnectionProfile -Name "Brink-Router3" -NetworkCategory Private

Note   Note
Substitute Brink-Router3 in the command above with your network name from step 3 above instead.

Click image for larger version. 

Name: network_location_PowerShell-3.png 
Views: 444 
Size: 26.6 KB 
ID: 34864


 5. To Set Network Location to Public

A) Type the command below into the elevated PowerShell, press Enter, and go to step 6 below. (see screenshot below)

 Set-NetConnectionProfile -Name "Brink-Router3" -NetworkCategory Public

Note   Note
Substitute Brink-Router3 in the command above with your network name from step 3 above instead.

Click image for larger version. 

Name: network_location_PowerShell-2.png 
Views: 372 
Size: 26.7 KB 
ID: 34863


6. When finished, you can now close PowerShell if you like.







Network Location - Set to Private or Public in Windows 10 OPTION FIVE Network Location - Set to Private or Public in Windows 10
To Change Network Location of Current Network Connection in PowerShell

1. Open an elevated Windows PowerShell.

2. Do step 3 (Private) or step 4 (Public) below for what you would like to set the network location of your current network connection.


 3. To Set Network Location of Current Network Connection to Private

A) Type the command below into the elevated PowerShell, press Enter, and go to step 5 below. (see screenshot below)

 $net = get-netconnectionprofile;Set-NetConnectionProfile -Name $net.Name -NetworkCategory Private

Click image for larger version. 

Name: Private.png 
Views: 165 
Size: 18.8 KB 
ID: 77550


 4. To Set Network Location of Current Network Connection to Public

A) Type the command below into the elevated PowerShell, press Enter, and go to step 5 below. (see screenshot below)

 $net = get-netconnectionprofile;Set-NetConnectionProfile -Name $net.Name -NetworkCategory Public

Click image for larger version. 

Name: Public.png 
Views: 108 
Size: 18.5 KB 
ID: 77551


5. When finished, you can now close PowerShell if you like.







Network Location - Set to Private or Public in Windows 10 OPTION SIX Network Location - Set to Private or Public in Windows 10
To Change Network Location of Current Network Connection using a VBS file

1. Do step 2 (Private) or step 3 (Public) below for what you would like to set the network location of your current network connection.


 2. To Set Network Location of Current Network Connection to Private

A) Click/tap on the Download button below to download the file below, and go to step 4 below.

Set_Current_Network_Location_to_Private.vbs

download


 3. To Set Network Location of Current Network Connection to Public

A) Click/tap on the Download button below to download the file below, and go to step 4 below.

Set_Current_Network_Location_to_Public.vbs

download


4. Save the .vbs file to your desktop.

5. Run the .vbs file.

6. Unblock the .vbs file. (see screenshot below)

Click image for larger version. 

Name: Unblock.png 
Views: 118 
Size: 19.4 KB 
ID: 77549

7. Click/tap on Yes or OK when prompted by UAC.

8. The network location of your current network connect will now be changed.



That's it,
Shawn