Projet

Général

Profil

Routage » Historique » Version 84

Laurent GUERBY, 30/03/2025 13:00
ajout systemd-network

1 1 Laurent GUERBY
{{>toc}}
2 1 Laurent GUERBY
3 6 Mehdi Abaakouk
h1. Routage
4 1 Laurent GUERBY
5 53 Matthieu Herrb
h2. Configuration
6 1 Laurent GUERBY
7 2 Laurent GUERBY
Coté Adhérent-e :
8 1 Laurent GUERBY
9 70 Matthieu Herrb
En ligne de commande (ou dans @/etc/rc.local@):
10 70 Matthieu Herrb
remplacer *IP* par l'adresse IPv4 allouée à la machine et XX et YY par les valeurs dérivées de l'adresse v4 selon la table de la section qui suit.
11 1 Laurent GUERBY
12 1 Laurent GUERBY
<pre>
13 70 Matthieu Herrb
# IPv4
14 1 Laurent GUERBY
ip addr add IP/32 dev eth0
15 1 Laurent GUERBY
ip route add default via 91.224.148.0 dev eth0 onlink
16 1 Laurent GUERBY
17 70 Matthieu Herrb
# IPv6
18 82 Matthieu Herrb
ip -6 addr add 2a03:7220:80XX:YY00::1/56
19 1 Laurent GUERBY
ip -6 addr add fe80::XX:YY/64 dev eth0
20 1 Laurent GUERBY
ip -6 route add default via fe80::31 dev eth0
21 1 Laurent GUERBY
</pre>
22 1 Laurent GUERBY
23 72 Matthieu Herrb
h2. Adresses
24 1 Laurent GUERBY
25 71 Matthieu Herrb
YY est la conversion en hexadécimal de DDD
26 47 Laurent GUERBY
27 72 Matthieu Herrb
|_. IPv4 |_. XX |_. Préfixe v6 |_.Link local v6 |_. Origine v4 |
28 73 Aymeric APLU
|91.224.148.DDD | 80 | 2a03:7220:8080:YY00::/56 | fe80::80:YY | PI tetaneutral.net |
29 73 Aymeric APLU
|91.224.149.DDD | 81 | 2a03:7220:8081:YY00::/56 | fe80::81:YY | PI tetaneutral.net |
30 73 Aymeric APLU
|89.234.156.DDD | 83 | 2a03:7220:8083:YY00::/56 | fe80::83:YY | PA opdop |
31 73 Aymeric APLU
|89.234.157.DDD | 84 | 2a03:7220:8084:YY00::/56 | fe80::84:YY | PA opdop |
32 73 Aymeric APLU
|185.119.168.DDD | 85 | 2a03:7220:8085:YY00::/56 | fe80::85:YY | PA tetaneutral.net |
33 73 Aymeric APLU
|185.119.169.DDD | 86 | 2a03:7220:8086:YY00::/56 | fe80::86:YY | PA tetaneutral.net |
34 73 Aymeric APLU
|185.119.170.DDD | 87 | 2a03:7220:8087:YY00::/56 | fe80::87:YY | PA tetaneutral.net |
35 73 Aymeric APLU
|185.119.171.DDD | 88 | 2a03:7220:8088:YY00::/56 | fe80::88:YY | PA tetaneutral.net |
36 2 Laurent GUERBY
37 66 Matthieu Herrb
h2. Sur VM ou machine hébergée
38 2 Laurent GUERBY
39 74 Anthony Prades
h3. Debian/Ubuntu (sans netplan)
40 76 Matthieu Herrb
41 2 Laurent GUERBY
<pre>
42 2 Laurent GUERBY
# cat /etc/network/interfaces
43 2 Laurent GUERBY
auto lo
44 2 Laurent GUERBY
iface lo inet loopback
45 2 Laurent GUERBY
auto eth0
46 2 Laurent GUERBY
iface eth0 inet6 static
47 2 Laurent GUERBY
    pre-up /sbin/sysctl -w net.ipv6.conf.eth0.accept_ra=0
48 2 Laurent GUERBY
    pre-up /sbin/sysctl -w net.ipv6.conf.eth0.autoconf=0
49 2 Laurent GUERBY
    up ip addr add fe80::YY:XX/64 dev eth0
50 47 Laurent GUERBY
    address 2a03:7220:80YY:XX00::1
51 2 Laurent GUERBY
    netmask 56
52 1 Laurent GUERBY
    gateway fe80::31
53 1 Laurent GUERBY
54 1 Laurent GUERBY
iface eth0 inet manual
55 1 Laurent GUERBY
    up ip link set eth0 up
56 1 Laurent GUERBY
    down ip link set eth0 down
57 1 Laurent GUERBY
    pre-up /sbin/sysctl -w net.ipv6.conf.eth0.accept_ra=0
58 1 Laurent GUERBY
    pre-up /sbin/sysctl -w net.ipv6.conf.eth0.autoconf=0
59 1 Laurent GUERBY
    up ip addr add 91.224.148.DDD/32 dev eth0
60 1 Laurent GUERBY
    up ip route add 91.224.148.0/32 dev eth0
