User Tools

Site Tools


настройка_стендов_слушателей

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
настройка_стендов_слушателей [2018/07/12 14:52]
val
настройка_стендов_слушателей [2020/08/22 15:00] (current)
val [Общие файлы конфигурации]
Line 8: Line 8:
 ==== Общие файлы конфигурации ==== ==== Общие файлы конфигурации ====
  
-=== Debian/​Ubuntu/​FreeBSD ​===+=== Debian/​Ubuntu ===
  
 <​code>​ <​code>​
Line 30: Line 30:
  
 ==== Debian/​Ubuntu ==== ==== Debian/​Ubuntu ====
 +
 +  * [[Настройка сети в Linux]]
  
 === Gate === === Gate ===
Line 133: Line 135:
 ===== Скрипты автоконфигурации ===== ===== Скрипты автоконфигурации =====
  
 +<​code>​
 +# git clone http://​val.bmstu.ru/​unix/​conf.git
 +</​code>​
 ==== gate.corpX.un ==== ==== gate.corpX.un ====
 <​code>​ <​code>​
Line 176: Line 181:
         netmask 255.255.255.0         netmask 255.255.255.0
         gateway 172.16.1.254         gateway 172.16.1.254
 +
 +#auto eth2
 +#iface eth2 inet static
 +#        address 192.168.$((100+$X)).1
 +#        netmask 255.255.255.0
 EOF EOF
  
 echo "​net.ipv4.ip_forward = 1" >> /​etc/​sysctl.conf echo "​net.ipv4.ip_forward = 1" >> /​etc/​sysctl.conf
 +
 +timedatectl set-timezone Europe/​Moscow
  
 echo Success echo Success
Line 224: Line 236:
         gateway 192.168.$X.1         gateway 192.168.$X.1
 EOF EOF
 +
 +timedatectl set-timezone Europe/​Moscow
  
 echo Success echo Success
Line 246: Line 260:
  
 echo '​INTERFACES="​eth0"'​ > /​etc/​default/​isc-dhcp-server echo '​INTERFACES="​eth0"'​ > /​etc/​default/​isc-dhcp-server
 +echo '#​INTERFACES="​eth0 eth2"'​ >> /​etc/​default/​isc-dhcp-server
  
 cat > /​etc/​dhcp/​dhcpd.conf <<EOF cat > /​etc/​dhcp/​dhcpd.conf <<EOF
 ddns-update-style none; ddns-update-style none;
  
-log-facility local7;+default-lease-time 600; 
 +max-lease-time 7200; 
 + 
 +option domain-name "​corp$X.un";​ 
 +option domain-name-servers 192.168.$X.10;
  
 #### For provisioning #### #### For provisioning ####
 #option tftp-server-name code 66 = string; # RFC 2132 #option tftp-server-name code 66 = string; # RFC 2132
 #option tftp-server-address code 150 = ip-address; # RFC 5859 #option tftp-server-address code 150 = ip-address; # RFC 5859
 +#option tftp-server-name "​server.corp$X.un";​
 +#option tftp-server-address 192.168.$X.10;​
  
-subnet 192.168.$X.0 netmask 255.255.255.0 { 
-  default-lease-time 600; 
-  max-lease-time 7200; 
-  range 192.168.$X.101 192.168.$X.199;​ 
-  option routers 192.168.$X.1;​ 
-  option domain-name "​corp$X.un";​ 
-  option domain-name-servers 192.168.$X.10;​ 
- 
-#### For provisioning #### 
-#  option tftp-server-name "​server.corp$X.un";​ 
-#  option tftp-server-address 192.168.$X.10;​ 
  
 +shared-network LAN1 {
 +  subnet 192.168.$X.0 netmask 255.255.255.0 {
 +    range 192.168.$X.101 192.168.$X.199;​
 +    option routers 192.168.$X.1;​
 +  }
 } }
 +
 +#​shared-network LAN2 {
 +#  subnet 192.168.$((100 + $X)).0 netmask 255.255.255.0 {
 +#    range 192.168.$((100 + $X)).101 192.168.$((100 + $X)).199;
 +#    option routers 192.168.$((100 + $X)).1;
 +#  }
 +#}
 +
 +
 EOF EOF
  
