Skip to content

Commit 72e1f8c

Browse files
author
Timoses
committed
manually configure nics
1 parent 88c240b commit 72e1f8c

File tree

2 files changed

+46
-20
lines changed

2 files changed

+46
-20
lines changed

Vagrantfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ Vagrant.configure("2") do |config|
77
config.vm.define "client" do |client|
88
client.vm.hostname = "client"
99
client.vm.network "private_network", ip: "192.168.101.2",
10-
virtualbox__intnet: "client"
10+
virtualbox__intnet: "client", auto_config: false
1111
end
1212

1313
config.vm.define "infra" do |infra|
1414
infra.vm.hostname = "infra"
1515
infra.vm.network "private_network", ip: "192.168.102.2",
16-
virtualbox__intnet: "infra"
16+
virtualbox__intnet: "infra", auto_config: false
1717
end
1818

1919
config.vm.define "cin" do |cin|
2020
cin.vm.hostname = "cin"
2121
cin.vm.network "private_network", ip: "192.168.103.2",
22-
virtualbox__intnet: "cin"
22+
virtualbox__intnet: "cin", auto_config: false
2323
end
2424

2525
config.vm.define "router" do |router|

playbook.yml

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
- hosts: all:!router
2+
become: true
3+
4+
vars:
5+
host_ips: {
6+
'client': '192.168.101.2/24', 'infra': '192.168.102.2/24', 'cin': '192.168.103.2/24'
7+
}
8+
default_gateways: {
9+
'client': '192.168.101.1', 'infra': '192.168.102.1', 'cin': '192.168.103.1'
10+
}
11+
12+
tasks:
13+
- name: Configure internal network IP
14+
command: "ip a add {{ host_ips[inventory_hostname] }} dev eth1"
15+
ignore_errors: "true"
16+
- name: Remove default gateway
17+
command: "ip route del default"
18+
ignore_errors: "true"
19+
- name: Add default gateway to router
20+
command: "ip route add default via {{ default_gateways[inventory_hostname] }}"
21+
ignore_errors: "true"
22+
123
- hosts: all
224
become: true
325

@@ -9,6 +31,22 @@
931
- tcpdump
1032
- bind-utils
1133
- vim
34+
- tmux
35+
36+
- hosts: infra
37+
become: true
38+
tasks:
39+
- yum:
40+
name: "bind"
41+
42+
- hosts: all
43+
become: true
44+
tasks:
45+
- name: Remove nameservers in /etc/resolv.conf
46+
lineinfile:
47+
path: /etc/resolv.conf
48+
regexp: "^nameserver"
49+
state: absent
1250

1351
- hosts: router
1452
become: true
@@ -34,34 +72,22 @@
3472
zone: internal
3573
state: enabled
3674
loop:
37-
- "enp0s8"
38-
- "enp0s9"
39-
- "enp0s10"
75+
- "eth1"
76+
- "eth2"
77+
- "eth3"
4078
- name: NAT Masquerade default zone (usually public)
4179
firewalld:
4280
masquerade: yes
4381
state: enabled
4482
permanent: yes
4583
- name: Allow outgoing connections
46-
command: "firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -s 192.168.0.0/16 -o enp0s3 -j ACCEPT"
84+
command: "firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -s 192.168.0.0/16 -o eth0 -j ACCEPT"
4785
- name: Accept incoming established/active connections
48-
command: "firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i enp0s3 -d 192.168.0.0/16 -m state --state RELATED,ESTABLISHED -j ACCEPT"
86+
command: "firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i eth0 -d 192.168.0.0/16 -m state --state RELATED,ESTABLISHED -j ACCEPT"
4987

5088
- name: Reload firewall
5189
command: "firewall-cmd --reload"
5290

53-
- hosts: all:!router
54-
become: true
5591

56-
vars:
57-
default_gateways: {
58-
'client': '192.168.101.1', 'infra': '192.168.102.1', 'cin': '192.168.103.1'
59-
}
6092

61-
tasks:
62-
- name: Remove default gateway
63-
command: "ip route del default"
64-
ignore_errors: "true"
65-
- name: Add default gateway to router
66-
command: "ip route add default via {{ default_gateways[inventory_hostname] }}"
6793

0 commit comments

Comments
 (0)