Linux cut command

Cut out selected fields of each line of a file.

Syntax

cut [-b] [-c] [-f] list [-n] [-d delim] [-s] [file]

-b list The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72
bytes of each line). When -b and -n are used together, list is adjusted so that no multi-byte character is split. If -b is used, the input line should contain 1023 bytes or less.
-c list The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
-f list The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (useful for table subheadings), unless -s is specified. If -f is used, the input line should contain 1023 characters or less.
list A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional – to indicate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)).
-n Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split.
-d The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special meaning to the shell must be quoted. The delimiter can be a multi-byte character.
-s Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be passed through untouched.
file A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be used

Example: Use cut to get your ipv4 IP address:

ifconfig eth0 |grep 'inet addr' |cut -d ':' -f 1,2 | cut -c 21- | cut -c -14

OpenVZ VPN TUN/TAP device

First check if the tun module is loaded on the host node

lsmod | grep tun

If not make sure you load it

modprobe tun

Allow your container to use the tun/tap device by running the following commands on the host node. This example would apply for container number 101

CTID=101

vzctl set $CTID --devnodes net/tun:rw --save

vzctl set $CTID --devices c:10:200:rw --save

vzctl set $CTID --capability net_admin:on --save

vzctl exec $CTID mkdir -p /dev/net

vzctl exec $CTID chmod 600 /dev/net/tun

Thats it restart your container and start installing openVPN.

gentoo configure ipv6 and ipv4 dual stack

Due to lack of documentation I had a bit of trouble getting both default gateways to work. It is vital that both gateways are on a separate line in the config file. You must also use the CIDR notation for ipv4 too. You cannot mix the netmask and CIDR entries. This is my config file which works without a problem. The only think I have changed are the IP addresses I used the ones reserved for documentation.

 

/etc/conf.d/net

 

###############################################################################################
config_eth0="198.51.100.2/24 2001:db8::2/48"
###############################################################################################
routes_eth0="default via 198.51.100.1
default via 2001:db8::2"
###############################################################################################

You also need to make sure that you kernel supports ipv6 and you need iproute2. To check this run

# ip -6 addr show lo
1: lo: mtu 16436
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
(The above lines show things are working)

If you can see your loopback address ::1 you should be good to restart your network card to apply the new configuration. Or if you needed to recompile you kernel a reboot may be necessary. After that is done you can test the ipv6 connection with icmp6.

# ping6 -n google.com
PING google.com(2a00:1450:4008:c01::8b) 56 data bytes
64 bytes from 2a00:1450:4008:c01::8b: icmp_seq=1 ttl=50 time=29.8 ms
64 bytes from 2a00:1450:4008:c01::8b: icmp_seq=2 ttl=50 time=28.5 ms
64 bytes from 2a00:1450:4008:c01::8b: icmp_seq=3 ttl=50 time=28.3 ms
64 bytes from 2a00:1450:4008:c01::8b: icmp_seq=4 ttl=50 time=28.4 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3009ms
rtt min/avg/max/mdev = 28.352/28.779/29.817/0.637 ms

That looks good we received an answer from google via ipv6. Another thing you should know is that you will need to create iptables rules for ip6tables. In the standard configuration all packets will be accepted which you might not want (default policy accept). Now you could think about reconfiguring your web services to use your ipv6 connection. You may also need to emerge your software with the ipv6 use flag to make use of the new connection. A useful tool for calculating ipv6 networks and subnets is net-misc/sipcalc Sipcalc is an advanced console-based IP subnet calculator. Have fun with your new ipv6 connection :)