61 1 Laurent GUERBY
    up ip route add default via 91.224.148.0
62 1 Laurent GUERBY
    down ip route flush dev eth0
63 1 Laurent GUERBY
    down ip addr flush dev eth0
64 74 Anthony Prades
</pre>
65 74 Anthony Prades
66 74 Anthony Prades
h3. netplan
67 74 Anthony Prades
68 78 Anthony Prades
Note: il est conseillé de supprimer le paquet cloud-init
69 78 Anthony Prades
70 80 Anthony Prades
/etc/network/interfaces
71 1 Laurent GUERBY
<pre>
72 78 Anthony Prades
auto lo
73 78 Anthony Prades
iface lo inet loopback
74 78 Anthony Prades
</pre>
75 78 Anthony Prades
76 78 Anthony Prades
/etc/netplan/01-ttn-init.yaml
77 78 Anthony Prades
<pre>
78 74 Anthony Prades
network:
79 74 Anthony Prades
    ethernets:
80 74 Anthony Prades
        eth0:
81 75 Matthieu Herrb
           dhcp4: false
82 75 Matthieu Herrb
           dhcp6: false
83 75 Matthieu Herrb
           accept-ra: false
84 74 Anthony Prades
           addresses:
85 79 Anthony Prades
               - 91.224.148.DDD/32
86 79 Anthony Prades
               - 2a03:7220:80YY:XX00::1/56
87 79 Anthony Prades
               - fe80::YY:XX/64
88 79 Anthony Prades
           gateway6: fe80::31
89 79 Anthony Prades
           routes:
90 79 Anthony Prades
               - to: 0.0.0.0/0
91 79 Anthony Prades
                 via: 91.224.148.0
92 79 Anthony Prades
                 on-link: true
93 81 Matthieu Herrb
           nameservers:
94 81 Matthieu Herrb
              search:
95 81 Matthieu Herrb
                - tetaneutral.net
96 81 Matthieu Herrb
              addresses:
97 81 Matthieu Herrb
                - 2a03:7220:8080:a00::1
98 81 Matthieu Herrb
                - 2a03:7220:8081:fe00::1
99 81 Matthieu Herrb
                - 91.224.148.10
100 81 Matthieu Herrb
                - 91.224.149.254
101 74 Anthony Prades
    version: 2
102 79 Anthony Prades
    renderer: networkd
