Hello à toutes et tous,
Avec ce scripts, j’aimerais lancer ma connexion en dhcp derrière l’ont d’Orange .
Je suis loin de maîtriser l’écriture de scripts.
La preuve j’ai besoin d’aide
#!/bin/bash
#Converti le fti
USERNAME=$1
AUTHSTRING=00:00:00:00:00:00:00:00:00:00:00:66:74:69:2f
for (( i=0; i<${#USERNAME}; i++ )); do
HEXCHAR=$(echo -n ${USERNAME:$i:1} | od -An -txC | xargs)
AUTHSTRING=${AUTHSTRING}:${HEXCHAR}
done
echo ${AUTHSTRING};
#Fichier dhclient
#Ecriture
echo 'option rfc3118-authentication code 90 = string;" >> /diagbox/web/tmp/dhclient.conf
echo "interface \"orange\" {" >> /diagbox/web/tmp/dhclient.conf
echo "send vendor-class-identifier \"sagem\";" >> /diagbox/web/tmp/dhclient.conf
echo "send user-class \"+FSVDSL_livebox.Internet.softathome.Livebox3\";" >> /diagbox/web/tmp/dhclient.conf
echo "send rfc3118-authentication ${AUTHSTRING} ;" >> /diagbox/web/tmp/dhclient.conf
echo 'request subnet-mask, routers,' >> /diagbox/web/tmp/dhclient.conf
echo 'domain-name, broadcast-address, dhcp-lease-time,' >> /diagbox/web/tmp/dhclient.conf
echo 'dhcp-renewal-time, dhcp-rebinding-time,' >> /diagbox/web/tmp/dhclient.conf
echo 'rfc3118-authentication;' >> /diagbox/web/tmp/dhclient.conf
echo 'supersede domain-name-servers 8.8.8.8, 8.8.4.4;' >> /diagbox/web/tmp/dhclient.conf
echo '}' >> /diagbox/web/tmp/dhclient.conf
done
#Deplacement
if sudo cp /diagbox/web/tmp/dhclient.conf /etc/dhcp/dhclient.conf; then
echo 'fichier dhclient modifie';
else
echo "Echec déplacement fichier dhclient" >> /diagbox/web/tmp/error.log
exit
fi
#iptables
if sudo cp /etc/iptables.ipv4.nat.backup_rescue_dhcp /etc/iptables.ipv4.nat; then
echo 'fichier iptables modifié';
else
echo "Echec déplacement fichier iptables" >> /diagbox/web/tmp/error.log
exit
fi
sudo iptables -t mangle -I POSTROUTING -o orange -j CLASSIFY --set-class 0:1
#Modification interfaces eth0
if sudo ifdown eth0; then
echo 'arret eth0';
else
echo "Echec arret ethO" >> /diagbox/web/tmp/error.log
exit
fi
if sudo cp /etc/network/interfaces_RESCUE_DHCP /etc/network/interfaces; then
echo 'configuration interfaces modifié';
else
echo "Echec modification configuration ethO" >> /diagbox/web/tmp/error.log
exit
fi
if sudo ifup eth0; then
echo 'activation eth0';
else
echo "Echec activation ethO" >> /diagbox/web/tmp/error.log
exit
fi
#Test 8 pings
sudo ping 8.8.8.8 -c8 -q
if [ $? != 1 ]; then
echo "connexion derrière ont opérationnel" >> /diagbox/web/tmp/ping.txt
else
echo "nok" >> /diagbox/web/tmp/ping.txt
fi
en cherchant sur la toile, j’ai trouvé comment remplacer la Livebox en utilisant le protocole DHCP.
Quand je le fais manuellement, ça fonctionne.
Mais mon script me sort une erreur
root@diagbox:~# bash /diagbox/scripts_sh/speedtest_ont.sh adsl@adsl
/diagbox/scripts_sh/cnx_ont.sh: line 5: $'\r': command not found
/diagbox/scripts_sh/cnx_ont.sh: line 6: syntax error near unexpected token `$'do\r''
/diagbox/scripts_sh/cnx_ont.sh: line 6: `for (( i=0; i<${#USERNAME}; i++ ) '; do
Et je ne sais pas à quoi ça correspond lol.
Merci d’avance pour votre aide.