Line 302: Line 326:
                 172.16.1.254;​                 172.16.1.254;​
         };         };
 +        empty-zones-enable no;
 }; };
  
Line 328: Line 353:
 @         ​SOA ​    ns root.ns ​ 1 1d 12h 1w 3h @         ​SOA ​    ns root.ns ​ 1 1d 12h 1w 3h
           NS      ns           NS      ns
 +
 +          A       ​192.168.$X.10
 +          MX 1    server
  
 ns        A       ​192.168.$X.10 ns        A       ​192.168.$X.10
Line 358: Line 386:
 echo Success echo Success
 exit 0 exit 0
 +</​code>​
 +
 +===== Ansible конфигурация =====
 +
 +<​code>​
 +# git clone http://​val.bmstu.ru/​unix/​conf.git
 +</​code>​
 +
 +<​code>​
 +server.isp.un:​~/​ansible/​roles#​ cat host.yml
 +</​code><​code>​
 +- name: Network config for hosts
 +  hosts: corp
 +  strategy: free
 +  roles:
 +    - host
 +</​code><​code>​
 +server.isp.un:​~/​ansible/​roles#​ cat host/​tasks/​main.yml
 +</​code><​code>​
 +- name: Create hosts file
 +  template: src=hosts.j2 dest=/​etc/​hosts
 +
 +- name: Create resolv.conf file
 +  template: src=resolv.conf.j2 dest=/​etc/​resolv.conf
 +
 +- name: Create hostname file
 +  template: src=hostname.j2 dest=/​etc/​hostname
 +
 +- name: Create interfaces file
 +  template: src=interfaces.j2 dest=/​etc/​network/​interfaces
 +
 +#- name: Restart system
 +#  command: shutdown -r +1
 +</​code><​code>​
 +server.isp.un:​~/​ansible/​roles#​ cat host/​vars/​main.yml
 +</​code><​code>​
 +hostname: server
 +#hostname: mail
 +base_domain_prefix:​ corp
 +base_domain_suffix:​ un
 +base_net: 172.16.1
 +gateway_octet:​ 254
 +dns_ip: 172.16.1.254
 +X: "{{ ansible_eth0.ipv4.address.split('​.'​)[3] }}"
 +#X: "{{ ansible_eth0.ipv4.address.split('​.'​)[3] | int - 100 }}"
 +</​code><​code>​
 +server.isp.un:​~/​ansible/​roles#​ cat host/​templates/​hosts.j2
 +</​code><​code>​
 +127.0.0.1 localhost
 +
 +{{ ansible_eth0.ipv4.address }} {{ hostname }}.{{ base_domain_prefix }}{{ X }}.{{ base_domain_suffix }} {{ hostname }}
 +
 +{{ base_net }}.254 rep
 +</​code><​code>​
 +server.isp.un:​~/​ansible/​roles#​ cat host/​templates/​resolv.conf.j2
 +</​code><​code>​
 +search {{ base_domain_prefix }}{{ X }}.{{ base_domain_suffix }}
 +nameserver {{ dns_ip }}
 +</​code><​code>​
 +server.isp.un:​~/​ansible/​roles#​ cat host/​templates/​hostname.j2
 +</​code><​code>​
 +{{ hostname }}.{{ base_domain_prefix }}{{ X }}.{{ base_domain_suffix }}
 +</​code><​code>​
 +server.isp.un:​~/​ansible/​roles#​ cat host/​templates/​interfaces.j2
 +</​code><​code>​
 +auto lo
 +iface lo inet loopback
 +
 +auto eth0
 +iface eth0 inet static
 +        address {{ ansible_eth0.ipv4.address }}
 +        netmask 255.255.255.0
 +        gateway {{ base_net }}.{{ gateway_octet }}
 +</​code><​code>​
 +root@server:​~/​ansible/​roles#​ ansible-playbook host.yml
 +
 +или
 +
 +root@server:​~#​ ansible-playbook ansible/​roles/​host.yml
 </​code>​ </​code>​
настройка_стендов_слушателей.1531396356.txt.gz · Last modified: 2018/07/12 14:52 by val