103 1 Laurent GUERBY
</pre>
104 1 Laurent GUERBY
105 78 Anthony Prades
Valider avec la commande:
106 1 Laurent GUERBY
<pre>
107 78 Anthony Prades
netplan apply
108 78 Anthony Prades
</pre>
109 74 Anthony Prades
110 78 Anthony Prades
Si tout est bon:
111 78 Anthony Prades
<pre>
112 78 Anthony Prades
netplan generate
113 2 Laurent GUERBY
</pre>
114 53 Matthieu Herrb
115 83 Laurent GUERBY
h3. systemd-network
116 83 Laurent GUERBY
117 84 Laurent GUERBY
Il est possible de se passer et /etc/network/interfaces et de netplan en utilisant uniquement systemd-network, dans /etc/systemd/network/50-ttnn-eth0.network :
118 84 Laurent GUERBY
119 84 Laurent GUERBY
<pre>
120 84 Laurent GUERBY
[Match]
121 84 Laurent GUERBY
PermanentMACAddress=TTNN_MAC
122 84 Laurent GUERBY
Name=eth0
123 84 Laurent GUERBY
124 84 Laurent GUERBY
[Network]
125 84 Laurent GUERBY
LinkLocalAddressing=ipv6
126 84 Laurent GUERBY
Address=TTNN_IPV4/32
127 84 Laurent GUERBY
Address=TTNN_IPV6/56
128 84 Laurent GUERBY
Address=TTNN_LL/64
129 84 Laurent GUERBY
IPv6AcceptRA=no
130 84 Laurent GUERBY
DNS=91.224.148.10
131 84 Laurent GUERBY
DNS=91.224.149.254
132 84 Laurent GUERBY
DNS=2a03:7220:8080:0a00::1
133 84 Laurent GUERBY
DNS=2a03:7220:8080:fe00::1
134 84 Laurent GUERBY
Domains=tetaneutral.net
135 84 Laurent GUERBY
136 84 Laurent GUERBY
[Route]
137 84 Laurent GUERBY
Destination=0.0.0.0/0
138 84 Laurent GUERBY
Gateway=91.224.148.0
139 84 Laurent GUERBY
GatewayOnLink=true
140 84 Laurent GUERBY
141 84 Laurent GUERBY
[Route]
142 84 Laurent GUERBY
Destination=::/0
143 84 Laurent GUERBY
Gateway=fe80::31        
144 84 Laurent GUERBY
</pre>
145 84 Laurent GUERBY
146 84 Laurent GUERBY
Préparations pour avoir eth0 :
147 84 Laurent GUERBY
148 84 Laurent GUERBY
<pre>
149 84 Laurent GUERBY
sed -i 's/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"net.ifnames=0 /g' /etc/default/grub
150 84 Laurent GUERBY
update-grub
151 84 Laurent GUERBY
echo LLMNR=no >> /etc/systemd/resolved.conf
152 84 Laurent GUERBY
</pre>
153 84 Laurent GUERBY
154 67 Matthieu Herrb
h2. Autres systèmes d'exploitation
155 30 yannick deroche
156 30 yannick deroche
h3. pfsense
157 30 yannick deroche
158 30 yannick deroche
http://blog.magiksys.net/pfsense-firewall-default-gateway-different-subnet
159 30 yannick deroche
160 65 Matthieu Herrb
Ça se configure via le shell de la console pfSense
161 65 Matthieu Herrb
C'est l'option "-link" à rajouter. Pour spécifier que c'est directement accessible via l'interface configurée.
162 1 Laurent GUERBY
163 45 yannick deroche
EN PREMIER LIEU, IL FAUT EFFACER TOUTES SES ROUTES PAR DEFAUT (en shell, option 8)
164 45 yannick deroche
<pre>
165 45 yannick deroche
ifconfig em0 91.224.XXX.YYY 255.255.255.255 (remplacer em0 par son nom d'interface WAN)
166 45 yannick deroche
</pre>
167 30 yannick deroche
168 1 Laurent GUERBY
Il faut figer son interface WAN en shell: (option 8)
169 30 yannick deroche
170 30 yannick deroche
<pre>
171 45 yannick deroche
route del default
172 30 yannick deroche
</pre>
173 1 Laurent GUERBY
174 30 yannick deroche
Il faut ensuite ajouter le chemin d'accès à la GW, car avec une @IP en /32, la GW est "unreachable":
175 30 yannick deroche
176 30 yannick deroche
<pre>
177 45 yannick deroche
route add -net 91.224.148.0/32 -link -iface em0 (remplacer em0 par son nom d'interface WAN)
178 30 yannick deroche
</pre>
179 30 yannick deroche
180 30 yannick deroche
Il faut enfin définir sa GW par défaut:
181 30 yannick deroche
182 30 yannick deroche
<pre>
183 30 yannick deroche
route add default 91.224.148.0
184 30 yannick deroche
</pre>
185 30 yannick deroche
186 30 yannick deroche
NE PLUS MODIFIER LES PARAMETRES RESEAUX DE L'INTERFACE WAN PAR LA CONSOLE OU LA WEB-UI (uniquement en shell)
187 30 yannick deroche
188 30 yannick deroche
Si vous aller dans la web UI puis dans "diagnostique>routage", vous devriez voir votre oeuvre.
189 35 Matthieu Herrb
190 35 Matthieu Herrb
h3. OpenBSD
191 35 Matthieu Herrb
192 51 Matthieu Herrb
_<if>_ représente le nom de l'interface à configurer.
193 48 Matthieu Herrb
194 58 Matthieu Herrb
Pour IPv4 il faut ajouter la route explicite (/32) vers le routeur dans @/etc/hostname.<if>@:
195 51 Matthieu Herrb
196 1 Laurent GUERBY
<pre>
197 1 Laurent GUERBY
inet 91.224.149.DDD 255.255.255.255 NONE
198 58 Matthieu Herrb
inet6 2a03:7220:80XX:HH00::1 64
199 58 Matthieu Herrb
inet6 alias fe80::XX:HH
200 1 Laurent GUERBY
! route add 91.224.148.0/32 -link -iface <if>
201 51 Matthieu Herrb
</pre>
202 51 Matthieu Herrb
203 58 Matthieu Herrb
et dans @/etc/mygate@ :
204 51 Matthieu Herrb
<pre>
205 51 Matthieu Herrb
91.224.148.0
206 58 Matthieu Herrb
fe80::31%<if>
207 51 Matthieu Herrb
</pre>
208 46 Aymeric APLU
209 46 Aymeric APLU
h3. CentOS/RHEL
210 46 Aymeric APLU
211 46 Aymeric APLU
Modif IPv4 :
212 46 Aymeric APLU
213 46 Aymeric APLU
Dans : /etc/sysconfig/network-scripts/ifcfg-eth0 
214 46 Aymeric APLU
215 46 Aymeric APLU
<pre>
216 46 Aymeric APLU
NETMASK=255.255.255.255
217 46 Aymeric APLU
IPADDR=91.224.149.XXX
218 46 Aymeric APLU
</pre>
219 46 Aymeric APLU
220 46 Aymeric APLU
Dans : /etc/sysconfig/network-scripts/route-eth0 
221 46 Aymeric APLU
<pre>
222 46 Aymeric APLU
default via 91.224.148.0 dev eth0 onlink
223 46 Aymeric APLU
</pre>
224 46 Aymeric APLU
225 46 Aymeric APLU
h3. Windows (on ne sait jamais :-D)
226 46 Aymeric APLU
227 46 Aymeric APLU
<pre>
228 46 Aymeric APLU
route -p add GATEWAY mask 255.255.255.255 0.0.0.0 if INTERFACENUMBER
229 46 Aymeric APLU
route -p add 0.0.0.0 mask 0.0.0.0 GATEWAY
230 46 Aymeric APLU
</pre>