Create a symbol link for python after installing it on OpenBSD
# pkg_add python
quirks-2.304 signed on 2017-04-02T15:01:33Z
Ambiguous: choose package for python
a 0: <None>
1: python-2.7.13p0
2: python-3.4.5p2
3: python-3.5.2p2
4: python-3.6.0p0
Your choice: 4
It won’t create a symbol link by default:
# python
ksh: python: not found
So for using it handily, you can create a symbol link yourself:
# cd /usr/local/bin
# ln -s python3.6 python
Importar archivo “.sql” desde la consola mysql
Importar un archivo desde phpmyadmin es algo lento y hay que configurar unos parametros en el php.ini cuando son archivos demasiado grandes, para ahorrarse toda la espera en el navegador recomiendo importar el archivo sql desde la consola de mysql, para esto se debe iniciar sesion desde la consola (Es lo mismo para windows como para linux)
(Iniciamos sesion)
1
| mysql -uUSUARIO -pPASSWORD |
(usamos la bd donde queremos importar el archivo sql, en mi caso es una tabla)
1
| use nombreBasedatos; |
(source es el comando donde se llamara el archivo como parametro y comenzara hacer todo).
1
| source /home/nombreusuario/archivo.sql |
Cambiar Password en OpenBSD
How do I change root user or any other user account password under OpenBSD operating systems?
You need to use the passwd command. It can changes the user’s local password stored in /etc/master.passwd file, Kerberos, or YP password. A root user can change any users password. Normal user can only change their own password.
Task: OpenBSD Change root User Password
Login as root user and enter:
# passwd
Task: OpenBSD Change Other User Account Password
Login as root user and enter:
To change the password for tom user account, enter:
# passwd {userName}
To change the password for tom user account, enter:
# passwd tom
Task: OpenBSD Change Your Own Password
Simply type the passwd command:
First, the user is prompted for their current password. If the current password is correctly typed, a new password is requested. The new password must be entered twice to avoid typing errors.
$ passwd
First, the user is prompted for their current password. If the current password is correctly typed, a new password is requested. The new password must be entered twice to avoid typing errors.
Power Management
You may also want to enable apmd to save power if your hardware supports it. It will scale the CPU down during idle times and turn it up when the load reaches a certain point. Check the man page for a few different options.
# echo 'apmd_flags="-A"' >> /etc/rc.conf.local
# /etc/rc.d/apmd start
You can check what level (with 0 being the lowest, 100 being the highest) the CPU is running at with:
# sysctl hw.setperf
Try different levels and apmd settings to find the balance you're most comfortable with. Always running it on the lowest setting might limit the data throughput too much, but it will really depend on what hardware you're using.
Bandwidth Statistics
Monitoring how much bandwidth is being used is a common feature of many routers. The same thing can be done on an OpenBSD box quite easily. We'll install the "vnstat" daemon and tell it to monitor each interface.
# pkg_add vnstat
# vnstat -u -i em0
# vnstat -u -i em1
# vnstat -u -i em2
# vnstat -u -i em3
# chown _vnstat /var/db/vnstat/*
If you only care about WAN traffic statistics, just enable it for the egress interface, which is em0 in my case. Next, make any changes you want to the configuration file:
# vi /etc/vnstat.conf
I like to make things a bit more human-readable:
--- vnstat.conf Sat May 2 21:15:35 2015
+++ vnstat.conf Sat May 2 21:13:32 2015
@@ -28,7 +28,7 @@
# how units are prefixed when traffic is shown
# 0 = IEC standard prefixes (KiB/MiB/GiB/TiB)
# 1 = old style binary prefixes (KB/MB/GB/TB)
-UnitMode 0
+UnitMode 1
# output style
# 0 = minimal & narrow, 1 = bar column visible
@@ -37,11 +37,11 @@
OutputStyle 3
# used rate unit (0 = bytes, 1 = bits)
-RateUnit 1
+RateUnit 0
# maximum bandwidth (Mbit) for all interfaces, 0 = disable feature
# (unless interface specific limit is given)
-MaxBandwidth 100
+MaxBandwidth 0
# interface specific limits
# example 8Mbit limit for 'ethnone':
Be sure to add the rc.d script to your startup items, alongside dnscrypt-proxy.
# grep scripts /etc/rc.conf.local
pkg_scripts="dnscrypt_proxy vnstatd"
Finally, start the daemon.
# /etc/rc.d/vnstatd start
Wait a few minutes and it should start collecting data.
# vnstat -i em0
Database updated: Tue Jun 9 15:41:10 2015
em0 since 05/02/15
rx: 334.15 GB tx: 110.72 GB total: 444.88 GB
monthly
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
May '15 265.71 GB | 53.94 GB | 319.66 GB | 125.14 KB/s
Jun '15 68.44 GB | 56.78 GB | 125.22 GB | 175.62 KB/s
------------------------+-------------+-------------+---------------
estimated 237.26 GB | 196.85 GB | 434.11 GB |
daily
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
yesterday 3.03 GB | 1.43 GB | 4.46 GB | 54.09 KB/s
today 2.68 GB | 134.89 MB | 2.82 GB | 52.28 KB/s
------------------------+-------------+-------------+---------------
estimated 4.11 GB | 205 MB | 4.31 GB |
That's all there is to it.
OpenBSD RAID1 (ESPEJADO DE DISCOS) durante la instalación
Setting up a mirror in OpenBSD is quite easy. Boot up the installer and go to shell mode.
Welcome to the OpenBSD/i386 5.5 installation program.
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? s
By default, OpenBSD will only make a /dev entry for the first drive. This is assuming you have two drives: wd0 and wd1. Let's create the /dev entry for wd1 and set a disk layout.
# cd /dev
# sh MAKEDEV wd1
# dd if=/dev/zero of=/dev/wd0c bs=1m count=1
# dd if=/dev/zero of=/dev/wd1c bs=1m count=1
# fdisk -iy wd0
# fdisk -iy wd1
Next we create the partitions on the disks.
# disklabel -E wd0
Label editor (enter '?' for help at any prompt)
> a a
offset: [64]
size: [20964761]
FS type: [4.2BSD] RAID
We can do it once for wd0 and then just import that same configuration into wd1 - pretty cool!
# disklabel wd0 > bsdnowiscool
# disklabel -R wd1 bsdnowiscool
# rm bsdnowiscool
Create the mirror like so:
# bioctl -c 1 -l wd0a,wd1a softraid0
# exit
In my case, the newly-created pseudo-device was called sd0. Go through the installer as normal, but be sure to choose that device instead of the regular hard drives.
Available disks are: wd0 wd1 sd0.
Which one is the root disk? (or 'done') [wd0] sd0
Reboot and check the status of your array in the new system:
# bioctl sd0
Volume Status Size Device
softraid0 0 Online 2146656256 sd0 RAID1
0 Online 2146656256 0:0.0 noencl <wd0a>
1 Online 2146656256 0:1.0 noencl <wd1a>
Or just verify through dmesg.
# grep sd0 /var/run/dmesg.boot
sd0 at scsibus3 targ 1 lun 0: <OPENBSD, SR RAID 1, 005> SCSI2 0/direct fixed
sd0: 2047MB, 512 bytes/sector, 4192688 sectors
root on sd0a (fa6620cf9195850e.a) swap on sd0b dump on sd0b
That's it.
pf.conf en OpenBSD 6.2
# Create blocks that are variable
ext_if="em0"
int_if="em1"
icmp_types="echoreq"
webports = "{http, https}"
sport = "{667 3306}"
# Skip all loopback traffic
set skip on lo
# Perform NAT on external interface
match out on $ext_if from $int_if:network to any nat-to $ext_if
# Define default behavior
block in
pass out keep state
# Allow inbound traffic on internal interface
pass quick on $int_if
# Protect against spoofing
antispoof quick for { lo $int_if }
# SSH is listening on port 22
pass in quick proto tcp to $ext_if port 22 keep state (max-src-conn 15, max-src-conn-rate 5/3, overload <bruteforce> flush global)
# Webserver
pass proto tcp from any to $ext_if port $webports
pass in quick log on $ext_if proto tcp to port $webports
pass in quick on $ext_if proto tcp to port $sport
ext_if="em0"
int_if="em1"
icmp_types="echoreq"
webports = "{http, https}"
sport = "{667 3306}"
# Skip all loopback traffic
set skip on lo
# Perform NAT on external interface
match out on $ext_if from $int_if:network to any nat-to $ext_if
# Define default behavior
block in
pass out keep state
# Allow inbound traffic on internal interface
pass quick on $int_if
# Protect against spoofing
antispoof quick for { lo $int_if }
# SSH is listening on port 22
pass in quick proto tcp to $ext_if port 22 keep state (max-src-conn 15, max-src-conn-rate 5/3, overload <bruteforce> flush global)
# Webserver
pass proto tcp from any to $ext_if port $webports
pass in quick log on $ext_if proto tcp to port $webports
pass in quick on $ext_if proto tcp to port $sport
Suscribirse a:
Entradas (Atom)