https://wiki.archlinux.org/api.php?action=feedcontributions&user=Sheep+42&feedformat=atomArchWiki - User contributions [en]2024-03-29T14:54:23ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Msmtp&diff=433467Msmtp2016-04-30T15:35:10Z<p>Sheep 42: Undo revision 433466 by Sheep 42 (talk)</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Email clients]]<br />
[[Category:Mail server]]<br />
[[ja:Msmtp]]<br />
{{Related articles start}}<br />
{{Related|mutt}}<br />
{{Related|OfflineIMAP}}<br />
{{Related articles end}}<br />
<br />
[http://msmtp.sourceforge.net/ msmtp] is a very simple and easy to use SMTP client with fairly complete [[Wikipedia:sendmail|sendmail]] compatibility.<br />
<br />
== Installing ==<br />
<br />
msmtp can be [[installed]] with the package {{Pkg|msmtp}}. Additionally install {{Pkg|msmtp-mta}} that creates a sendmail alias to msmtp.<br />
<br />
== Basic setup ==<br />
<br />
The following is an example of a msmtp configuration (the file is based on the packaged, regular-user, example located at {{ic|/usr/share/doc/msmtp/msmtprc-user.example}}; the system configuration file belongs at {{ic|/etc/msmtprc}} and it's example is located at {{ic|/usr/share/doc/msmtp/msmtprc-system.example}}):<br />
<br />
{{hc|~/.msmtprc|<br />
# Set default values for all following accounts.<br />
defaults<br />
auth on<br />
tls on<br />
tls_trust_file /etc/ssl/certs/ca-certificates.crt<br />
logfile ~/.msmtp.log<br />
<br />
# Gmail<br />
account gmail<br />
host smtp.gmail.com<br />
port 587<br />
from ''username''@gmail.com<br />
user ''username''<br />
password ''plain-text-password''<br />
<br />
# A freemail service<br />
account freemail<br />
host smtp.freemail.example<br />
from joe_smith@freemail.example<br />
...<br />
<br />
# Set a default account<br />
account default : gmail<br />
}}<br />
<br />
{{Note|If you are using SSL/TLS and receive a "Server sent empty reply" error message, see [[#Server sent empty reply]].}}<br />
<br />
The ''user'' configuration file must be explicitly readable/writeable to only it's owner or msmtp will fail:<br />
<br />
$ chmod 600 ~/.msmtprc<br />
<br />
To avoid saving the password in plain text in the configuration file, use ''passwordeval'' to launch an external program. This example using Gnu PG is commonly used to perform decryption of a password:<br />
<br />
echo -e "password\n" | gpg --encrypt -o .msmtp-gmail.gpg # enter id (email...)<br />
<br />
{{Warning |Most shells save command history(e.g. .bash_history .zhistory). To avoid this, use gpg with shell stdin:<br />
<code>gpg --encrypt -o .msmtp-gmail.gpg -r <email> -</code>. The ending dash is not a typo, rather it causes gpg to use stdin. After running that snippet of code, type in your password, press enter, and press Control-d so gpg can encrypt your password.}}<br />
<br />
{{hc|~/.msmtprc|<br />
passwordeval "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.msmtp-gmail.gpg"<br />
}}<br />
<br />
== Using the mail command ==<br />
<br />
To send mails using the {{ic|mail}} command you must install the package {{Pkg|s-nail}}. Either install {{Pkg|msmtp-mta}} or edit {{ic|/etc/mail.rc}} to set sendmail client:<br />
<br />
{{hc|/etc/mail.rc|2=set sendmail=/usr/bin/msmtp}}<br />
<br />
A {{ic|.msmtprc}} file will need to be in the home of every user who want to send mail or alternatively the system wide {{ic|/etc/msmtprc}} can be used.<br />
<br />
msmtp also understands aliases. Add the following line to the defaults section of msmtprc or your local configuration file:<br />
<br />
{{hc|/etc/msmtprc|2=aliases /etc/aliases}}<br />
<br />
and create an aliases file in {{ic|/etc}}<br />
<br />
{{hc|/etc/aliases|2=# Example aliases file<br />
<br />
# Send root to Joe and Jane<br />
root: joe_smith@example.com, jane_chang@example.com<br />
<br />
# Send everything else to admin<br />
default: admin@domain.example}}<br />
<br />
== Test functionality ==<br />
<br />
The account option ({{ic|1=--account=,-a}} tells which account to use as sender:<br />
<br />
$ echo "hello there username." | msmtp -a default ''username''@domain.com<br />
<br />
Or, with the addresses in a file:<br />
<br />
To: ''username''@domain.com<br />
From: ''username''@gmail.com<br />
Subject: A test<br />
<br />
Hello there.<br />
<br />
$ cat test.mail | msmtp -a default <username>@domain.com<br />
<br />
{{Tip|If using Gmail you'll need to allow "Less Secure Apps" in ''Settings'' > ''Security''. Make sure to sign out of your other Gmail accounts first because the security settings part of Google Accounts can not manage concurrent sessions of more than one account.}}<br />
<br />
== Cronie default email client ==<br />
<br />
{{Out of date|Arch uses [[systemd/Timers]] instead of cronie}}<br />
<br />
To make {{Pkg|cronie}} use msmtp rather than sendmail, make sure {{Pkg|msmtp-mta}} is installed, or edit the {{ic|cronie.service}} systemd unit:<br />
<br />
{{hc|/etc/systemd/system/cronie.service.d/msmtp.conf|[Service]<br />
ExecStart&#61;<br />
ExecStart&#61;/usr/bin/crond -n -m '/usr/bin/msmtp -t'}}<br />
<br />
Then you must tell cronie or msmtp what your email address is, either by:<br />
<br />
# Add to {{ic|/etc/msmtprc}}: {{bc|aliases /etc/aliases}} and create {{ic|/etc/aliases}}: {{bc|your_username: email@address.com}}&mdash; OR &mdash;.<br />
* Add a {{ic|MAILTO}} line to the crontab: {{bc|MAILTO&#61;email@address.com}}<br />
<br />
== Miscellaneous ==<br />
<br />
Other details.<br />
<br />
=== Practical password management ===<br />
<br />
The {{Ic|password}} directive may be omitted. In that case, if the account in question has {{Ic|auth}} set to a legitimate value other than {{Ic|off}}, invoking msmtp from an interactive shell will ask for the password before sending mail. msmtp will not prompt if it has been called by another type of application, such as [[Mutt]].<br />
There is a solution for such cases: the {{ic|--passwordeval}} parameter.<br />
You can call msmtp to use an external keyring tool like gpg:<br />
{{bc|msmtp --passwordeval 'gpg -d mypwfile.gpg'}}<br />
If gpg prompt for the passphrase cannot be issued (e.g. when called from Mutt) then start the [[GPG#gpg-agent|gpg-agent]] before.<br />
<br />
A simple hack to start the agent is to execute a external command in your muttrc.<br />
{{Note| Mutt uses the backtick {{ic| ` command ` }} syntax to execute external commands}}<br />
<br />
For example, you can put something like the following in your muttrc<br />
<br />
{{hc|muttrc|set my_msmtp_pass&#61;`gpg -d mypwfile.gpg`}}<br />
<br />
Mutt will execute this when it starts, gpg-agent will cache your password, msmtp will be happy and you can send mail. <br />
{{Note| If you do this, you will have to restart mutt after gpg-agent clears the password to start sending emails again}}<br />
<br />
If you cannot use a keyring tool for any reason, you may want to use the password directly. There is a patched version {{AUR|msmtp-pwpatched}}{{Broken package link|{{aur-mirror|msmtp-pwpatched}}}} in the AUR that provides the {{ic|--password}} parameter. Note that it is a '''huge security flaw''', since any user connected to you machine can see the parameter of any command (in the /proc filesystem for example).<br />
<br />
If this is not desired, an alternative is to place passwords in {{ic|~/.netrc}}, a file that can act as a common pool for msmtp, [[OfflineIMAP]], and associated tools.<br />
<br />
===Using msmtp offline===<br />
<br />
Although msmtp is great, it requires that you be online to use it. This isn't ideal for people on laptops with intermittent connections to the Internet or dialup users. Several scripts have been written to remedy this fact, collectively called msmtpqueue.<br />
<br />
The scripts are installed under {{ic|/usr/share/doc/msmtp/msmtpqueue}}. You might want to copy the scripts to a convenient location on your computer, ({{ic|/usr/local/bin}} is a good choice).<br />
<br />
Finally, change your MUA to use msmtp-enqueue.sh instead of msmtp when sending e-mail. By default, queued messages will be stored in {{ic|~/.msmtpqueue}}. To change this location, change the {{ic|QUEUEDIR&#61;$HOME/.msmtpqueue}} line in the scripts (or delete the line, and export the QUEUEDIR variable in {{ic|.bash_profile}} like so: {{ic|export QUEUEDIR&#61;"$XDG_DATA_HOME/msmtpqueue"}}). <br />
<br />
When you want to send any mail that you've created and queued up run:<br />
$ /usr/local/bin/msmtp-runqueue.sh<br />
<br />
Adding {{ic|/usr/local/bin}} to your PATH can save you some keystrokes if you're doing it manually. The README file that comes with the scripts has some handy information, reading it is recommended.<br />
<br />
===Vim syntax highlighting===<br />
The msmtp source distribution includes a {{ic|msmtprc}} highlighting script for [[Vim]]. Install it from {{ic|./scripts/vim/msmtp.vim}}.<br />
<br />
===Send mail with PHP using msmtp===<br />
Look for ''sendmail_path'' option in your {{ic|php.ini}} and edit like this:<br />
{{bc|1=<br />
sendmail_path = "/usr/bin/msmtp -C /path/to/your/config -t"<br />
}}<br />
<br />
Note that you '''can not''' use a user configuration file (ie: one under ~/) if you plan on using msmtp as a sendmail replacement with php or something similar.<br />
In that case just create /etc/msmtprc, and remove your user configuration (or not if you plan on using it for something else). Also make sure it's readable by whatever you're using it with (php, django, etc...)<br />
<br />
From the msmtp manual: ''Accounts defined in the user configuration file override accounts from the system configuration file. The user configuration file must have no more permissions than user read/write''<br />
<br />
So it's impossible to have a conf file under ~/ and have it still be readable by the php user.<br />
<br />
To test it place this file in your php enabled server or using php-cli.<br />
{{bc|<br />
<?php<br />
mail("your@email.com", "Test email from PHP", "msmtp as sendmail for PHP");<br />
?><br />
}}<br />
<br />
==Troubleshooting==<br />
===Issues with TLS===<br />
If you see the following message:<br />
msmtp: TLS certificate verification failed: the certificate hasn't got a known issuer<br />
it probably means your tls_trust_file is not right.<br />
<br />
Just follow the [http://msmtp.sourceforge.net/doc/msmtp.html#Transport-Layer-Security fine manual]. It explains you how to find out the server certificate issuer of a given smtp server. Then you can explore the {{ic|/usr/share/ca-certificates/}} directory to find out if by any chance, the certificate you need is there. If not, you will have to get the certificate on your own. If you are using your own certificate, you can make msmtp trust it by adding the following to your '''~/.msmtprc''':<br />
<br />
tls_fingerprint <SHA1 (recommended) or MD5 fingerprint of the certificate><br />
<br />
If you are trying to send mail through GMail and are receiving this error, have a look at [http://www.mail-archive.com/msmtp-users@lists.sourceforge.net/msg00141.html this] thread or just use the second GMail example above.<br />
<br />
If you are completely desperate, but are 100% sure you are communicating with the right server, you can always temporarily disable the cert check:<br />
$ msmtp --tls-certcheck off<br />
<br />
If you see the following message:<br />
msmtp: TLS handshake failed: the operation timed out<br />
You may be affected by this [https://bugs.archlinux.org/task/44994 bug]. Recompile with "--with-ssl=openssl" (msmtp is compiled with GnuTLS by default).<br />
<br />
===Server sent empty reply===<br />
If you get a "server sent empty reply" error, add the following line to '''~/.msmtprc''':<br />
<br />
tls_starttls off<br />
<br />
This allows msmtp to use SSL/TLS (port 465) in place of STARTTLS (port 587) [https://www.fastmail.com/help/technical/ssltlsstarttls.html].<br />
<br />
===Issues with GSSAPI===<br />
<br />
If you get the following error<br />
<br />
GNU SASL: GSSAPI error in client while negotiating security context in gss_init_sec_context() in SASL library. This is most likely due insufficient credentials or malicious interactions.<br />
<br />
Try changing your auth setting to plain, instead of gssapi in your .msmtprc file [https://bbs.archlinux.org/viewtopic.php?id=138727]:<br />
<br />
auth plain</div>Sheep 42https://wiki.archlinux.org/index.php?title=Msmtp&diff=433466Msmtp2016-04-30T15:33:56Z<p>Sheep 42: /* Basic setup */ add "auth on"</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Email clients]]<br />
[[Category:Mail server]]<br />
[[ja:Msmtp]]<br />
{{Related articles start}}<br />
{{Related|mutt}}<br />
{{Related|OfflineIMAP}}<br />
{{Related articles end}}<br />
<br />
[http://msmtp.sourceforge.net/ msmtp] is a very simple and easy to use SMTP client with fairly complete [[Wikipedia:sendmail|sendmail]] compatibility.<br />
<br />
== Installing ==<br />
<br />
msmtp can be [[installed]] with the package {{Pkg|msmtp}}. Additionally install {{Pkg|msmtp-mta}} that creates a sendmail alias to msmtp.<br />
<br />
== Basic setup ==<br />
<br />
The following is an example of a msmtp configuration (the file is based on the packaged, regular-user, example located at {{ic|/usr/share/doc/msmtp/msmtprc-user.example}}; the system configuration file belongs at {{ic|/etc/msmtprc}} and it's example is located at {{ic|/usr/share/doc/msmtp/msmtprc-system.example}}):<br />
<br />
{{hc|~/.msmtprc|<br />
# Set default values for all following accounts.<br />
defaults<br />
auth on<br />
tls on<br />
tls_trust_file /etc/ssl/certs/ca-certificates.crt<br />
logfile ~/.msmtp.log<br />
<br />
# Gmail<br />
account gmail<br />
host smtp.gmail.com<br />
port 587<br />
from ''username''@gmail.com<br />
user ''username''<br />
auth on<br />
password ''plain-text-password''<br />
<br />
# A freemail service<br />
account freemail<br />
host smtp.freemail.example<br />
from joe_smith@freemail.example<br />
...<br />
<br />
# Set a default account<br />
account default : gmail<br />
}}<br />
<br />
{{Note|If you are using SSL/TLS and receive a "Server sent empty reply" error message, see [[#Server sent empty reply]].}}<br />
<br />
The ''user'' configuration file must be explicitly readable/writeable to only it's owner or msmtp will fail:<br />
<br />
$ chmod 600 ~/.msmtprc<br />
<br />
To avoid saving the password in plain text in the configuration file, use ''passwordeval'' to launch an external program. This example using Gnu PG is commonly used to perform decryption of a password:<br />
<br />
echo -e "password\n" | gpg --encrypt -o .msmtp-gmail.gpg # enter id (email...)<br />
<br />
{{Warning |Most shells save command history(e.g. .bash_history .zhistory). To avoid this, use gpg with shell stdin:<br />
<code>gpg --encrypt -o .msmtp-gmail.gpg -r <email> -</code>. The ending dash is not a typo, rather it causes gpg to use stdin. After running that snippet of code, type in your password, press enter, and press Control-d so gpg can encrypt your password.}}<br />
<br />
{{hc|~/.msmtprc|<br />
passwordeval "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.msmtp-gmail.gpg"<br />
}}<br />
<br />
== Using the mail command ==<br />
<br />
To send mails using the {{ic|mail}} command you must install the package {{Pkg|s-nail}}. Either install {{Pkg|msmtp-mta}} or edit {{ic|/etc/mail.rc}} to set sendmail client:<br />
<br />
{{hc|/etc/mail.rc|2=set sendmail=/usr/bin/msmtp}}<br />
<br />
A {{ic|.msmtprc}} file will need to be in the home of every user who want to send mail or alternatively the system wide {{ic|/etc/msmtprc}} can be used.<br />
<br />
msmtp also understands aliases. Add the following line to the defaults section of msmtprc or your local configuration file:<br />
<br />
{{hc|/etc/msmtprc|2=aliases /etc/aliases}}<br />
<br />
and create an aliases file in {{ic|/etc}}<br />
<br />
{{hc|/etc/aliases|2=# Example aliases file<br />
<br />
# Send root to Joe and Jane<br />
root: joe_smith@example.com, jane_chang@example.com<br />
<br />
# Send everything else to admin<br />
default: admin@domain.example}}<br />
<br />
== Test functionality ==<br />
<br />
The account option ({{ic|1=--account=,-a}} tells which account to use as sender:<br />
<br />
$ echo "hello there username." | msmtp -a default ''username''@domain.com<br />
<br />
Or, with the addresses in a file:<br />
<br />
To: ''username''@domain.com<br />
From: ''username''@gmail.com<br />
Subject: A test<br />
<br />
Hello there.<br />
<br />
$ cat test.mail | msmtp -a default <username>@domain.com<br />
<br />
{{Tip|If using Gmail you'll need to allow "Less Secure Apps" in ''Settings'' > ''Security''. Make sure to sign out of your other Gmail accounts first because the security settings part of Google Accounts can not manage concurrent sessions of more than one account.}}<br />
<br />
== Cronie default email client ==<br />
<br />
{{Out of date|Arch uses [[systemd/Timers]] instead of cronie}}<br />
<br />
To make {{Pkg|cronie}} use msmtp rather than sendmail, make sure {{Pkg|msmtp-mta}} is installed, or edit the {{ic|cronie.service}} systemd unit:<br />
<br />
{{hc|/etc/systemd/system/cronie.service.d/msmtp.conf|[Service]<br />
ExecStart&#61;<br />
ExecStart&#61;/usr/bin/crond -n -m '/usr/bin/msmtp -t'}}<br />
<br />
Then you must tell cronie or msmtp what your email address is, either by:<br />
<br />
# Add to {{ic|/etc/msmtprc}}: {{bc|aliases /etc/aliases}} and create {{ic|/etc/aliases}}: {{bc|your_username: email@address.com}}&mdash; OR &mdash;.<br />
* Add a {{ic|MAILTO}} line to the crontab: {{bc|MAILTO&#61;email@address.com}}<br />
<br />
== Miscellaneous ==<br />
<br />
Other details.<br />
<br />
=== Practical password management ===<br />
<br />
The {{Ic|password}} directive may be omitted. In that case, if the account in question has {{Ic|auth}} set to a legitimate value other than {{Ic|off}}, invoking msmtp from an interactive shell will ask for the password before sending mail. msmtp will not prompt if it has been called by another type of application, such as [[Mutt]].<br />
There is a solution for such cases: the {{ic|--passwordeval}} parameter.<br />
You can call msmtp to use an external keyring tool like gpg:<br />
{{bc|msmtp --passwordeval 'gpg -d mypwfile.gpg'}}<br />
If gpg prompt for the passphrase cannot be issued (e.g. when called from Mutt) then start the [[GPG#gpg-agent|gpg-agent]] before.<br />
<br />
A simple hack to start the agent is to execute a external command in your muttrc.<br />
{{Note| Mutt uses the backtick {{ic| ` command ` }} syntax to execute external commands}}<br />
<br />
For example, you can put something like the following in your muttrc<br />
<br />
{{hc|muttrc|set my_msmtp_pass&#61;`gpg -d mypwfile.gpg`}}<br />
<br />
Mutt will execute this when it starts, gpg-agent will cache your password, msmtp will be happy and you can send mail. <br />
{{Note| If you do this, you will have to restart mutt after gpg-agent clears the password to start sending emails again}}<br />
<br />
If you cannot use a keyring tool for any reason, you may want to use the password directly. There is a patched version {{AUR|msmtp-pwpatched}}{{Broken package link|{{aur-mirror|msmtp-pwpatched}}}} in the AUR that provides the {{ic|--password}} parameter. Note that it is a '''huge security flaw''', since any user connected to you machine can see the parameter of any command (in the /proc filesystem for example).<br />
<br />
If this is not desired, an alternative is to place passwords in {{ic|~/.netrc}}, a file that can act as a common pool for msmtp, [[OfflineIMAP]], and associated tools.<br />
<br />
===Using msmtp offline===<br />
<br />
Although msmtp is great, it requires that you be online to use it. This isn't ideal for people on laptops with intermittent connections to the Internet or dialup users. Several scripts have been written to remedy this fact, collectively called msmtpqueue.<br />
<br />
The scripts are installed under {{ic|/usr/share/doc/msmtp/msmtpqueue}}. You might want to copy the scripts to a convenient location on your computer, ({{ic|/usr/local/bin}} is a good choice).<br />
<br />
Finally, change your MUA to use msmtp-enqueue.sh instead of msmtp when sending e-mail. By default, queued messages will be stored in {{ic|~/.msmtpqueue}}. To change this location, change the {{ic|QUEUEDIR&#61;$HOME/.msmtpqueue}} line in the scripts (or delete the line, and export the QUEUEDIR variable in {{ic|.bash_profile}} like so: {{ic|export QUEUEDIR&#61;"$XDG_DATA_HOME/msmtpqueue"}}). <br />
<br />
When you want to send any mail that you've created and queued up run:<br />
$ /usr/local/bin/msmtp-runqueue.sh<br />
<br />
Adding {{ic|/usr/local/bin}} to your PATH can save you some keystrokes if you're doing it manually. The README file that comes with the scripts has some handy information, reading it is recommended.<br />
<br />
===Vim syntax highlighting===<br />
The msmtp source distribution includes a {{ic|msmtprc}} highlighting script for [[Vim]]. Install it from {{ic|./scripts/vim/msmtp.vim}}.<br />
<br />
===Send mail with PHP using msmtp===<br />
Look for ''sendmail_path'' option in your {{ic|php.ini}} and edit like this:<br />
{{bc|1=<br />
sendmail_path = "/usr/bin/msmtp -C /path/to/your/config -t"<br />
}}<br />
<br />
Note that you '''can not''' use a user configuration file (ie: one under ~/) if you plan on using msmtp as a sendmail replacement with php or something similar.<br />
In that case just create /etc/msmtprc, and remove your user configuration (or not if you plan on using it for something else). Also make sure it's readable by whatever you're using it with (php, django, etc...)<br />
<br />
From the msmtp manual: ''Accounts defined in the user configuration file override accounts from the system configuration file. The user configuration file must have no more permissions than user read/write''<br />
<br />
So it's impossible to have a conf file under ~/ and have it still be readable by the php user.<br />
<br />
To test it place this file in your php enabled server or using php-cli.<br />
{{bc|<br />
<?php<br />
mail("your@email.com", "Test email from PHP", "msmtp as sendmail for PHP");<br />
?><br />
}}<br />
<br />
==Troubleshooting==<br />
===Issues with TLS===<br />
If you see the following message:<br />
msmtp: TLS certificate verification failed: the certificate hasn't got a known issuer<br />
it probably means your tls_trust_file is not right.<br />
<br />
Just follow the [http://msmtp.sourceforge.net/doc/msmtp.html#Transport-Layer-Security fine manual]. It explains you how to find out the server certificate issuer of a given smtp server. Then you can explore the {{ic|/usr/share/ca-certificates/}} directory to find out if by any chance, the certificate you need is there. If not, you will have to get the certificate on your own. If you are using your own certificate, you can make msmtp trust it by adding the following to your '''~/.msmtprc''':<br />
<br />
tls_fingerprint <SHA1 (recommended) or MD5 fingerprint of the certificate><br />
<br />
If you are trying to send mail through GMail and are receiving this error, have a look at [http://www.mail-archive.com/msmtp-users@lists.sourceforge.net/msg00141.html this] thread or just use the second GMail example above.<br />
<br />
If you are completely desperate, but are 100% sure you are communicating with the right server, you can always temporarily disable the cert check:<br />
$ msmtp --tls-certcheck off<br />
<br />
If you see the following message:<br />
msmtp: TLS handshake failed: the operation timed out<br />
You may be affected by this [https://bugs.archlinux.org/task/44994 bug]. Recompile with "--with-ssl=openssl" (msmtp is compiled with GnuTLS by default).<br />
<br />
===Server sent empty reply===<br />
If you get a "server sent empty reply" error, add the following line to '''~/.msmtprc''':<br />
<br />
tls_starttls off<br />
<br />
This allows msmtp to use SSL/TLS (port 465) in place of STARTTLS (port 587) [https://www.fastmail.com/help/technical/ssltlsstarttls.html].<br />
<br />
===Issues with GSSAPI===<br />
<br />
If you get the following error<br />
<br />
GNU SASL: GSSAPI error in client while negotiating security context in gss_init_sec_context() in SASL library. This is most likely due insufficient credentials or malicious interactions.<br />
<br />
Try changing your auth setting to plain, instead of gssapi in your .msmtprc file [https://bbs.archlinux.org/viewtopic.php?id=138727]:<br />
<br />
auth plain</div>Sheep 42https://wiki.archlinux.org/index.php?title=Network_configuration&diff=264029Network configuration2013-06-23T23:29:39Z<p>Sheep 42: /* Wired -> Wireless Failover */ Add missing ifenslave package.</p>
<hr />
<div>[[Category:Networking]]<br />
[[Category:Getting and installing Arch]]<br />
[[cs:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Configuring Network]]<br />
{{Article summary start}}<br />
{{Article summary text|A simple guide for setting up and troubleshooting network.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Networking overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Jumbo Frames}}<br />
{{Article summary wiki|Firewalls}}<br />
{{Article summary wiki|Samba}}<br />
{{Article summary wiki|Wireless Setup}}<br />
{{Article summary end}}<br />
<br />
This page explains how to set up a '''wired''' connection to a network. If you need to set up '''wireless''' networking see the [[Wireless_Setup|Wireless Setup]] page.<br />
<br />
== Check the connection ==<br />
{{Note|If you receive an error like {{ic|ping: icmp open socket: Operation not permitted}} when executing ping, try to re-install the {{ic|iputils}} package.}} <br />
<br />
Many times, the basic installation procedure has created a working network configuration. To check if this is so, use the following command:<br />
<br />
{{Note|The {{ic|-c 3}} option calls it three times. See {{ic|man ping}} for more information.}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|2=<br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms}}<br />
<br />
If it works, then you may only wish to personalize your settings from the options below.<br />
<br />
If the previous command complains about unknown hosts, it means that your machine was unable to resolve this domain name. It might be related to your service provider or your router/gateway. You can try pinging a static IP address to prove that your machine has access to the Internet.<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|2=<br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms}}<br />
<br />
{{Note|{{ic|8.8.8.8}} is a static address that is easy to remember. It is the address of Google's primary DNS server, therefore it can be considered reliable, and is generally not blocked by content filtering systems and proxies.}}<br />
<br />
If you are able to ping this address, you may try adding this nameserver to your {{ic|/etc/resolv.conf}} file.<br />
<br />
== Set the hostname ==<br />
<br />
A [[Wikipedia:Hostname|hostname]] is a unique name created to identify a machine on a network: it is configured in {{ic|/etc/hostname}}. The file can contain the system's domain name, if any. To set the hostname, do:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
This will put '''myhostname''' in {{ic|/etc/hostname}}.<br />
<br />
See {{ic|man 5 hostname}} and {{ic|man 1 hostnamectl}} for details.<br />
<br />
{{Note|<br />
*{{ic|hostnamectl}} supports FQDNs<br />
*You no longer need to edit {{ic|/etc/hosts}}, {{pkg|systemd}} will provide host name resolution, and is installed on all systems by default.}}<br />
<br />
To set the hostname temporarily (until a reboot), use the {{ic|hostname}} command from {{Pkg|inetutils}}:<br />
<br />
# hostname ''myhostname''<br />
<br />
== Device Driver ==<br />
<br />
=== Check the driver status ===<br />
<br />
Udev should detect your network interface card ([[Wikipedia:Network_interface_controller|NIC]]) and automatically load the necessary module at start up. Check the "Ethernet controller" entry (or similar) from the {{ic|lspci -v}} output. It should tell you which kernel module contains the driver for your network device. For example:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1}}<br />
<br />
Next, check that the driver was loaded via {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}}. For example:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
Skip the next section if the driver was loaded successfully. Otherwise, you will need to know which module is needed for your particular model.<br />
<br />
=== Load the device module ===<br />
<br />
Google for the right module/driver for the chipset. Once you know which module to use, you can [[Kernel modules#Loading|load it]] with:<br />
<br />
# modprobe ''module_name''<br />
<br />
If udev is not detecting and loading the proper module automatically during bootup, you can add it to a {{ic|*.conf}} file from the {{ic|/etc/modules-load.d/}} folder so that you do not need to {{ic|modprobe}} it every time you boot. For example, if {{ic|tg3}} is the network module:<br />
<br />
# tee /etc/modules-load.d/tg3.conf <<< "tg3"<br />
<br />
Other common modules are {{ic|8139too}} for cards with a Realtek chipset, or {{ic|sis900}} for cards with a SiS chipset.<br />
<br />
== Network Interfaces ==<br />
<br />
=== Device names ===<br />
<br />
For motherboards that have integrated NICs, it is important to have fixed device name. Many configuration problems are caused by interface name changing.<br />
<br />
[[Udev]] is responsible for which device gets which name. Systemd v197 introduced [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames Predictable Network Interface Names], which automatically assigns static names to network devices. Interfaces are now prefixed with en (ethernet), wl (WLAN), or ww (WWAN) followed by an automatically generated identifier, creating an entry such as {{ic|enp0s25}}. <br />
<br />
This behavior may be disabled by adding a symlink:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
Users upgrading from an earlier systemd version will have a blank rules file created automatically. So if you want to use persistent device names, just delete the file.<br />
<br />
==== Change device name ====<br />
You can change the device name by defining the name manually with an udev-rule. For example: <br />
{{hc|/etc/udev/rules.d/10-network.rules|2=<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"}}<br />
A couple things to note:<br />
<br />
* To get the MAC address of each card, use this command: {{ic|cat /sys/class/net/'''device-name'''/address}}<!-- {{ic|<nowiki>udevadm info -a -p /sys/class/net/<yourdevice> | grep address | tr [A-Z] [a-z]</nowiki>}} --><br />
* Make sure to use the lower-case hex values in your udev rules. It doesn't like upper-case. <br />
{{Note|When choosing the static names '''it should be avoided to use names in the format of "eth''X''" and "wlan''X''"''', because this may lead to race conditions between the kernel and udev during boot. Instead, it is better to use interface names that are not used by the kernel as default, e.g.: {{ic|net0}}, {{ic|net1}}, {{ic|wifi0}}, {{ic|wifi1}}. For further details please see the [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] documentation.}}<br />
<br />
=== Get current device names ===<br />
<br />
Current NIC names can be found via sysfs<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0}}<br />
<br />
=== Enabling and disabling network interfaces ===<br />
<br />
You can activate or deactivate network interfaces using:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
To check the result:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
[...]}}<br />
<br />
== Configure the IP address ==<br />
<br />
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.<br />
<br />
=== Dynamic IP address ===<br />
<br />
==== Manually run DHCP Client Daemon ====<br />
<br />
Please note that {{ic|dhcpcd}} is not {{ic|dhcpd}}.<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds}}<br />
<br />
And now, {{ic|ip addr show dev eth0}} should show your inet address.<br />
<br />
For some people, {{ic|dhclient}} (from the {{Pkg|dhclient}} package) works where {{ic|dhcpcd}} fails.<br />
<br />
==== Run DHCP at boot ====<br />
<br />
If you simply want to use DHCP for your Ethernet connection, you can use {{ic|dhcpcd@.service}} (provided by the {{Pkg|dhcpcd}} package).<br />
<br />
To start DHCP for {{ic|eth0}}, simply use:<br />
<br />
# systemctl start dhcpcd@eth0<br />
<br />
You can enable the service to automatically start at boot with:<br />
<br />
# systemctl enable dhcpcd@eth0<br />
<br />
If the dhcpd service starts before your network card module ({{bug|30235}}), manually add your network card to {{ic|/etc/modules-load.d/*.conf}}. For example, if your Realtek card needs {{ic|r8169}} to be loaded, create:<br />
<br />
{{hc|/etc/modules-load.d/realtek.conf|<br />
r8169}}<br />
<br />
{{Tip|To find out which modules are used by your network card, use {{ic|lspci -k}}.}}<br />
<br />
If you use DHCP and you do '''not''' want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of {{ic|dhcpcd.conf}}:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf}}<br />
<br />
To prevent {{ic|dhcpcd}} from adding domain name servers to {{ic|/etc/resolv.conf}}, use the {{ic|nooption}} option:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers}}<br />
<br />
Then add your own DNS name server to {{ic|/etc/resolv.conf}}.<br />
<br />
You may use the {{Pkg|openresolv}} package if several different processes want to control {{ic|/etc/resolv.conf}} (e.g. {{Pkg|dhcpcd}} and a VPN client). No additional configuration for {{Pkg|dhcpcd}} is needed to use {{Pkg|openresolv}}.<br />
<br />
=== Static IP address ===<br />
<br />
There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability with unchanging addresses, or you may not have a DHCP server available.<br />
<br />
{{Note|If you share your Internet connection from a Windows machine without a router, be sure to use static IP addresses on both computers to avoid LAN problems.}}<br />
<br />
You need:<br />
<br />
* Static IP address<br />
* [[Wikipedia:Subnetwork|Subnet mask]]<br />
* [[Wikipedia:Broadcast_address|Broadcast address]]<br />
* [[Wikipedia:Default_gateway|Gateway]]'s IP address<br />
<br />
If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a subnet mask of 255.255.255.0 and a broadcast address of 192.168.*.255. The gateway is usually 192.168.*.1 or 192.168.*.254.<br />
<br />
==== Manual assignment ====<br />
<br />
You can assign a static IP address in the console:<br />
<br />
# ip addr add <IP address>/<subnet mask> dev <interface><br />
<br />
For example:<br />
<br />
# ip addr add 192.168.1.2/24 dev eth0<br />
<br />
{{Note|The subnet mask was specified using [[Wikipedia:CIDR_notation|CIDR notation]].}}<br />
<br />
For more options, see {{ic|man ip}}.<br />
<br />
Add your gateway like so:<br />
<br />
# ip route add default via <default gateway IP address><br />
<br />
For example:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
If you the get the error "No such process", it means you have to run {{ic|ip link set dev eth0 up}} as root.<br />
<br />
====Manual connection at boot using systemd====<br />
This section details how to manually connect using [[systemd]].<br />
<br />
{{Note|We use {{ic|net0}} as the interface name in these examples, you have to replace all occurrences (including those in the {{ic|BindsTo}} and {{ic|After}} values) with the name of the interface you are configuring.}}<br />
<br />
=====Using [[dhcpcd]]=====<br />
Create the file {{ic|/etc/systemd/system/network.service}} using your editor of choice. This example uses [[wpa_supplicant]].<br />
{{hc|/etc/systemd/system/network.service|<nowiki><br />
[Unit]<br />
Description=Network Connectivity<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-net0.device<br />
After=sys-subsystem-net-devices-net0.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
ExecStart=/usr/bin/ip link set dev net0 up<br />
ExecStart=/usr/bin/wpa_supplicant -B -i net0 -c /etc/wpa_supplicant.conf # Remove this for wired connections<br />
ExecStart=/usr/bin/dhcpcd net0<br />
<br />
ExecStop=/usr/bin/dhcpcd -k net0<br />
ExecStop=/usr/bin/ip addr flush dev net0<br />
ExecStop=/usr/bin/ip link set dev net0 down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
# systemctl enable network<br />
<br />
To test, reboot or stop all other network daemons and run as root:<br />
# systemctl start network<br />
<br />
=====Using a static IP address=====<br />
Create the file {{ic|/etc/systemd/system/network.service}} using your editor of choice. This example uses a static IP address and [[wpa_supplicant]].<br />
{{hc|/etc/systemd/system/network.service|<nowiki><br />
[Unit]<br />
Description=Wireless Static IP Connectivity<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-net0.device<br />
After=sys-subsystem-net-devices-net0.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
ExecStart=/usr/bin/ip link set dev net0 up<br />
ExecStart=/usr/bin/wpa_supplicant -B -i net0 -c /etc/wpa_supplicant.conf # Remove this for wired connections<br />
ExecStart=/usr/bin/ip addr add 192.168.0.10/24 dev net0<br />
ExecStart=/usr/bin/ip route add default via 192.168.0.1<br />
<br />
ExecStop=/usr/bin/ip addr flush dev net0<br />
ExecStop=/usr/bin/ip link set dev net0 down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
Do not forget to enable it!<br />
# systemctl enable network<br />
<br />
To test, reboot or make sure all other network daemons are stopped and then run as root<br />
# systemctl start network<br />
<br />
==== Calculating addresses ====<br />
<br />
You can use {{ic|ipcalc}} provided by the {{Pkg|ipcalc}} package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. For example, I use ethernet over firewire to connect a windows machine to arch. For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it. To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|2=<br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet}}<br />
<br />
== Load configuration ==<br />
<br />
To test your settings either reboot the computer or reload the relevant systemd services:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== Additional settings ==<br />
<br />
=== ifplugd for laptops ===<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding or LAG ===<br />
<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
copy {{ic|/etc/netctl/examples/bonding}} to {{ic|/etc/netctl/bonding}} and edit it, for example, to be the following: <br />
<br />
{{hc|/etc/netctl/bonding|2=<br />
Description='Bond Interface'<br />
Interface='bond0'<br />
Connection=bond<br />
BindsToInterfaces=('eth0' 'eth1')<br />
IP=dhcp<br />
IP6=stateless}}<br />
<br />
Now you can disable and stop your old configuration and set bonding to be automaticly started:<br />
<br />
Disable your old configuration:<br />
# netctl stop ethernet<br />
# netctl disable ethernet<br />
Enable and start bonding:<br />
# netctl start bonding<br />
# netctl enable bonding<br />
<br />
{{Note|To change the bonding mode (default is round robin) to, e.g, active backup:<br />
<br />
Create {{ic|/etc/modprobe.d/bonding.conf}}:<br />
<br />
{{hc|/etc/modprobe.d/bonding.conf|2=<br />
options bonding mode=2<br />
options bonding miimon=100}}<br />
<br />
For more information about the different bonding policies (and other driver settings) see the [http://sourceforge.net/projects/bonding/files/Documentation/ Linux Ethernet Bonding Driver HOWTO] and [http://www.linuxfoundation.org/collaborate/workgroups/networking/bonding The Linux Foundation: bonding].}}<br />
<br />
To check the status and bonding mode:<br />
<br />
$ cat /proc/net/bonding/bond0<br />
<br />
==== Wired -> Wireless Failover ====<br />
<br />
Using {{ic|bonding}} to fallback to wireless when the wired ethernet goes down, this also detects the presence of either network connection and starts dhcpcd when either or both are connected.<br />
<br />
You'll need {{Pkg|netctl}}, {{Pkg|ifplugd}}, {{Pkg|ifenslave}}, and {{Pkg|wpa_supplicant}} from the official repositories.<br />
<br />
First configure the bonding driver to use active-backup:<br />
<br />
{{hc|/etc/modprobe.d/bonding.conf|2=<br />
options bonding mode=active-backup<br />
options bonding miimon=100<br />
options bonding primary=eth0<br />
options bonding max_bonds=0}}<br />
<br />
The `max-bonds` line avoids getting the "Interface bond0 already exists" error.<br />
<br />
Next, configure a {{Pkg|netctl}} profile to enslave the two hardware interfaces:<br />
<br />
{{hc|/etc/netctl/failover|2=<br />
Description='A wired connection with failover to wireless'<br />
Interface='bond0'<br />
Connection=bond<br />
BindsToInterfaces=('eth0' 'wlan0')<br />
IP='no'<br />
SkipNoCarrier='no'}}<br />
<br />
Enable the profile on startup.<br />
<br />
# netctl enable failover<br />
<br />
Configure wpa_supplicant to associate with known networks. This can be done with a netctl profile (remember to use IP='no'), a wpa_supplicant service running constantly, or on-demand with wpa_cli. Ways to do this are covered on the [[wpa_supplicant]] page.<br />
<br />
Create an {{Pkg|ifplugd}} action for automatic DHCP assignment on the bonded interface:<br />
<br />
{{hc|/etc/ifplugd/bond_dhcp.action|2=<br />
#!/bin/sh<br />
<br />
case "$2" in<br />
up)<br />
systemctl start "dhcpcd@$1.service" && exit 0<br />
;;<br />
down)<br />
systemctl stop "dhcpcd@$1.service" && exit 0<br />
;;<br />
*)<br />
echo "Wrong arguments" > /dev/stderr<br />
;;<br />
esac<br />
exit 1}}<br />
<br />
and make it executable<br />
<br />
# chmod +x /etc/ifplugd/bond_dhcp.action<br />
<br />
Then create the [[systemd]] service which starts ifplugd for bond0:<br />
<br />
{{hc|/etc/systemd/system/net-auto-bonded@.service|2=<br />
[Unit]<br />
Description=Provides automatic dhcp resolution for bonded failover connection<br />
Requires=netctl@failover.service<br />
After=netctl@failover.service<br />
<br />
[Service]<br />
ExecStart=/usr/bin/ifplugd -i %i -r /etc/ifplugd/bond_dhcp.action -fIns<br />
<br />
[Install]<br />
WantedBy=multi-user.target}}<br />
<br />
Enable the net-auto-bonded service and reboot:<br />
<br />
# systemctl enable net-auto-bonded@bond0.service<br />
# reboot<br />
<br />
If you have a wired and wireless connection to the same network, you can probably now disconnect and reconnect the wired connection without losing connectivity. In most cases, even streaming music won't skip!<br />
<br />
=== IP address aliasing ===<br />
<br />
IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose.<br />
<br />
To use IP aliasing from [[netcfg]], change {{ic|POST_UP}} and {{ic|PRE_DOWN}} commands in your network profile to set up the additional IP addresses manually. See [https://bbs.archlinux.org/viewtopic.php?pid=1036395#p1036395 here] for details.<br />
<br />
==== Example ====<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
Prepare the configuration:<br />
<br />
{{hc|/etc/netctl/mynetwork|2=<br />
<br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
Donain=''<br />
}}<br />
Then simply execute: <br />
<br />
$ netctl start mynetwork<br />
<br />
=== Change MAC/hardware address ===<br />
<br />
See [[MAC Address Spoofing]].<br />
<br />
=== Internet Share ===<br />
<br />
See [[Internet Share]].<br />
<br />
=== Router Configuration ===<br />
<br />
See [[Router]].<br />
<br />
== Troubleshooting ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Most domestic cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br><small>This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.</small><br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#For DHCP assigned IP address]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== PC Pingable by IP but not by hostname? ===<br />
This issue hunted me for months! Turns out to be a very simple fix IF you are using samba as well. Usually people only start smbd which is enough for network access to work, but does not advocate the pc's name to the router. nmbd is doing that so you should always have:<br />
systemctl enable smbd.service<br />
systemctl enable nmbd.service<br />
<br />
Which makes them run at startup. If you don't want to restart then you can start then right away with:<br />
systemctl start smbd.service<br />
systemctl start nmbd.service<br />
<br />
And that makes the computer available by name on the network.</div>Sheep 42