-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d88e1b0
Showing
13 changed files
with
878 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# mikrotik-armor | ||
## What? | ||
Ansible playbook to perform common hardening funtions on a RouterOS device. This is almost 100% based on the [Manito Networks](https://www.manitonetworks.com/networking/2017/7/25/mikrotik-router-hardening) suggestions for hardening a device. | ||
|
||
## Why? | ||
Why not? Having a much more secure base to start from is useful in saving you unpleasant work later. | ||
|
||
## How? | ||
Install ansible. Clone the repo and adjust the variables, accounting for your own file hierarchy. | ||
Then run the command: `ansible-playbook /etc/ansible/playbooks/mikrotik-armor.yml` | ||
|
||
## To Do | ||
Adjust as necessary | ||
|
||
## other stuff | ||
*Use anything I write at your own peril.* | ||
|
||
Sometimes I put stuff on my [website](https://www.forwardingplane.net). You can contact me via [email](mailto:buraglio@forwardingplane.net) or [Twitter](https://www.twitter.com/buraglio) or [LinkedIN](https://www.linkedin.com/in/buraglio/). I'm not always responsive in a timely manner and probably won't be able to help you do ansible stuff, but generally do eventually reply. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Ansible -- http://ansible.com/ | ||
# ============================================== | ||
[defaults] | ||
inventory = ./hosts | ||
library = ./library | ||
#vault_password_file = ~/.ansible_pw | ||
|
||
gathering = smart | ||
roles_path = ./roles | ||
host_key_checking = True | ||
deprecation_warnings = True | ||
command_warnings = True | ||
nocows = 1 | ||
fact_caching = memory | ||
fact_caching_timeout = 86400 | ||
retry_files_enabled = False | ||
|
||
# Use the YAML callback plugin. | ||
stdout_callback = yaml | ||
# Use the stdout_callback when running ad-hoc commands. | ||
bin_ansible_callbacks = True | ||
|
||
[ssh_connection] | ||
ssh_args = -o ControlMaster=auto -o ControlPersist=60s | ||
control_path = %(directory)s/ansible-ssh-%%h-%%p-%%r | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# RouterOS Routers | ||
[network:children] | ||
mikrotik | ||
|
||
[mikrotik] | ||
10.100.100.100 # change this to somethintg useful, or use a range like below | ||
## c-10-100-100-[2:254].cpe.mywisp.net | ||
## 10.100.100.[2:254] | ||
[mikrotik:vars] | ||
ansible_network_os=routeros | ||
ansible_connection=network_cli | ||
# I use ssh keys for all access, it's fairly trivial to use ansible vault | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- hosts: mikrotik | ||
gather_facts: False | ||
roles: | ||
- mikrotik-armor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Role Name | ||
========= | ||
|
||
A brief description of the role goes here. | ||
|
||
Requirements | ||
------------ | ||
|
||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. | ||
|
||
Dependencies | ||
------------ | ||
|
||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: | ||
|
||
- hosts: servers | ||
roles: | ||
- { role: username.rolename, x: 42 } | ||
|
||
License | ||
------- | ||
|
||
BSD | ||
|
||
Author Information | ||
------------------ | ||
|
||
An optional section for the role authors to include contact information, or a website (HTML is not allowed). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
# defaults file for mikrotik-armor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
# handlers file for mikrotik-armor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
galaxy_info: | ||
author: your name | ||
description: your description | ||
company: your company (optional) | ||
|
||
# If the issue tracker for your role is not on github, uncomment the | ||
# next line and provide a value | ||
# issue_tracker_url: http://example.com/issue/tracker | ||
|
||
# Choose a valid license ID from https://spdx.org - some suggested licenses: | ||
# - BSD-3-Clause (default) | ||
# - MIT | ||
# - GPL-2.0-or-later | ||
# - GPL-3.0-only | ||
# - Apache-2.0 | ||
# - CC-BY-4.0 | ||
license: license (GPL-2.0-or-later, MIT, etc) | ||
|
||
min_ansible_version: 2.4 | ||
|
||
# If this a Container Enabled role, provide the minimum Ansible Container version. | ||
# min_ansible_container_version: | ||
|
||
# | ||
# Provide a list of supported platforms, and for each platform a list of versions. | ||
# If you don't wish to enumerate all versions for a particular platform, use 'all'. | ||
# To view available platforms and versions (or releases), visit: | ||
# https://galaxy.ansible.com/api/v1/platforms/ | ||
# | ||
# platforms: | ||
# - name: Fedora | ||
# versions: | ||
# - all | ||
# - 25 | ||
# - name: SomePlatform | ||
# versions: | ||
# - all | ||
# - 1.0 | ||
# - 7 | ||
# - 99.99 | ||
|
||
galaxy_tags: [] | ||
# List tags for your role here, one per line. A tag is a keyword that describes | ||
# and categorizes the role. Users find roles by searching for tags. Be sure to | ||
# remove the '[]' above, if you add tags to this list. | ||
# | ||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters. | ||
# Maximum 20 tags per role. | ||
|
||
dependencies: [] | ||
# List your role dependencies here, one per line. Be sure to remove the '[]' above, | ||
# if you add dependencies to this list. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
# tasks file for mikrotik-armor | ||
- name: disable services telnet, www, www-ssl, api, api-ssl, winbox | ||
routeros_command: | ||
commands: | ||
- /ip service disable [find name=telnet] | ||
- /ip service disable [find name=ftp] | ||
- /ip service disable [find name=www] | ||
- /ip service disable [find name=www-ssl] | ||
- /ip service disable [find name=api] | ||
- /ip service disable [find name=api-ssl] | ||
- /ip service disable [find name=winbox] | ||
- name: disable bandwidth server | ||
routeros_command: | ||
commands: | ||
- /tool bandwidth-server set enabled=no | ||
- name: disable remote DNS server | ||
routeros_command: | ||
commands: | ||
- /ip dns set allow-remote-requests=no | ||
- name: disable socks | ||
routeros_command: | ||
commands: | ||
- /ip socks set enabled=no | ||
- name: disable mac-winbx mac-ping (leaving mac-telnet enabled) | ||
routeros_command: | ||
commands: | ||
- /tool mac-server mac-winbox set [find] disabled=yes | ||
- /tool mac-server ping set enabled=no | ||
- name: enable ssh strong-crypto | ||
routeros_command: | ||
commands: | ||
- /ip ssh set strong-crypto=yes | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
localhost | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- hosts: localhost | ||
remote_user: root | ||
roles: | ||
- mikrotik-armor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
# vars file for mikrotik-armor |