{"id":895,"date":"2021-10-17T06:32:49","date_gmt":"2021-10-17T05:32:49","guid":{"rendered":"https:\/\/wordpress.pedrorotoli.com\/?p=895"},"modified":"2021-10-17T13:52:33","modified_gmt":"2021-10-17T12:52:33","slug":"vyos-2","status":"publish","type":"post","link":"https:\/\/wordpress.pedrorotoli.com\/?p=895","title":{"rendered":"Vyos Monitoring on Zabbix using SNMP v3"},"content":{"rendered":"<h4>Vyos initial setup:<\/h4>\n<p>Configure IP address of the interfaces:<br \/>\n<code>configure<br \/>\nset interface ethernet eth<em><strong>n<\/strong><\/em> address x.x.x.x\/x<\/code><\/p>\n<p>Configure DNS for domain resolution:<br \/>\n<code>set system name-server x.x.x.x<\/code><\/p>\n<p>Configure static route to allow internet access:<br \/>\n<code>set protocols static route 0.0.0.0\/0 next-hop x.x.x.x<\/code><\/p>\n<p>Enable SSH:<br \/>\n<code>set service ssh port 22<\/code><\/p>\n<p>Save public key for authentication:<br \/>\n<code>loadkey &lt;user&gt; &lt;key_file&gt;<\/code><\/p>\n<p>Add debian buster repositories to <code>\/etc\/apt\/sources.list<\/code> do be able to install emacs and other shit:<\/p>\n<p><code>deb http:\/\/ftp.rnl.tecnico.ulisboa.pt\/pub\/debian\/ buster main<\/code><br \/>\n<code>deb-src http:\/\/ftp.rnl.tecnico.ulisboa.pt\/pub\/debian\/ buster main<\/code><\/p>\n<p><code>deb http:\/\/security.debian.org\/debian-security\/ buster\/updates main contrib<\/code><br \/>\n<code>deb-src http:\/\/security.debian.org\/debian-security\/ buster\/updates main contrib<\/code><\/p>\n<p><code># buster-updates, previously known as 'volatile'<\/code><br \/>\n<code>deb http:\/\/ftp.rnl.tecnico.ulisboa.pt\/pub\/debian\/ buster-updates main contrib<\/code><br \/>\n<code>deb-src http:\/\/ftp.rnl.tecnico.ulisboa.pt\/pub\/debian\/ buster-updates main contrib<\/code><\/p>\n<h4>Prepare Ubuntu Server to install Zabbix:<\/h4>\n<p>Install and configure MySQL and nginx:<br \/>\n<code>$ sudo apt install mysql-server php php-mysql php-fpm nginx -y<\/code><\/p>\n<p>Install Zabbix repo:<br \/>\n<code>$ wget https:\/\/repo.zabbix.com\/zabbix\/5.4\/ubuntu\/pool\/main\/z\/zabbix-release\/zabbix-release_5.4-1+ubuntu20.04_all.deb<br \/>\n$ sudo dpkg -i zabbix-release_5.4-1+ubuntu20.04_all.deb<br \/>\n$ sudo apt update<\/code><\/p>\n<p>Install Zabbix server, frontend and agent:<br \/>\n<code>$ sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent -y<\/code><\/p>\n<p>Create initial database:<br \/>\n<code>$ sudo mysql -u root -p<br \/>\n<span style=\"color: #ff0000;\">password<\/span><br \/>\nmysql&gt; create database zabbix character set utf8 collate utf8_bin;<br \/>\nmysql&gt; create user zabbix@localhost identified by '<span style=\"color: #ff0000;\">password<\/span>';<br \/>\nmysql&gt; grant all privileges on zabbix.* to zabbix@localhost;<br \/>\nmysql&gt; quit;<\/code><\/p>\n<p>Import initial database schema and data, use the password created earlier (it takes a while):<br \/>\n<code>$ zcat \/usr\/share\/doc\/zabbix-sql-scripts\/mysql\/create.sql.gz | mysql -uzabbix -p zabbix<\/code><\/p>\n<p>Configure the database access for Zabbix server, make the following edit the file <code>\/etc\/zabbix\/zabbix_server.conf<\/code>:<br \/>\n<code>DBPassword=<span style=\"color: #ff0000;\">password<\/span><\/code><\/p>\n<p>Configure PHP for Zabbix frontend, uncomment the following lines on <code>\/etc\/zabbix\/nginx.conf<\/code> and change port 80 to 81:<br \/>\n<code>listen 127.0.0.1:81;<\/code><br \/>\n<code>server_name example.com;<\/code><\/p>\n<p>This would make Zabbix be on the root directory instead of <code>\/zabbix<\/code> subdirectory, create a file named <code>proxy<\/code> inside <code>\/etc\/nginx\/sites-available<\/code>, and put this inside it:<\/p>\n<p><code>server {<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0listen 80;<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0root \/var\/www\/html;<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0index index.php index.html;<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0location \/zabbix\/ {<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0proxy_pass http:\/\/127.0.0.1:81\/;<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0}<\/code><br \/>\n<code>}<\/code><\/p>\n<p>Then create a link for this file on <code>\/etc\/nginx\/sites-enabled<\/code>.<\/p>\n<p>Make sure all relevant services are enables:<br \/>\n<code>systemctl enable zabbix-server zabbix-agent nginx php7.4-fpm<\/code><\/p>\n<p>That will make it so you anyone won&#8217;t be able to access zabbix directly through port 81, and instead will have to go through the <code>\/zabbix<\/code> subdirectory.<\/p>\n<p>After that restart nginx and access <code>x.x.x.x\/zabbix<\/code> using the IP address of the server.<\/p>\n<p>Click next until the DB connection configuration, put the password configured previously and click next, give it a name and click next, now select the correct time zone and choose a theme, click next, next again e finish.<\/p>\n<p>After that you can log in, the username is Admin and the password is zabbix.<\/p>\n<h4>Configuring SNMP v3 on Vyos:<\/h4>\n<p><code>set service snmp listen-address x.x.x.x port 161<\/code> (port is optional, if omitted will default to 161, the IP is of the interface that will receive the requests)<br \/>\n<code>set service snmp v3 engineid '000000000000000000000002'<\/code> (it&#8217;s a hexadecimal number with at least two digits)<br \/>\n<code>set service snmp v3 group <span style=\"color: #ff0000;\">groupname<\/span> mode 'ro'<\/code><br \/>\n<code>set service snmp v3 group <span style=\"color: #ff0000;\">groupname<\/span> view <span style=\"color: #ff0000;\">viewname<\/span><\/code><br \/>\n<code>set service snmp v3 user <span style=\"color: #ff0000;\">username<\/span> auth plaintext-password '<span style=\"color: #ff0000;\">password<\/span>'<\/code><br \/>\n<code>set service snmp v3 user <span style=\"color: #ff0000;\">username<\/span> auth type <span style=\"color: #ff0000;\">sha<\/span><\/code><br \/>\n<code>set service snmp v3 user <span style=\"color: #ff0000;\">username<\/span> group <span style=\"color: #ff0000;\">groupname<\/span><\/code><br \/>\n<code>set service snmp v3 user <span style=\"color: #ff0000;\">username<\/span> privacy plaintext-password '<span style=\"color: #ff0000;\">password<\/span>'<\/code><br \/>\n<code>set service snmp v3 user <span style=\"color: #ff0000;\">username<\/span> privacy type <span style=\"color: #ff0000;\">aes<\/span><\/code><br \/>\n<code>set service snmp v3 view <span style=\"color: #ff0000;\">viewname<\/span> oid 1<\/code><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vyos initial setup: Configure IP address of the interfaces: configure set interface ethernet ethn address x.x.x.x\/x Configure DNS for domain resolution: set system name-server x.x.x.x<\/p>\n","protected":false},"author":1,"featured_media":899,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,53],"tags":[64,41,49,63],"class_list":["post-895","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-network","tag-snmp-v3","tag-ubuntu-server","tag-vyos","tag-zabbix"],"_links":{"self":[{"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=\/wp\/v2\/posts\/895","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=895"}],"version-history":[{"count":35,"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=\/wp\/v2\/posts\/895\/revisions"}],"predecessor-version":[{"id":931,"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=\/wp\/v2\/posts\/895\/revisions\/931"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=\/wp\/v2\/media\/899"}],"wp:attachment":[{"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.pedrorotoli.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}