Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##########################################################
- ##### NETWORK ####
- ##########################################################
- Konfigurowanie interfejsu Ethernet
- Przewidywalne nazwy interfejsów sieciowych
- Używanie DHCP do automatycznego konfigurowania interfejsu
- Ręczne konfigurowanie interfejsu
- Ustawianie prędkości i dupleksu
- Interfejs bez adresu IP
- Definiowanie serwerów nazw (DNS)
- Plik konfiguracyjny resolv.conf
- Program resolvconf
- Konfiguracja DNS dla menedżera sieci
- Konfiguracja klienta DHCP
- Bridging
- Mostkowanie bez przełączania
- Howto use vlan (dot1q, 802.1q, trunk) (Etch, Lenny)
- Konfiguracja ręczna
- Konfiguracja skryptu sieciowego
- Mosty i sieci VLAN
- Zastrzega się przy stosowaniu mostkowania i vlan
- Jak stworzyć odporne na uszkodzenia wiązania z vlan (Etch)
- Konfiguracja sieci
- klejenie z aktywną kopią zapasową
- / etc / network / interfaces
- Jak ustawić MTU (Max transfer unit / packet size) za pomocą VLANS nad połączonym interfejsem
- Wiele adresów IP w jednym interfejsie
- Stara metoda
- Metoda iproute2
- Konfigurowanie interfejsu Ethernet
- Większość konfiguracji sieci można wykonać za pomocą pliku konfiguracyjnego interfejsów w / etc / network / interfaces . Tutaj możesz podać swojej karcie sieciowej adres IP (lub użyć dhcp), skonfigurować informacje o routingu, skonfigurować maskowanie IP, ustawić domyślne trasy i wiele więcej.
- Pamiętaj, aby dodać interfejsy, które mają zostać podniesione przy starcie systemu do linii "auto".
- Zobacz interfejsy człowiek, aby uzyskać więcej opcji.
- Przewidywalne nazwy interfejsów sieciowych
- Od wersji Stretch stare nazwy sieci, takie jak eth0, eth1, zniknęły, ponieważ nazwa urządzenia może się zmienić. Nowe nazwy są podobne do tych: enp6s0, enp8s0, enp0s31f6, enp5s0. Niestety, wykorzystywany system nadal jest nieco arbitralny, ponieważ opiera się na wyliczeniach BIOS-u, które zmieniają się w błędne BIOS-y i w niektórych sytuacjach. (To nie było oparte na zmniejszonej sumie sumy adresu MAC (2c: 56: ac: 39: ec: 0d staje się 98) lub inna podobna metoda jest zagadkowa (udev może robić takie rzeczy) i nazwy, które nam pozostały są raczej nieprzyjazne dla użytkownika).
- Dla osób korzystających z więcej niż jednego interfejsu sieciowego - będziemy musieli poradzić sobie z nowym systemem.
- Aby znaleźć nazwy interfejsów, zajrzyj tutaj: $ ls / sys / class / net /
- Aktualizowanie i przewidywanie nazw interfejsów sieciowych
- Uaktualnienia do wersji Stretch zachowują stare nazwy urządzeń - pomimo tego, co przeczytasz w Internecie - usunięcie /etc/udev/rules.d/70-local-persistent-net.rules nie da ci nowych nazw nawet po update-initramfs -u i update-grub. (jeszcze nie znalazłem poprawnych inkantacji Debiana?)
- Używanie DHCP do automatycznego konfigurowania interfejsu
- Jeśli używasz tylko protokołu DHCP, wszystko, czego potrzebujesz, to coś takiego:
- auto eth0
- allow-hotplug eth0
- iface eth0 inet dhcp
- W przypadku protokołu DHCPv6 (używanego do IPv6) dołącz także następującą sekcję iface
- iface eth0 inet6 dhcp
- Alternatywnie, protokół IPv6 może być automatycznie konfigurowany za pomocą automatycznej konfiguracji adresu bezstanowego lub SLAAC, który jest określony za pomocą funkcji auto zamiast dhcp w sekcji inet6 :
- iface eth0 inet6 auto
- Ręczne konfigurowanie interfejsu
- Jeśli konfigurujesz go ręcznie, wówczas coś takiego ustawi domyślną bramę (sieć, transmisja i brama są opcjonalne):
- auto eth0
- iface eth0 inet static
- adres 192.0.2.7
- maska sieci 255.255.255.0
- bramka 192.0.2.254
- Jeśli chcesz dodać również adres IPv6, dodaj coś takiego:
- iface eth0 inet6 static
- adres 2001: db8 :: c0ca: 1eaf
- maska sieci 64
- gateway 2001: db8 :: 1ead: ed: beef
- Zobacz interfejsy człowiek, aby uzyskać więcej opcji.
- Wyłącz wszystkie usługi DHCP, np. Dhcpcd .
- Ustawianie prędkości i dupleksu
- Automatyczna negocjacja wielokrotnie kończy się niepowodzeniem i często jest oznaką wadliwego okablowania, dlatego należy zbadać sprawy fizyczne, zanim uznają, że algorytmy autonegocjacji interfejsów są niezgodne. Jeśli wyłączysz automatyczną negocjację i ręcznie ustawisz szybkość i dupleks, interfejs partnera na drugim końcu kabla będzie zakładał, że brak automatycznej negocjacji wskazuje prędkość 10 Mb / s i dupleks połowy. Aby zapewnić bezbłędną pracę, jeśli ręcznie ustawisz prędkość i dupleks, musisz upewnić się, że dokładnie taka sama prędkość i dupleks są skonfigurowane w interfejsie partnera.
- Jeśli ustawisz prędkość i dupleks interfejsu ręcznie, może być wymagana próba i błąd. Oto podstawowe kroki:
- Zainstaluj pakiety ethtool i net-tools , aby mieć programy ettool i mii-tool . Jeden lub oba mogą działać dla twojego interfejsu.
- Upewnij się, że masz możliwość zalogowania się do systemu na wypadek, gdyby interfejs sieciowy stał się niefunkcjonalny. Połączenie SSH może zostać zakłócone, więc powinieneś mieć strategię awaryjną.
- Zidentyfikuj interfejs, o którym mowa (często będzie to eth0). Odpowiednio dostosuj pozostałą część instrukcji.
- Spróbuj określić, jakie są obecne ustawienia prędkości i dupleksu. W tym momencie robi się fajnie:
- Jako root, spróbuj najpierw ethtool eth0 i sprawdź, czy linie "Speed:" i "Duplex:" wyglądają poprawnie. W przeciwnym razie etykieta może nie być obsługiwana przez Twoje urządzenie.
- Jako root, wypróbuj mii-tool -v eth0 i zobacz, czy jego wyjście wygląda poprawnie. Jeśli nie, to Mii-narzędzie może nie być obsługiwane przez twoje urządzenie.
- Jeśli żaden z nich nie jest obsługiwany, może być konieczne ustawienie parametrów bezpośrednio w module sterownika jądra. Zidentyfikuj moduł sterownika, którego używasz, czytając dane wyjściowe dmesg i lsmod . Następnie możesz wypróbować modinfo MODULENAME, aby zobaczyć, jakie parametry zaakceptuje, jeśli takie istnieją. (Możesz użyć modinfo nawet w modułach, które nie są załadowane, dla porównania.) ToDo : gdzie ustawia się parametry modułu jądra?
- Następnie spróbuj zmienić ustawienia interfejsu podczas jego działania. Oczywiście musisz być rootem. Zarówno:
- ethtool -s eth0 speed 100 duplex full autoneg off (zakładając 100 Mbps i pełny dupleks)
- mii-tool -F 100baseTx-FD eth0 (samo założenie)
- W każdym przypadku sprawdź ponownie, czy ustawienia interfejsu rzeczywiście się zmieniły, a następnie spróbuj wysłać niektóre dane do systemu i wyjść z niego, aby sprawdzić, czy karta sieciowa działa poprawnie.
- Jeśli jedno z tych poleceń z powodzeniem ustawi twoją kartę sieciową, możesz umieścić ją w / etc / network / interfaces, aby działała po podniesieniu interfejsu (np. Przy starcie systemu). Jednak zanim to zrobisz, powinieneś zrozumieć, że niektóre sterowniki i urządzenia zachowują się inaczej niż inne. Po załadowaniu modułu sterownika karta sieciowa może rozpocząć autonegocjację bez żadnej możliwości jej zatrzymania (szczególnie w przypadku sterowników, które nie akceptują parametrów). Ustawienia z interfejsów są stosowane w pewnym momencie, które mogą znajdować się w samym środku negocjacji. Niektórzy uważają więc za konieczne opóźnienie polecenia ethtool lub mii-tool o kilka sekund. A zatem:
- iface eth0 inet static
- adres ...
- maska sieci ...
- brama ...
- spać 5; ethtool -s eth0 ...
- Lub analogiczne polecenie mii-tool .
- Zrestartuj komputer, aby upewnić się, że poprawnie wyświetlił się, i bądź gotowy do interwencji ręcznie (np. Ctrl-Alt-Del, a następnie uruchom tryb pojedynczego użytkownika z GRUB lub LILO), jeśli coś nie działa.
- Interfejs bez adresu IP
- Aby utworzyć interfejs sieciowy bez adresu IP, użyj metody ręcznej i użyj komend wstępnych i końcowych, aby zwiększyć lub zmniejszyć interfejs.
- iface eth0 inet manual
- pre-up ifconfig $ IFACE up
- post-down ifconfig $ IFACE w dół
- Jeśli interfejs jest interfejsem VLAN, polecenia góra / dół muszą być wykonywane po / przed haczykami vlan. (Musisz także zainstalować pakiet vlan .)
- iface eth0.99 inet manual
- post-up ifconfig $ IFACE up
- pre-down ifconfig $ IFACE w dół
- Uwaga: Jeśli tworzysz interfejs VLAN tylko po to, aby umieścić go w moście, nie ma potrzeby ręcznego definiowania interfejsu VLAN. Po prostu skonfiguruj most, a interfejs VLAN zostanie utworzony automatycznie podczas tworzenia mostu (patrz poniżej).
- Definiowanie serwerów nazw (DNS)
- Zanim komputer może połączyć się z zewnętrznym zasobem sieciowym (na przykład z serwerem WWW), musi mieć możliwość konwersji dowolnych nazw alfanumerycznych (np. Wiki.debian.org) na numeryczne adresy sieciowe (np. 140.211.166.4 ). (Internet używa tych strukturalnych numerycznych adresów IP jako adresów sieciowych.)
- Biblioteka C i inne biblioteki tłumaczeń szukają pliku /etc/resolv.conf dla listy serwerów nazw. W najprostszym przypadku jest to plik do edycji, aby ustawić listę serwerów nazw. Ale pamiętaj, że różne inne programy do dynamicznej konfiguracji z przyjemnością nadpisają twoje ustawienia:
- Program resolvconf
- Demon menedżera sieci
- Klienci DHCP
- W większości sytuacji plik do edycji jest plikiem konfiguracyjnym dla takiego programu.
- W najbardziej złożonych sytuacjach używanie resolvconf jest na prawdę właściwą drogą, chociaż w bardziej prostych konfiguracjach prawdopodobnie jest to przesada.
- Plik konfiguracyjny resolv.conf
- Plik konfiguracyjny resolv.conf w pliku /etc/resolv.conf zawiera informacje umożliwiające komputerowi podłączonemu do sieci rozpoznawanie nazw na adresy. (Uwaga: nie mylić tego pliku konfiguracyjnego z programem resolvconf , który niestety ma prawie identyczną nazwę).
- Plik resolv.conf zwykle zawiera adresy IP serwerów nazw (DNS resolveers), które będą próbowały tłumaczyć nazwy na adresy dla dowolnego węzła dostępnego w sieci. Pojawi się linia lub linie, które wyglądają tak:
- serwer nazw 12.34.56.78
- serwer nazw 12.34.56.79
- W tym przykładzie system używa serwerów nazw na adresach IP 12.34.56.78 i 12.34.56.79 . Po prostu edytuj plik i wprowadź adresy IP serwerów nazw, których musisz używać po każdym serwerze nazw . Dodaj więcej linii serwerów nazw , jeśli masz więcej serwerów nazw. Nie używaj tej metody, jeśli masz zainstalowany program resolvconf .
- Plik konfiguracyjny resolv.conf ma wiele innych opcji definiujących sposób wyszukiwania nazw przez repozytorium. Zobacz szczegóły man resolv.conf .
- Program resolvconf
- Program resolvconf śledzi informacje systemowe o aktualnie dostępnych serwerach nazw. Nie należy go mylić z plikiem konfiguracyjnym resolv.conf , który niestety ma prawie identyczną nazwę. Program resolvconf jest opcjonalny w systemie Debian.
- Plik konfiguracyjny resolv.conf zawiera informacje o serwerach nazw używanych przez system. Jednakże, gdy wiele programów musi dynamicznie modyfikować plik konfiguracyjny resolv.conf , mogą się ze sobą nawzajem łączyć i plik może stać się niesynchronizowany. Program resolvconf rozwiązuje ten problem. Działa jako pośrednik między programami, które dostarczają informacje o serwerze nazw (np. Klienci dhcp) i programami, które używają informacji o serwerze nazw (np. Resolver).
- Kiedy resolvconf jest poprawnie zainstalowany, plik konfiguracyjny resolv.conf w /etc/resolv.conf jest zamieniany przez dowiązanie symboliczne do /etc/resolvconf/run/resolv.conf, a zamiast tego resolver używa pliku konfiguracyjnego, który jest dynamicznie generowany przez resolvconf w /etc/resolvconf/run/resolv.conf .
- Program resolvconf jest zwykle potrzebny tylko wtedy, gdy system ma wiele programów, które muszą dynamicznie modyfikować informacje o serwerze nazw. W prostym systemie, w którym serwery nazw nie zmieniają się często lub są zmieniane tylko przez jeden program, plik konfiguracyjny resolv.conf jest odpowiedni.
- Jeśli zainstalowany jest program resolvconf , nie należy edytować pliku konfiguracyjnego resolv.conf ręcznie, ponieważ zostanie on dynamicznie zmieniony przez programy w systemie. Jeśli chcesz ręcznie zdefiniować serwery nazw (tak jak w przypadku interfejsu statycznego), dodaj linię podobną do następującej w pliku konfiguracyjnym interfejsów w / etc / network / interfaces :
- dns-nameservers 12.34.56.78 12.34.56.79
- Umieść linię wciętą wewnątrz zwrotki iface , np. Tuż za linią bramy . Wprowadź adresy IP serwerów nazw, których musisz użyć po dns-nameservers . Umieść wszystkie w jednej linii oddzielonej spacjami. Nie zapomnij o " s " na końcu dns-nameservers .
- Program resolvconf jest całkiem nowym dodatkiem do Debiana i wiele starszych programów wymaga aktualizacji lub rekonfiguracji, aby działały poprawnie. Jeśli masz problemy, zobacz / usr / share / doc / resolvconf / README . Zawiera mnóstwo informacji o tym, jak inne programy radzą sobie z resolvconf .
- Konfiguracja DNS dla menedżera sieci
- Menedżer sieci zastąpi ustawienia dhcp, zastępując resolv.conf, nawet jeśli skonfigurowałeś DNS w pliku /etc/dhcp/dhclient.conf, np. Powodując, że DNS najpierw przeszukuje domenę lokalną, co może wymagać czasu przed rozpoznaniem DNS, co powoduje długotrwałe DNS czasy rozwiązania. Możesz zorientować się, co NetworkManager uważa za ustawienia, wykonując polecenie nm-tool z linii poleceń.
- Możesz skonfigurować te ustawienia za pomocą graficznego interfejsu użytkownika, uruchamiając edytor połączeń nm, którego aktualnie (13.11.23) nie można znaleźć w Narzędziach systemowych → Administracja, ale należy go uruchomić ręcznie z wiersza poleceń. Po uruchomieniu:
- Wybierz połączenie (na karcie Wired lub Wireless) i kliknij Edytuj.
- Kliknij kartę Ustawienia IPv4
- Wybierz "Tylko adresy automatyczne (DHCP)" zamiast "Automatyczny (DHCP)".
- Wprowadź serwery DNS w polu "Serwery DNS", oddzielone spacjami (np. 208.67.222.222 dla OpenDNS).
- Kliknij "Zastosuj".
- NetworkManager zapisuje te ustawienia w / etc / NetworkManager / system-connections / name-of-connection . Przykład / etc / NetworkManager / system-connections / Wired connection 1 :
- [802-3-ethernet]
- duplex = pełny
- mac-address = XX: XX: XX: XX: XX: XX
- [połączenie]
- id = Połączenie przewodowe 1
- uuid = xxx-xxxxxx-xxxxxx-xxxxxx-xxx
- type = 802-3-ethernet
- timestamp = 1385213042
- [ipv6]
- method = auto
- [ipv4]
- method = auto
- dns = 208,67.222.222;
- ignore-auto-dns = true
- Ponowne uruchomienie narzędzia nm powinno pokazać, że NetworkManager ma teraz pojęcie, jak należy rozwiązać twój DNS.
- Konfiguracja klienta DHCP
- Przykład: dhclient3 używa /etc/dhcp/dhclient.conf . Ustawienie, które chcesz
- zastępuje nazwy domen-serwery 12.34.56.78, 12.34.56.79;
- lub może
- prepend nazwa-domeny-serwery 12.34.56.78, 12.34.56.79;
- Szczegóły znajdziesz na stronie podręcznika dhclient.conf (5).
- Bridging
- Mostkowanie powoduje umieszczenie wielu interfejsów w tym samym segmencie sieci. Jest to bardzo popularne przy podłączaniu serwera do wielu przełączników w celu uzyskania wysokiej dostępności lub wirtualizacji. W tym ostatnim przypadku zwykle służy do utworzenia mostu na hoście (np. Dom0) i umieszczenia wirtualnych interfejsów gości (domU) w moście.
- Przykład: Podłącz serwer do 2 przełączników (przez eth0 i eth1), definiując most 0 i nadaj serwerowi adres IP w tej podsieci:
- auto br0
- iface br0 inet static
- adres 10.10.0.15
- maska sieci 255.255.255.0
- bramka 10.10.0.1
- bridge_ports eth0 eth1
- w górę / usr / sbin / brctl stp br0 on
- Jeśli serwer jest podłączony do wielu przełączników, zwykle trzeba uruchomić protokół drzewa opinającego, aby uniknąć pętli. Dlatego STP musi być włączony za pomocą polecenia "w górę", jak pokazano powyżej.
- Przykład: Konfiguracja mostu bez konfiguracji adresu IP (użyj "manual" zamiast "static"), aby "przekazać dalej" interfejs do maszyny wirtualnej gościa. (Konfiguracja statycznego mostu zawiera tylko jeden interfejs fizyczny, interfejs wirtualny zostanie dodany do mostu po uruchomieniu maszyny wirtualnej).
- auto br1
- Instrukcja iface br1 inet
- bridge_ports eth4
- up / usr / sbin / brctl setageing br1 0
- w górę / usr / sbin / brctl stp br0 off
- Uwaga: Most linuxowy obsługuje tylko STP, bez RSTP (Rapid Spanning Tree). Dlatego obsługuje tylko stare koszty STP, a nie nowe koszty RSTP (patrz Spanning_Tree_Protocol ). Zazwyczaj jest to w porządku z przełącznikami Cisco, ale np. Przełączniki Juniper wykorzystują koszty RSTP, co może prowadzić do różnych obliczeń drzewa opinającego i problemów z pętlami. Można to naprawić, ustawiając koszty ręcznie, na przełączniku lub na serwerze. Ustawienie kosztu na przełączniku jest preferowane, ponieważ Linux przełącza się z powrotem na domyślne koszty za każdym razem, gdy interfejs zmniejsza / upuszcza.
- Mostkowanie bez przełączania
- Domyślnie most linuksowy działa jak przełącznik. Oznacza to, że zapamiętuje adresy MAC znajdujące się za portem przełącznika, a jeśli docelowy adres MAC jest znany, pakiety danych lub przesyłają tylko do odpowiedniego portu - w przeciwnym razie będą transmitowane pakiety.
- W niektórych konfiguracjach jest to złe. Na przykład, jeśli most łączy 2 interfejsy magistrali i te same adresy MAC mogą być widoczne z obu interfejsów, w zależności od sieci VLAN. Ponieważ most linuxowy nie obsługuje VLAN (dedykowane tabele adresów MAC dla każdej sieci VLAN), w takich konfiguracjach należy wyłączyć uczenie się adresu MAC i przełączyć mostek w prawdziwy tryb "mostkowy" z:
- up / sbin / brctl setageing br0 0
- up / sbin / brctl stp br0 off
- Howto use vlan (dot1q, 802.1q, trunk) (Etch, Lenny)
- Konfiguracja ręczna
- modprobe 8021q
- apt-get install vlan
- vconfig add eth0 222 # 222 jest liczbą vlan
- ifconfig eth0.222 up
- ifconfig eth0.222 mtu 1496 #optional, jeśli twoja karta sieciowa nie obsługuje MTU 1504B
- ifconfig eth0.222 10.10.10.1 maska sieci 255.255.255.0
- Konfiguracja skryptu sieciowego
- Do / etc / modules dodaj linię:
- 8021q
- W / etc / network / interfaces do section iface dodaj parametr:
- v0l-raw-device eth0
- Nazwa interfejsu powinna być nazwą surowego interfejsu (taką samą, jak określona przez urządzenie vlan-raw), a następnie kropką, a następnie identyfikatorem sieci VLAN, na przykład eth0.100. Zamiast tego może to być "vlan", a następnie VLAN ID, na przykład vlan100. W obu przypadkach identyfikator sieci VLAN jest na końcu i jest to jedyne miejsce, w którym jest skonfigurowany.
- Uwaga: Jeśli nazwiesz interfejsy VLAN ethX.YYY, wówczas nie ma potrzeby określania urządzenia vlan-raw, ponieważ urządzenie surowe można pobrać z nazwy interfejsu.
- Na przykład:
- auto eth0.222
- iface eth0.222 inet static
- adres 10.10.10.1
- maska sieci 255.255.255.0
- v0l-raw-device eth0
- Mosty i sieci VLAN
- Jeśli tworzysz interfejsy VLAN tylko w celu umieszczenia ich w moście, nie ma potrzeby ręcznego definiowania interfejsów VLAN. Po prostu skonfiguruj most, a interfejs VLAN zostanie utworzony automatycznie podczas tworzenia mostu, np .:
- auto br1
- Instrukcja iface br1 inet
- bridge_ports eth0.99 eth1.99
- w górę / usr / sbin / brctl stp br0 on
- Zastrzega się przy stosowaniu mostkowania i vlan
- # / etc / network / interfaces
- auto eth0 bri0
- iface eth0 inet static
- adres 192.168.1.1
- maska sieci 255.255.255.0
- iface eth0.110 inet manual
- v0l-raw-device eth0
- iface bri0 inet static
- adres 192.168.110.1
- maska sieci 255.255.255.0
- bridge_ports eth0.110
- bridge_stp on
- bridge_maxwait 10
- Jeśli używasz zaawansowanej konfiguracji sieci VLAN, która jest prawdopodobnie przydatna do pracy w sieci w środowiskach wirtualizacji, zadbaj o podłączenie urządzenia mostkowego lub sieci VLAN do fizycznego urządzenia bazowego - jak pokazano powyżej. Dołączenie interfejsu fizycznego (eth0) do mostka (np. Bri1) przy użyciu tego samego fizycznego interfejsu na pozornie różnych sieciach VLAN spowoduje, że wszystkie pakiety pozostaną oznakowane. (Kernel nowszy niż 2.6.37 i starszy niż 3.2).
- Jak stworzyć odporne na uszkodzenia wiązania z vlan (Etch)
- debian_bonding.png
- debian_bonding.dia
- Jak skonfigurować jedno z powyższych aktywnych połączeń na serwerze 3 vlan {vlan10, vlan20, vlan30} Sieć Debiana bez SPOF bez natywnego vlana.
- aptitude install vlan ifenslave-2.6
- Konfiguracja sieci
- Przykład konfiguracji interfejsu przełącznika Cisco
- interfejs GigabitEthernet1 / 2
- opis eth1
- switchport
- switchport trunk encapsulation dot1q
- switchport trunk dozwolone vlan 10,20,30
- bagażnik trybu switchport
- bez adresu IP
- brak włączania cdp
- spanning-tree portfast trunk
- klejenie z aktywną kopią zapasową
- Utwórz plik /etc/modprobe.d/bonding.conf zawierający:
- alias bond0 bonding
- opcje tryb łączenia = aktywna kopia zapasowa miimon = 100 downdelay = 200 updelay = 200 primary = eth1
- / etc / network / interfaces
- # Interfejs sieciowy pętli zwrotnej
- auto lo
- iface lo inet loopback
- # Główny interfejs sieciowy
- auto bond0
- iface bond0 inet manual
- up ifconfig bond0 0.0.0.0 up
- niewolnicy eth1 eth0
- auto vlan10
- iface vlan10 inet static
- adres 10.10.10.12
- maska sieci 255.255.0.0
- vlan-raw-device bond0
- bramka 10.10.0.1
- dns-search hup.hu
- dns-nameservers 10.10.0.2
- auto vlan20
- iface vlan20 inet static
- adres 10.20.10.12
- maska sieci 255.255.0.0
- vlan-raw-device bond0
- auto vlan30
- iface vlan30 inet static
- adres 10.30.10.12
- maska sieci 255.255.0.0
- vlan-raw-device bond0
- Jak ustawić MTU (Max transfer unit / packet size) za pomocą VLANS nad połączonym interfejsem
- MTU musi być skonfigurowany na interfejsie łączenia i interfejsach slave po zresetowaniu konfiguracji zastosowanej do interfejsów łączących. Odbywa się to za pomocą linii post-up w konfiguracji interfejsu klejenia.
- auto bond0
- iface bond0 inet manual
- up ifconfig lacptrunk0 0.0.0.0 w górę
- niewolnicy eth0 eth1
- # bond-mode 4 = 802.3ad
- tryb bond 4
- bond-miimon 100
- bond-downdelay 200
- bond-updelay 200
- stopa lacp-bond 1
- bond-xmit-hash-policy layer2 + 3
- post-up ifconfig eth0 mtu 9000 && ifconfig eth1 mtu 9000 && ifconfig bond0 mtu 9000
- Urządzenia #vlan będą używać zestawu MTU na urządzeniu bond0
- auto vlan101
- iface vlan101 inet static
- adres 10.101.60.123
- maska sieci 255.255.255.0
- bramka 10.155.60.1
- vlan-raw-device bond0
- auto vlan151
- iface vlan151 inet static
- adres 192.168.1.1
- maska sieci 255.255.255.0
- vlan-raw-device bond0
- Wiele adresów IP w jednym interfejsie
- Aliasowanie interfejsu umożliwia posiadanie wielu interfejsów w jednym interfejsie. Jest to przydatne, gdy więcej niż jeden serwer ma być widoczny przez Internet. Należy zauważyć, że hosty wirtualne mogą obsługiwać wiele serwerów Apache z jednym adresem IP. Apache odpowiada na nazwę domeny dostarczoną przez klienta w nagłówku HTTP. W wielu innych sytuacjach jeden zewnętrzny adres IP jest potrzebny dla każdego serwera korzystającego z portu.
- Stara metoda
- Ten tekst / etc / network / interfaces przypisuje do eth0 trzy adresy IP.
- auto eth0
- allow-hotplug eth0
- iface eth0 inet static
- adres 192.168.1.42
- maska sieci 255.255.255.0
- bramka 192.168.1.1
- auto eth0: 0
- allow-hotplug eth0: 0
- iface eth0: 0 inet static
- adres 192.168.1.43
- maska sieci 255.255.255.0
- auto eth0: 1
- allow-hotplug eth0: 1
- iface eth0: 1 inet static
- adres 192.168.1.44
- maska sieci 255.255.255.0
- Interfejs aliasu nie powinien mieć "gateway" ani "dns-nameservers"; Dynamiczne przydzielanie adresów IP jest dopuszczalne.
- Powyższa konfiguracja jest poprzednią tradycyjną metodą, która odzwierciedla tradycyjne użycie ifconfig do konfigurowania urządzeń sieciowych. ifconfig wprowadził pojęcie interfejsów aliasowych lub wirtualnych . Te typy wirtualnych interfejsów mają nazwy interfejsu formularza : integer i ifconfig traktują je bardzo podobnie do rzeczywistych interfejsów.
- Obecnie ifupdown używa narzędzia ip z pakietu iproute2 zamiast ifconfig . Nowsze narzędzie ip nie używa tej samej koncepcji aliasów ani wirtualnych interfejsów. Wspiera jednak przypisywanie dowolnych nazw interfejsom (nazywa się je etykietami). ifupdown używa tej funkcji do obsługi aliasowanych interfejsów podczas korzystania z ip .
- Metoda iproute2
- Ponadto ifupdown obsługuje określanie wielu interfejsów przez powtarzanie sekcji iface z tą samą nazwą interfejsu. Podstawową różnicą w stosunku do opisanej powyżej metody jest to, że wszystkie takie sekcje są traktowane przez ifupdown jako tylko jeden interfejs, więc użytkownik nie może ich dodawać ani usuwać pojedynczo. Jednak polecenia w górę / w dół , a także skrypty, są wywoływane dla każdej sekcji tak jak poprzednio.
- Pamiętaj jednak, że ta metoda jest niebezpieczna ! Niektóre kombinacje sterowników / sprzętu mogą czasami nie doprowadzić do połączenia, jeśli do interfejsów aliasu nie zostaną przypisane żadne etykiety. (Widać to na Debian Wheezy i Jessie z RTL8111 / 8168/8411 PCI Express Gigabit Ethernet Controller (rev 01) auto-negocjowanie do 10 / full. Podobne ostrzeżenie od innej osoby istnieje w historii tej strony.)
- Ten tekst / etc / network / interfaces przypisuje do eth0 trzy adresy IP.
- auto eth0
- allow-hotplug eth0
- iface eth0 inet static
- adres 192.168.1.42
- maska sieci 255.255.255.0
- bramka 192.168.1.1
- iface eth0 inet static
- adres 192.168.1.43
- maska sieci 255.255.255.0
- iface eth0 inet static
- adres 192.168.1.44
- maska sieci 255.255.255.0
- # możliwe jest również dodawanie adresów IP z różnych podsieci
- iface eth0 inet static
- adres 10.10.10.14
- maska sieci 255.255.255.0
- Podejście ręczne:
- auto eth0
- allow-hotplug eth0
- iface eth0 inet static
- adres 192.168.1.42
- maska sieci 255.255.255.0
- bramka 192.168.1.1
- do ip addr dodaj 192.168.1.43/24 dev $ etykieta IFACE $ IFACE: 0
- down ip addr del 192.168.1.43/24 dev $ IFACE label $ IFACE: 0
- up ip addr add 192.168.1.44/24 dev $ etykieta IFACE $ IFACE: 1
- down ip addr del 192.168.1.44/24 dev $ IFACE label $ IFACE: 1
- up ip addr dodaj 10.10.10.14/24 dev $ IFACE label $ IFACE: 2
- down ip addr del 10.10.10.14/24 dev $ IFACE label $ IFACE: 2
- ####################################################################################################
- ####################################################################################################
- ####################################################################################################
- Setting up an Ethernet Interface
- Predictable Network Interface Names
- Using DHCP to automatically configure the interface
- Configuring the interface manually
- Setting the speed and duplex
- Bringing up an interface without an IP address
- Defining the (DNS) Nameservers
- The resolv.conf configuration file
- The resolvconf program
- DNS configuration for NetworkManager
- DHCP Client Configuration
- Bridging
- Bridging without Switching
- Howto use vlan (dot1q, 802.1q, trunk) (Etch, Lenny)
- Manual config
- Network init script config
- Bridges and VLANs
- Caveats when using bridging and vlan
- Howto create fault tolerant bonding with vlan (Etch)
- Network config
- bonding with active backup
- /etc/network/interfaces
- How to set the MTU (Max transfer unit / packet size) with VLANS over a bonded interface
- Multiple IP addresses on one Interface
- Legacy method
- iproute2 method
- Setting up an Ethernet Interface
- The majority of network setup can be done via the interfaces configuration file at /etc/network/interfaces. Here, you can give your network card an IP address (or use dhcp), set up routing information, configure IP masquerading, set default routes and much more.
- Remember to add interfaces that you want brought up at boot time to the 'auto' line.
- See man interfaces for more options.
- Predictable Network Interface Names
- As of Stretch, the old network names like eth0, eth1 have gone away as the device name can change. The new names are similar to these: enp6s0, enp8s0, enp0s31f6, enp5s0. Sadly, the system used is still somewhat arbitrary in that it relies on the BIOS enumeration which changes in with buggy BIOSs and under some situations. (That it wasn't based on a reduced sumcheck of the MAC address (2c:56:ac:39:ec:0d becomes 98) or some similar method is puzzling (udev can do such things) and the names we are left with are rather user unfriendly).
- For people using more than one Network Interface - we will just have to deal with the new system.
- To find the names of your interfaces you will want to look here: $ ls /sys/class/net/
- Upgrading and Predictable Network Interface Names
- Upgrades to Stretch will retain the old device names - despite what you will read on the web - removing /etc/udev/rules.d/70-local-persistent-net.rules will not give you the new names even if followed with a update-initramfs -u and update-grub. ( have not yet found the correct Debian incantations for this yet?? )
- Using DHCP to automatically configure the interface
- If you're just using DHCP then all you need is something like:
- auto eth0
- allow-hotplug eth0
- iface eth0 inet dhcp
- For DHCPv6 (used for IPv6), append also the following iface stanza
- iface eth0 inet6 dhcp
- Alternatively, IPv6 can be autoconfigured using stateless address autoconfiguration, or SLAAC, which is specified using auto instead of dhcp in the inet6 stanza:
- iface eth0 inet6 auto
- Configuring the interface manually
- If you're configuring it manually then something like this will set the default gateway (network, broadcast and gateway are optional):
- auto eth0
- iface eth0 inet static
- address 192.0.2.7
- netmask 255.255.255.0
- gateway 192.0.2.254
- If you want to add an IPv6 address, too, append something like:
- iface eth0 inet6 static
- address 2001:db8::c0ca:1eaf
- netmask 64
- gateway 2001:db8::1ead:ed:beef
- See man interfaces for more options.
- Make sure to disable all DHCP services, e.g. dhcpcd.
- Setting the speed and duplex
- Autonegotiation repeatedly failing is often a symptom of faulty cabling, so investigate physical matters before assuming that the interfaces' autonegotiation algorithms are incompatible. If you turn off autonegotiation and set speed and duplex manually then the partner interface at the other end of the cable will assume that the absence of autonegotiation indicates a speed of 10Mbps and a duplex of half. For error-free operation if you set speed and duplex manually you must ensure that exactly the same speed and duplex are configured on the partner interface.
- If you set your interface's speed and duplex by hand, then some trial and error may be required. Here are the basic steps:
- Install the ethtool and net-tools packages, so that you have the ethtool and mii-tool programs. One or both of these might work for your interface.
- Make sure you have a way to login to the system in case the network interface becomes nonfunctional. An SSH connection could be disrupted, so you should have a fallback strategy.
- Identify the interface in question (it will often be eth0). Adjust the remainder of these instructions accordingly.
- Try to determine what its current speed and duplex settings are. This is where it gets fun:
- As root, try ethtool eth0 first, and see whether the "Speed:" and "Duplex:" lines look valid. If not, the ethtool may not be supported by your device.
- As root, try mii-tool -v eth0 and see whether its output looks correct. If not, them mii-tool may not be supported by your device.
- If neither one is supported, you may have to set parameters directly on the kernel driver module. Identify which driver module you're using by reading the output of dmesg and lsmod. You can then try modinfo MODULENAME to see what parameters it accepts, if any. (You can use modinfo even on modules that are not loaded, for comparison.) ToDo: where does one set kernel module parameters?
- Next, try to change the settings of the interface while it's operating. You'll need to be root, of course. Either:
- ethtool -s eth0 speed 100 duplex full autoneg off (assuming 100 Mbps and full duplex)
- mii-tool -F 100baseTx-FD eth0 (same assumption)
- In each case, re-check to see whether the interface settings actually changed, and then try sending some data in and out of the system to see whether the NIC is operating correctly.
- If one of these commands successfully set your NIC, then you can put it into /etc/network/interfaces so it runs when you bring the interface up (e.g. at boot time). However, before you do that, you should understand that some drivers and devices behave differently than others. When the driver module is loaded, the NIC may begin autonegotiation without any way to stop it (particularly with drivers that do not accept parameters). The settings from interfaces are applied at some point after that, which may be right in the middle of the negotiation. So, some people find it necessary to delay the ethtool or mii-tool command by a few seconds. Thus:
- iface eth0 inet static
- address ...
- netmask ...
- gateway ...
- up sleep 5; ethtool -s eth0 ...
- Or the analogous mii-tool command.
- Reboot the machine to make sure it comes up correctly, and be prepared to intervene manually (e.g. Ctrl-Alt-Del and then boot into single-user mode from GRUB or LILO) if things don't work.
- Bringing up an interface without an IP address
- To create a network interface without an IP address at all use the manual method and use pre-up and post-down commands to bring the interface up and down.
- iface eth0 inet manual
- pre-up ifconfig $IFACE up
- post-down ifconfig $IFACE down
- If the interface is a VLAN interface, the up/down commands must be executed after/before the vlan hooks. (You also have to install the vlan package.)
- iface eth0.99 inet manual
- post-up ifconfig $IFACE up
- pre-down ifconfig $IFACE down
- Note: If you create the VLAN interface only to put it into a bridge, there is no need to define the VLAN interface manually. Just configure the bridge, and the VLAN interface will be created automatically when creating the bridge (see below).
- Defining the (DNS) Nameservers
- Before a computer can connect to an external network resource (say, for example, a web server), it must have a means of converting any alpha-numeric names (e.g. wiki.debian.org) into numeric network addresses (e.g. 140.211.166.4). (The Internet uses these structured numeric IP addresses as network addresses.)
- The C library and other resolver libraries look to /etc/resolv.conf for a list of nameservers. In the simplest case, that is the file to edit to set the list of name servers. But note that various other programs for dynamic configuration will be happy to overwrite your settings:
- The resolvconf program
- The network-manager daemon
- DHCP clients
- In most situations, the file to edit is the configuration file for such a program.
- In the most complex situations, using resolvconf really is the way to go, though in more simple configurations it is probably overkill.
- The resolv.conf configuration file
- The configuration file resolv.conf at /etc/resolv.conf contains information that allows a computer connected to a network to resolve names into addresses. (Note: Do not confuse this configuration file with the program resolvconf, which unfortunately has a nearly identical name.)
- The resolv.conf file typically contains the IP addresses of nameservers (DNS name resolvers) that will attempt to translate names into addresses for any node available on the network. There will be a line or lines that look like this:
- nameserver 12.34.56.78
- nameserver 12.34.56.79
- In this example, the system is using nameservers at the IP addresses 12.34.56.78 and 12.34.56.79. Simply edit the file and enter the IP addresses of the nameservers you need to use after each nameserver. Add more nameserver lines if you have more nameservers. Don't use this method if you have the resolvconf program installed.
- The resolv.conf configuration file has many other options for defining how resolver looks up names. See man resolv.conf for details.
- The resolvconf program
- The resolvconf program keeps track of system information about the currently available nameservers. It should not be confused with the configuration file resolv.conf, which unfortunately has a nearly identical name. The resolvconf program is optional on a Debian system.
- The configuration file resolv.conf contains information about the nameservers to be used by the system. However, when multiple programs need to dynamically modify the resolv.conf configuration file they can step on each other and the file can become out-of-sync. The resolvconf program addresses this problem. It acts as an intermediary between programs that supply nameserver information (e.g. dhcp clients) and programs that use nameserver information (e.g. resolver).
- When resolvconf is properly installed, the resolv.conf configuration file at /etc/resolv.conf is replaced by a symbolic link to /etc/resolvconf/run/resolv.conf and the resolver instead uses the configuration file that is dynamically generated by resolvconf at /etc/resolvconf/run/resolv.conf.
- The resolvconf program is generally only necessary when a system has multiple programs that need to dynamically modify the nameserver information. In a simple system where the nameservers do not change often or are only changed by one program, the resolv.conf configuration file is adequate.
- If the resolvconf program is installed, you should not edit the resolv.conf configuration file manually as it will be dynamically changed by programs in the system. If you need to manually define the nameservers (as with a static interface), add a line something like the following to the interfaces configuration file at /etc/network/interfaces:
- dns-nameservers 12.34.56.78 12.34.56.79
- Place the line indented within an iface stanza, e.g., right after the gateway line. Enter the IP addresses of the nameservers you need to use after dns-nameservers. Put all of them on one line separated by spaces. Don't forget the "s" on the end of dns-nameservers.
- The resolvconf program is a fairly new addition to Debian and many older programs need to be updated or reconfigured to work properly with it. If you have problems, see /usr/share/doc/resolvconf/README. It has lots of information on making other programs get along with resolvconf.
- DNS configuration for NetworkManager
- NetworkManager will override dhcp settings, overwriting resolv.conf even if you've configured DNS in /etc/dhcp/dhclient.conf, e.g. causing DNS to first search the local domain, which may have to time out before DNS resolution continues causing lengthy DNS resolution times. You can get an idea of what NetworkManager thinks the settings should be by executing nm-tool at the command line.
- You may configure these settings using a GUI by launching nm-connection-editor which currently (13.11.23) isn't to be found in System Tools → Administration menu, rather it must be launched by hand from the command line. After launching:
- Choose a connection (from the Wired or Wireless tab) and click Edit.
- Click on the IPv4 Settings tab
- Choose 'Automatic (DHCP) addresses only' instead of just 'Automatic (DHCP)'.
- Enter the DNS servers in the “DNS servers” field, separated by spaces (e.g. 208.67.222.222 for OpenDNS).
- Click “Apply.”
- NetworkManager saves these settings in /etc/NetworkManager/system-connections/name-of-connection. Example /etc/NetworkManager/system-connections/Wired connection 1 :
- [802-3-ethernet]
- duplex=full
- mac-address=XX:XX:XX:XX:XX:XX
- [connection]
- id=Wired connection 1
- uuid=xxx-xxxxxx-xxxxxx-xxxxxx-xxx
- type=802-3-ethernet
- timestamp=1385213042
- [ipv6]
- method=auto
- [ipv4]
- method=auto
- dns=208.67.222.222;
- ignore-auto-dns=true
- Running nm-tool again should show that NetworkManager now has the right idea of how your DNS should be resolved.
- DHCP Client Configuration
- Example: dhclient3 uses /etc/dhcp/dhclient.conf. The setting you want is
- supersede domain-name-servers 12.34.56.78, 12.34.56.79;
- or perhaps
- prepend domain-name-servers 12.34.56.78, 12.34.56.79;
- See the dhclient.conf(5) manual page for details.
- Bridging
- Bridging puts multiple interfaces into the same network segment. This is very popular when connecting a server to multiple switches for high availability or with virtualization. In the latter case it is usually used to create a bridge in the host (eg. dom0) and put the virtual interfaces of the guests (domU) into the bridge.
- Example: Connect a server to 2 switches (via eth0 and eth1) by defining bridge 0 and give the server an IP address in this subnet:
- auto br0
- iface br0 inet static
- address 10.10.0.15
- netmask 255.255.255.0
- gateway 10.10.0.1
- bridge_ports eth0 eth1
- up /usr/sbin/brctl stp br0 on
- If a server is connected to multiple switches then you usually need to run the spanning tree protocol to avoid loops. Therefore STP must be turned on via an "up" command as shown above.
- Example: Bridge setup without IP address configuration (use "manual" instead of "static") to "forward" an interface to a guest VM. (The static bridge config contains only 1 physical interface. The virtual interface will be added to the bridge when the VM is started.)
- auto br1
- iface br1 inet manual
- bridge_ports eth4
- up /usr/sbin/brctl setageing br1 0
- up /usr/sbin/brctl stp br0 off
- Note: The Linux bridge supports only STP, no RSTP (Rapid Spanning Tree). Therefore it supports only the old STP Costs, not the new RSTP Costs (see Spanning_Tree_Protocol). This is usually fine with Cisco Switches, but eg. Juniper switches use the RSTP costs and therefore this may lead to different spanning tree calculations and loop problems. This can be fixed by settings the costs manually, either on the switch or on the server. Setting the cost on the switch is preferred as Linux switches back to the default costs whenever an interface does down/up.
- Bridging without Switching
- By default the Linux bridge acts like a switch. This means, it remembers the MAC addresses behind a switch port and if the destination MAC address is known, data packets or only forward to the respective port - otherwise packets will be broadcasted.
- In some setups this is bad. For example if the bridge connects 2 trunk interfaces and the same MAC addresses may be seen from both interfaces, depending on the VLAN. As the Linux bridge does not support VLANs (dedicated MAC address tables per each VLAN), in such setups you have to disable the MAC address learning and put the bridge into a real "bridge" mode with:
- up /sbin/brctl setageing br0 0
- up /sbin/brctl stp br0 off
- Howto use vlan (dot1q, 802.1q, trunk) (Etch, Lenny)
- Manual config
- modprobe 8021q
- apt-get install vlan
- vconfig add eth0 222 # 222 is vlan number
- ifconfig eth0.222 up
- ifconfig eth0.222 mtu 1496 #optional if your network card doesn't support MTU 1504B
- ifconfig eth0.222 10.10.10.1 netmask 255.255.255.0
- Network init script config
- Into /etc/modules add line:
- 8021q
- In /etc/network/interfaces to section iface add parameter:
- vlan-raw-device eth0
- The interface name should be the raw interface name (the same as specified by vlan-raw-device), then a dot, then the VLAN ID, for example eth0.100. It can instead be "vlan" then the VLAN ID, for example vlan100. In either case, the VLAN ID is on the end, and this is the only place that it is configured.
- Note: If you name your VLAN interfaces ethX.YYY, then there is no need to specify the vlan-raw-device, as the raw device can be retrieved from the interface name.
- Eg:
- auto eth0.222
- iface eth0.222 inet static
- address 10.10.10.1
- netmask 255.255.255.0
- vlan-raw-device eth0
- Bridges and VLANs
- If you create VLAN interfaces only to put them into a bridge, there is no need to define the VLAN interfaces manually. Just config the bridge, and the VLAN interface will be created automatically when creating the bridge, e.g:
- auto br1
- iface br1 inet manual
- bridge_ports eth0.99 eth1.99
- up /usr/sbin/brctl stp br0 on
- Caveats when using bridging and vlan
- #/etc/network/interfaces
- auto eth0 bri0
- iface eth0 inet static
- address 192.168.1.1
- netmask 255.255.255.0
- iface eth0.110 inet manual
- vlan-raw-device eth0
- iface bri0 inet static
- address 192.168.110.1
- netmask 255.255.255.0
- bridge_ports eth0.110
- bridge_stp on
- bridge_maxwait 10
- If you are using a brigded VLAN setup, which is probably useful for networking in virtualization environments, take care to only attach either a bridge device or VLAN devices to an underlying physical device - like shown above. Attaching the physical interface (eth0) to a bridge (eg. bri1) while using the same physical interface on apparently different VLANs will result in all packets to remain tagged. (Kernel newer than 2.6.37 and older than 3.2).
- Howto create fault tolerant bonding with vlan (Etch)
- debian_bonding.png
- debian_bonding.dia
- How to configure one of the above server active backup bonding 3 vlan {vlan10,vlan20,vlan30} Debian networking without SPOF without native vlan.
- aptitude install vlan ifenslave-2.6
- Network config
- Cisco switch interface example config
- interface GigabitEthernet1/2
- description eth1
- switchport
- switchport trunk encapsulation dot1q
- switchport trunk allowed vlan 10,20,30
- switchport mode trunk
- no ip address
- no cdp enable
- spanning-tree portfast trunk
- bonding with active backup
- Create a file /etc/modprobe.d/bonding.conf containing:
- alias bond0 bonding
- options bonding mode=active-backup miimon=100 downdelay=200 updelay=200 primary=eth1
- /etc/network/interfaces
- # The loopback network interface
- auto lo
- iface lo inet loopback
- # The primary network interface
- auto bond0
- iface bond0 inet manual
- up ifconfig bond0 0.0.0.0 up
- slaves eth1 eth0
- auto vlan10
- iface vlan10 inet static
- address 10.10.10.12
- netmask 255.255.0.0
- vlan-raw-device bond0
- gateway 10.10.0.1
- dns-search hup.hu
- dns-nameservers 10.10.0.2
- auto vlan20
- iface vlan20 inet static
- address 10.20.10.12
- netmask 255.255.0.0
- vlan-raw-device bond0
- auto vlan30
- iface vlan30 inet static
- address 10.30.10.12
- netmask 255.255.0.0
- vlan-raw-device bond0
- How to set the MTU (Max transfer unit / packet size) with VLANS over a bonded interface
- MTU needs to be configured on the bonding interface and slave interfaces after the reset of the configuration has been applied to the bonding interfaces. This is done using a post-up line in the bonding interface configuration.
- auto bond0
- iface bond0 inet manual
- up ifconfig lacptrunk0 0.0.0.0 up
- slaves eth0 eth1
- # bond-mode 4 = 802.3ad
- bond-mode 4
- bond-miimon 100
- bond-downdelay 200
- bond-updelay 200
- bond-lacp-rate 1
- bond-xmit-hash-policy layer2+3
- post-up ifconfig eth0 mtu 9000 && ifconfig eth1 mtu 9000 && ifconfig bond0 mtu 9000
- #vlan devices will use the MTU set on bond0 device
- auto vlan101
- iface vlan101 inet static
- address 10.101.60.123
- netmask 255.255.255.0
- gateway 10.155.60.1
- vlan-raw-device bond0
- auto vlan151
- iface vlan151 inet static
- address 192.168.1.1
- netmask 255.255.255.0
- vlan-raw-device bond0
- Multiple IP addresses on one Interface
- Interface aliasing allows one interface to have multiple IP addresses. This is useful when more than one server is to be visible via the Internet. Note that virtual hosts can support multiple Apache servers with a single IP address. Apache responds to the domain name supplied by the client in the HTTP header. In many other situations, one external IP is needed for each server using a port.
- Legacy method
- This /etc/network/interfaces text assigns three IP addresses to eth0.
- auto eth0
- allow-hotplug eth0
- iface eth0 inet static
- address 192.168.1.42
- netmask 255.255.255.0
- gateway 192.168.1.1
- auto eth0:0
- allow-hotplug eth0:0
- iface eth0:0 inet static
- address 192.168.1.43
- netmask 255.255.255.0
- auto eth0:1
- allow-hotplug eth0:1
- iface eth0:1 inet static
- address 192.168.1.44
- netmask 255.255.255.0
- An alias interface should not have "gateway" or "dns-nameservers"; dynamic IP assignment is permissible.
- The above configuration is the previous traditional method that reflects the traditional use of ifconfig to configure network devices. ifconfig has introduced the concept of aliased or virtual interfaces. Those types of virtual interfaces have names of the form interface:integer and ifconfig treats them very similarly to real interfaces.
- Nowadays ifupdown uses the ip utility from the iproute2 package instead of ifconfig. The newer ip utility does not use the same concept of aliases or virtual interfaces. However, it supports assigning arbitrary names to the interfaces (they're called labels). ifupdown uses this feature to support aliased interfaces while using ip.
- iproute2 method
- Also, ifupdown supports specifying multiple interfaces by repeating iface sections with the same interface name. The key difference from the method described above is that all such sections are treated by ifupdown as just one interface, so user can't add or remove them individually. However, up/down commands, as well as scripts, are called for every section as it used to be.
- Note however that this method is dangerous! Certain driver/hardware combinations may sometimes fail to bring the link up if no labels are assigned to the alias interfaces. (Seen this on Debian Wheezy and Jessie with RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 01) auto-negotiating to 10/full. A similar warning from another person exists in the history of this page.)
- This /etc/network/interfaces text assigns three IP addresses to eth0.
- auto eth0
- allow-hotplug eth0
- iface eth0 inet static
- address 192.168.1.42
- netmask 255.255.255.0
- gateway 192.168.1.1
- iface eth0 inet static
- address 192.168.1.43
- netmask 255.255.255.0
- iface eth0 inet static
- address 192.168.1.44
- netmask 255.255.255.0
- # adding IP addresses from different subnets is also possible
- iface eth0 inet static
- address 10.10.10.14
- netmask 255.255.255.0
- Manual approach:
- auto eth0
- allow-hotplug eth0
- iface eth0 inet static
- address 192.168.1.42
- netmask 255.255.255.0
- gateway 192.168.1.1
- up ip addr add 192.168.1.43/24 dev $IFACE label $IFACE:0
- down ip addr del 192.168.1.43/24 dev $IFACE label $IFACE:0
- up ip addr add 192.168.1.44/24 dev $IFACE label $IFACE:1
- down ip addr del 192.168.1.44/24 dev $IFACE label $IFACE:1
- up ip addr add 10.10.10.14/24 dev $IFACE label $IFACE:2
- down ip addr del 10.10.10.14/24 dev $IFACE label $IFACE:2
- ##########################################################
- ##### NETWORK 3G ####
- ##########################################################
- Jak podłączyć laptopa do Internetu za pomocą telefonu komórkowego przez USB lub Bluetooth
- W tym artykule opiszę, jak łatwo podłączyć laptopa do Internetu za pomocą telefonu komórkowego jako modemu 3G / GPRS przez Bluetooth lub USB.
- Procedura została przetestowana na laptopie Toshiba Satellite z pakietem Debian SID (2.6.26-1-686) i telefonem Nokia N80 podłączonym do hiszpańskiej sieci mobilnej Movistar. Z pewnością należy nieznacznie zmienić parametry podane w tym dokumencie, aby inne połączenie działało ...
- Bardzo ważne jest ścisłe przestrzeganie wszystkich kroków związanych z tym artykułem.
- Uwaga: Aby uzyskać ogólne informacje na temat konfigurowania Bluetooth, zobacz także stronę BluetoothUser .
- Parowanie laptopa z telefonem komórkowym
- Przede wszystkim musisz sparować laptopa z telefonem komórkowym. Do pobrania niektórych pakietów potrzebne jest aktywne połączenie internetowe z laptopem. Będziemy używać pakietu kdebluetooth . Chociaż sam jestem użytkownikiem Gnome, znalazłem ten pakiet bardzo przydatny. Tak więc otwórzmy konsolę i wpiszmy jako root:
- # apt-get install kdebluetooth
- Spowoduje to zainstalowanie pakietu. Następnie wpiszmy jako zwykły użytkownik:
- $ kbluetooth
- Wtedy na pasku zadań pojawi się mała niebieska ikona ...
- Jeśli klikniemy na niego prawym przyciskiem myszy i wybierz opcję KONFIGURACJA ... ADAPTERY ... wtedy będziemy mogli skonfigurować laptopa, aby ustawić go w trybie ODKRYWANIA ...
- Po tym aktywujemy Bluetooth w telefonie komórkowym i próbujemy wykryć laptopa ... Po odkryciu laptopa przez telefon, poprosimy nas o wprowadzenie hasła numerycznego: po prostu wpisz coś łatwego jak "123", jeśli myślisz nie ma zagrożenia bezpieczeństwa ... (To tylko jednorazowe hasło). Zostaniesz poproszony o powtórzenie tego samego hasła na swoim laptopie . Aby uniknąć powtarzania tego procesu za każdym razem, gdy parujesz laptopa z telefonem komórkowym, zdecydowanie zalecamy dodanie laptopa jako zaufanego urządzenia (jest to opcja łatwo dostępna w menu bluetooth na telefonie komórkowym ) ... Et voi-là ... nasze urządzenia są po prostu sparowane!
- Konfigurowanie parametrów MODEM
- Teraz musimy skonfigurować parametry modemu twojego telefonu komórkowego.
- Najpierw podłącz telefon komórkowy do laptopa za pomocą kabla USB ... Ważne jest, aby telefon komórkowy nie utracił łączności w tym momencie, tak aby był bezużyteczny, gdyby podłączyłeś telefon komórkowy przez USB w "Transfer plików "Tryb ... Musisz podłączyć go w taki sposób, aby telefon nadal działał. W przypadku Nokia N80 wybierz opcję "PC-Suite" ...
- A następnie wpisz jako root:
- # apt-get install wvdial
- # wvdialconf
- Po wykonaniu tej czynności wvdialconf sprawdził twój telefon komórkowy i po udanym połączeniu z nim ustalił poprawne parametry modemu i zapisał go do pliku. Ale teraz musimy ulepszyć ten plik konfiguracyjny, abyśmy mogli wpisać jako root:
- # apt-get install gedit
- # gedit /etc/wvdial.conf
- Musisz usunąć następujące wiersze kodu:
- Modem Type = USB Modem
- Modem = / dev / ttyACM0
- Musisz dodać następujące wiersze na końcu edytowanego pliku w tej samej kolejności, w jakiej występuje tutaj:
- Nowe PPPD = tak
- Telefon = * 99 *** 1 #
- Nazwa użytkownika = MOVISTAR
- Hasło = MOVISTAR
- Init6 = AT + CGDCONT = 1, "IP", "movistar.es"
- [Dialer usb-scb]
- Modem Type = USB Modem
- Modem = / dev / ttyACM0
- [Dialer blz-scb]
- Modem = / dev / rfcomm0
- Teraz zapisujemy plik bez zmiany nazwy ani lokalizacji i jesteśmy gotowi. Modem telefonu komórkowego jest w pełni skonfigurowany i możemy go używać niewyraźnie przez USB lub Bluetooth (jak wolisz) bez zmiany jakiegokolwiek parametru ...
- Przywracanie sieci
- Przed podłączeniem laptopa do telefonu komórkowego musimy najpierw usunąć istniejące połączenie sieciowe. Aby to zrobić, wpisujemy jako root:
- # ifconfig eth0 down
- # mv /etc/resolv.conf /etc/resolv.conf.eth0
- A eth0 to nazwa aktywnego interfejsu sieciowego. Jeśli nie masz pewności co do nazwy interfejsu, po prostu wpisz jako root:
- # ifconfig
- Aby pojawiły się wszystkie aktywne interfejsy ...
- Ustawienia DNS
- Aby korzystać z Internetu, będziesz potrzebować poprawnych ustawień DNS. Zwykle po podłączeniu będziesz automatycznie otrzymywać ustawienia DNS, więc nie musisz nic robić.
- Jeśli jednak sieć komórkowa tego wymaga, konieczne może być ręczne ustawienie serwerów DNS. Aby to zrobić:
- # echo "nameserver 194.179.1.100"> /etc/resolv.conf
- # echo "nameserver 194.179.1.101" >> /etc/resolv.conf
- Przykładowe serwery nazw są ważne tylko wtedy, gdy łączysz się z hiszpańską siecią mobilną Movistar ... sprawdź odpowiednie ustawienia swojej sieci komórkowej.
- Łączenie przez USB
- Jeśli chcesz podłączyć laptopa do Internetu przez USB do telefonu komórkowego. Wystarczy podłączyć kable i wpisać jako root:
- # wvdial usb-scb &
- Jesteś skończony. Możesz surfować po Internecie lub sprawdzać pocztę e-mail ... ;-)
- Łączenie przez Bluetooth
- Jeśli chcesz połączyć swój laptop z Internetem przez Bluetooth z telefonem komórkowym. Wystarczy włączyć Bluetooth w laptopie i telefonie komórkowym, a następnie wpisać jako root:
- # Skanowanie hcitool
- Pojawią się następujące informacje:
- Łów...
- 00: 11: 22: 33: 44: 55 NameDevice
- Jest to adres MAC i nazwa przypisana urządzeniu Bluetooth telefonu komórkowego. Teraz wpisujesz jako root (używając tego samego adresu MAC co powyżej):
- # rfcomm connect 0 00: 11: 22: 33: 44: 55 2 i
- Po nawiązaniu połączenia wpisujesz jako root:
- # wvdial blz-scb &
- Jesteś skończony. Możesz surfować po Internecie lub sprawdzać pocztę e-mail ... ;-)
- -------------------------------------------------------------------------------------------------------------------------
- Wsparcie sprzętowe
- Instalacja z PPP i / etc / network / interfaces
- Zaawansowana instalacja z WVDial
- Dla Novatel
- Dla opcji
- Dodatkowe kroki dla karty HSDPA
- Dodatkowe kroki dla karty Novatel U740
- Dodatkowe kroki dla kart Huawei
- Huawei E169
- Huawei E220
- Uwagi
- Jak połączyć za pomocą modemu bezprzewodowego Wi-Fi / WAN / mobilnego modemu Franklin U210
- FAQ
- DO ZROBIENIA
- Zasoby
- Linki zewnętrzne
- Wsparcie sprzętowe
- Następujące karty / telefony działają w 100% z następnymi skryptami / konfiguracjami:
- BandLuxe C100
- Huawei / E176 (działa po wyjęciu z pudełka)
- Huawei / E169 działa bez żadnych problemów
- Huawei / E220
- Huawei / E620
- Huawei / K3565-Z
- Motorola E1000
- Nokia 6680 (po prostu nie ustawiaj prędkości / usługi - bez konfiguracji 3gonly i 384k)
- Nokia N80 (z ładnym How-To UseYourCellPhoneAsModem )
- Karta Novatel HSDPA
- Novatel Merlin U630
- Opcja Fusion
- Opcja Karta HSDPA
- Opcja Quad
- Instalacja z PPP i / etc / network / interfaces
- Działa to z Debian Wheezy 7.
- Zainstaluj pakiety netbase , ifupdown i ppp, jeśli jeszcze ich nie masz:
- apt-get install netbase ifupdown ppp
- Utwórz plik / etc / ppp / peers / gprs z tą zawartością:
- użytkownik "YOUR_USERNAME"
- połącz "/ usr / sbin / chat -v -f / etc / chatscripts / gprs -T YOUR_APN"
- / dev / ttyUSB0
- noipdefault
- Trasa domyślna
- replaceefaultroute
- Ukryj hasło
- # lcp-echo-interval 30
- # lcp-echo-failure 4
- noauth
- trwać
- #mtu 1492
- #maxfail 0
- #holdoff 20
- usepeerdns
- #Opcjonalnie, spraw, aby zawsze wyglądało jak ppp2:
- #rozdział 2
- Następnie edytuj / etc / ppp / chap-secrets i dodaj na końcu:
- "YOUR_USERNAME" * "YOUR_PASSWORD"
- Podobnie, edytuj / etc / ppp / pap-secrets i dodaj na końcu:
- "YOUR_USERNAME" * "YOUR_PASSWORD"
- Następnie edytuj plik / etc / network / interfaces i dodaj:
- auto GPRS
- iface gprs inet ppp
- dostawca gprs
- To wszystko, czego potrzebujesz przez większość czasu. Połączenie zostanie uruchomione podczas startu, możesz uruchomić go z pomocą gprs ifup lub zatrzymać go za pomocą ifdown gprs .
- Zaawansowana instalacja z WVDial
- Musisz pobrać nowy plik wvdial.conf dla rzeczy HSDPA do pracy !!!
- Pierwotnie został napisany dla Gentoo Linux, który kompiluje wszystko od źródła. W rezultacie rzeczy mogą być nieco inne, ale możemy obejść to. Po pierwsze, musimy zmusić Linuksa do wykrycia karty, uruchomienia usług PCMCIA - zwykle można to zrobić za pomocą (większość dystrybucji robi to za Ciebie):
- Zanim włożysz kartę, otwórz konsolę / przełącz się do otwartej konsoli i jako root uruchom następujące:
- Rozpocznij invoke-rc.d pcmciautils
- To pozwoli ci "zobaczyć", co robi Linux:
- tail -f / var / log / messages
- Właśnie teraz włóż kartę i powinieneś zobaczyć, co się dzieje. Dołączyłem ślady dzienników tego, co dwie karty "wyglądają" jak w / var / log / messages w sekcji załączników.
- Jeśli widzisz tylko wiadomości option_insert_nousb.txt za pomocą karty opcji, uruchom następujące polecenie:
- modprobe usbserial vendor = 0x0af0 product = 0x5000
- Jeśli musisz uruchomić powyższe polecenie, musisz zapisać plik vmc_g dołączony do /etc/modules.d .
- Teraz musimy dowiedzieć się, gdzie znajduje się twoja karta - zobaczysz w wiadomościach, gdzie znajduje się karta - / dev / ttyS * dla Novatel lub / dev / ttyUSB * dla opcji:
- znajdź / dev / | grep ttyS
- Powinien pokazać / dev / ttyS0 lub / dev / ttyS1 dla karty Novatel.
- znajdź / dev / | grep ttyUSB
- Powinien pokazać / dev / ttyUSB0 i USB1 i USB2 dla karty opcji. (lub / dev / tts / ttyUSB0-2 dla udev)
- Kiedy to stwierdziliśmy, musimy zmienić plik /etc/wvdial.conf, aby pasował do twoich ustawień, załączony jest mój działający plik wvdial.conf (ten jest testowany w sieci GSM Play w Polsce, z modemem e169, ale nie używa żadnych konkretnych opcji, więc powinien być bardzo przenośnym). Plik to:
- [Domyślne ustawienia dialera]
- Modem = / dev / ttyUSB0
- Baud = 3600000
- Init1 = ATZ
- Init2 = ATQ0 V1 E1 S0 = 0 i C1 & D2 + FCLASS = 0
- Telefon = * 99 #
- Nazwa użytkownika = ppp
- Hasło = ppp
- Zapytaj hasło = 0
- Wybierz polecenie = ATDT
- Tryb głupi = 1
- Compuserve = 0
- Idle Seconds = 0
- ISDN = 0
- Auto DNS = 1
- Możliwe jest ustawienie kodu PIN wysyłanego do modemu w celu odblokowania karty SIM, jakkolwiek ten przykład nie korzysta z tej opcji (należy ją wyszukać). Niektóre karty SIM nie potrzebują kodu PIN do pracy jako modemy.
- Teraz możemy zacząć dzwonić.
- Dla Novatel
- wvdial novatel internet 3gonly 384k
- Dla opcji
- opcja wvdial internet 3gonly 384k
- Jeśli chcesz wysłać swój PIN, dodaj "pin" przed wszystkimi poleceniami, np
- wvdial pin novatel internet 3gonly 384k
- Po nawiązaniu połączenia - odpocznij Teraz możesz skonfigurować takie ustawienia, jak KPPP i Modem Lights Gnome, aby wykonać wybieranie.
- Dodatkowe kroki dla karty HSDPA
- Pobierz moduł jądra z linku poniżej. Wyodrębnij go do katalogu gdzieś bezpieczny.
- Skompiluj sterownik za pomocą następujących poleceń:
- czyść i czyń
- Gdy to zrobisz, uruchom następujące polecenie, aby wstawić moduł do jądra
- insmod nozomi.ko
- Gdy to zrobisz, użyj następującego polecenia, aby skonfigurować połączenie:
- wvdial hsdpa
- Dodatkowe kroki dla karty Novatel U740
- Dopóki nie dostanę czasu na aktualizację plików itp. Nasi użytkownicy Linuksa Novatel mogą po prostu wpisać to polecenie przed użyciem zwykłego polecenia wybierania:
- modprobe usbserial vendor = 0x1410 product = 0x1400
- LUB
- modprobe usbserial vendor = 0x1410 product = 0x1410
- Używanie lsusb pokazuje, że sprzedawca i identyfikator produktu lub cat / proc / bus / usb / devices zrobią to samo.I nadal będę dodawać je do FAQ, ale przynajmniej powinno to pomóc na teraz
- To doda USB jak w opcji 3G - czy widzę tutaj swap? - po prostu wybierz / dev / ttyUSB0 lub tak - sprawdź logi
- Dodatkowe kroki dla kart Huawei
- Nic naprawdę - po prostu upewnij się, że usbserial jest załadowany, a karta pojawi się na / dev / ttyUSB0 - sprawdź logi ponownie, aby potwierdzić
- Jeśli karta nie pojawi się, wyładuj usbserial i załaduj ponownie za pomocą następującego polecenia:
- rmmod usbserial
- modprobe usbserial vendor = 0x12d1 product = 0x1001
- Nadal próbuję pracować na karcie tylko USB, więc w tej chwili nie wiem, czy będzie działać pod Linuksem.
- Huawei E169
- Testowane przez rfree na Debian Wheezy z polskim operatorem Play. Wszystko działa dobrze:
- upewnij się z stat / dev / ttyUSB0 że taki plik urządzenia zostanie (ponownie) utworzony po podłączeniu modemu (i poczekaj 10 sekund), data pliku powinna się zmienić.
- jeśli plik urządzenia nie został utworzony (lub jeśli coś nie działa), zmusić modem do pracy jako modem tylko zamiast czytnika kart / pamięci, używając:
- rmmod usb_storage
- modprobe usbserial vendor = 0x0af0 product = 0x5000 # (lub dostosuj dostawcę i produkt
- numer do tych, które widzisz w dmesg lub lsusb, gdy szukasz swojego modemu)
- skopiuj załączony przykładowy plik wvdial.conf-e169 do /etc/wvdial.conf
- biegać wvdial (zainstaluj wvdial, jeśli go nie masz) - i powinno być zrobione
- Huawei E220
- Odkryłem, że modem działa tylko z dostarczonym krótkim kablem ... nie długim z dwoma wtyczkami ... * wzruszam ramionami *
- Taki sam jak E620, z wyjątkiem użycia następującej komendy modprobe:
- rmmod usb-storage
- modprobe usbserial vendor = 0x12d1 product = 0x1003
- (Niektórzy zgłaszają ID 0x1001 - użyj lsusb do potwierdzenia) Po tym zauważysz, że nadchodzi tylko jeden serial USB, następnie usuń urządzenie i ponownie je załącz, nie powinieneś ponownie wkładać usbserial.
- Uwagi
- Widziałem tylko prędkości 3G na tym urządzeniu, ale myślę, że to ze względu na moje warunki i lokalizację fal radiowych. Więcej na ten temat, aby śledzić ...
- Jak połączyć za pomocą modemu bezprzewodowego Wi-Fi / WAN / mobilnego modemu Franklin U210
- Chociaż ta sekcja wymaga pracy, dokumentuje, w jaki sposób jeden użytkownik Debiana łączy się z Internetem za pośrednictwem sieci komórkowej NTelos w Stanach Zjednoczonych za pomocą modemu USB Franklin CDMA EV-DO U210. NTelos używa sieci Sprint, a ponadto wydaje się, że U210 Franklina jest podstawowym modelem serii U Franklina (U210, U600, U601, U602, U770, U772), więc istnieje dość duża szansa, że możesz użyć tych informacji nawet jeśli twoja sytuacja różni się trochę od sytuacji pisarza - ale, jak mówią, twój przebieg może się różnić.
- Ta rada jest skierowana do początkujących i średnio zaawansowanych użytkowników. Zaawansowani użytkownicy są zachęcani do edycji wiki w celu ulepszenia porady.
- Modem USB firmy Franklin prezentuje się w sieci bezprzewodowej tak, jakby był telefonem komórkowym. Ma numer telefonu. Aby się połączyć, dzwoni inny numer telefonu. W sieci NTelos (i prawdopodobnie także w sieci Sprint) w Stanach Zjednoczonych numer telefonu, który musi posiadać modem USB, to "# 777". Nie musisz, ale prawdopodobnie możesz odkryć swój numer telefonu modemu USB, logując się na swoje konto na stronie internetowej operatora komórkowego. Jedynym numerem, którego potrzebujesz dzisiaj, jest "# 777".
- Jako root lub przez sudo (1) zainstaluj pakiet "wvdial" Debiana, na przykład przez
- $ sudo apt-get install wvdial
- Jeśli zachodzi taka potrzeba, zapisz oryginalny stan pliku /etc/wvdial.conf za pomocą RC (ci) (1) lub podobnego (możesz zignorować tę radę, jeśli nie znasz i nie dbasz o to, co to jest). Zmodyfikuj plik /etc/wvdial.conf, aby wyglądał mniej więcej tak:
- [Domyślne ustawienia dialera]
- Tryb głupi = prawda
- Init1 = ATZ
- Init2 = ATQ0 V1 E1 S0 = 0 i C1 & D2 + FCLASS = 0
- Modem Type = USB Modem
- Baud = 460800
- Nowe PPPD = tak
- Modem = / dev / ttyACM0
- ISDN = 0
- Telefon = # 777
- Hasło = <Twoje hasło>
- Nazwa użytkownika = <Twoja nazwa użytkownika>
- Ważne linie to "Tryb głupi = prawda" i "Telefon = 777". Nie musisz podawać hasła ani nazwy użytkownika.
- Edytuj "/ etc / group" [ponownie po użyciu ci (1) najpierw, jeśli chcesz] zmienić
- dialout: x: 20:
- do
- dialout: x: 20: foo
- wpisując swoją nazwę użytkownika zamiast "foo".
- W tym momencie może być konieczne wylogowanie się i ponowne zalogowanie, aby system (część systemu nie był pewien) rozpoznać, że należysz do grupy "dialout". Jeśli nie masz pewności, sprawdź komendę groups (1).
- Podłącz modem USB, jeśli jeszcze tego nie zrobiłeś. Nie jako root, ale jako użytkownik, podaj polecenie "wvdial" w wierszu poleceń terminala. Jeśli wszystko pójdzie dobrze, powinno to połączyć cię z Internetem przez twoją sieć komórkową. Później naciśnij klawisz <Ctrl-C>, aby rozłączyć.
- Podano, że pakiet "usb-modeswitch" może być niezbędny, jeśli modem USB nie był wcześniej używany. Pisarz nie spotkał się ani nie wypróbował omawianej okoliczności.
- Aby stwierdzić oczywiste: procedura powinna działać tylko wtedy, gdy zapłaciłeś subskrypcję do sieci komórkowej.
- Nie twierdzi się, że procedura była możliwie najłagodniejsza, ale procedura ma zaletę, że jest względnie oczywista w działaniu. Udoskonalony użytkownik może udoskonalić dane.
- FAQ
- Jak włączyć "Udostępnianie połączenia internetowego"?
- A) Ponieważ jądro 2.6 jest głównym strumieniem, itp. Omówię tylko IPTables i Kernel 2.6. Zakładam również, że ppp0 to twój modem, a eth0 to twój lan.
- Po pierwsze - musimy dodać pewne reguły do iptables - uruchom następujące polecenia:
- # Spowoduje to WYCZYŚĆ WSZYSTKIE ZASADY !!!
- iptables -F
- #Włącz NAT (przez interfejs ppp0)
- iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
- # następnie musimy włączyć routing:
- echo "1"> / proc / sys / net / ipv4 / ip_forward
- To powinno zrobić - od tego można dodawać reguły, aby blokować przychodzące połączenia itp.
- Moja karta jest uszkodzona / odpowiada "BŁĄD" na wszystkie polecenia
- A) Nie wysłałeś kodu PIN na kartę - dodaj polecenie "pin" lub wyłącz PIN na karcie SIM
- Moja karta Novatel działa bardzo wolno - +800 razy na sekundę
- A) Spróbuj uruchomić "setserial -a / dev / ttyS1 low_latency spd_warp" - zastąp / dev / ttyS1 swoim portem
- Kiedy już masz polecenie setserial, wstaw je do /etc/ppp/ip-up.local - spowoduje to uruchomienie komendy za każdym razem, gdy połączenie zostanie nawiązane.
- Co oznaczają wszystkie sekcje wvdial?
- Domyślne - co zrobić, jeśli nic nie jest wybrane (zawsze dołączone)
- pin - wyślij swoja pinezkę do karty
- novatel - wybierz kartę novatel
- opcja - wybierz kartę opcji
- hsdpa - Opcja karty HSDPA
- e1000 - wybierz E1000 przez USB
- na pokładzie - wybierz modem pokładowy mojego notebooka
- internet - wybierz APN Internetu
- internetvpn - wybierz APN Internetu
- myapn - wybierz swój apn
- 384k, 144k, 64k - wybierz szybkość połączenia 3G
- 2 gonly - wybierz tylko GPRS
- 3 gonly - wybierz tylko 3G
- Jak mogę zobaczyć użycie pod Linuksem?
- Zadanie Linux
- DO ZROBIENIA
- Niech karta opcji wywoła sama "modprobe usbserial"
- Spraw, aby karta Novatel zarejestrowała drugi port pod Linuksem
- Wykonaj badania poziomów sygnałów zgłoszonych przez + CSQ
- Uzyskaj PIN do pracy z wvdial i Novatel
- #################################################################################
- #################################################################################
- #################################################################################
- HowTo Connect your Laptop to Internet using a Cell Phone via USB or Bluetooth
- In this article I am going to describe how to easily connect your laptop to the internet using your cell phone as a 3G/GPRS modem via bluetooth or USB.
- The procedure has been tested in a Toshiba Satellite Laptop with Debian SID (2.6.26-1-686) and a Nokia N80 Cell Phone connected to the Spanish mobile net Movistar. Surely you must slightly change the parameters given in this paper to make a different connection work...
- It is very important to follow strictly all of the steps related in this article.
- Note: For general information on setting up Bluetooth, also see the page BluetoothUser.
- Pairing your Laptop with your Cell Phone
- First of all, you need to pair your laptop with your cell phone. You need an active internet connection to your laptop in order to download some packages. We will use the kdebluetooth package. Though I myself am a Gnome user, I have found this package very useful. So that let us open a console and type as root:
- # apt-get install kdebluetooth
- This will install the package. After that, just let us type as a normal user:
- $ kbluetooth
- Then a little blue icon will appear on the taskbar...
- If we click on it with the right button of the mouse and choose the option CONFIGURE... ADAPTERS... then we will be able to configure the laptop in order to set it in DISCOVERABLE mode...
- After this, we activate the Bluetooth on the cell phone and try to detect the laptop... Once discovered the laptop on the phone, it will prompt us to enter a numeric password: just type something easy like "123" in case you think there is no security threat... (It is just a one-time password). You will be prompted to repeat the same password on your laptop. To avoid repeating this process each time you pair your laptop with your cell phone, I highly recommend to add the laptop as a trusted device (this is an option easily accessible in the bluetooth menu on the cell phone)... Et voi-là... our devices are just paired!
- Configuring MODEM Parameters
- Now we need to configure the modem parameters of your cell phone.
- First connect the cell phone to the laptop computer with the USB cable... It is important that the cell phone does not lose connectivity at this point, so that it would be useless if you connected your cell phone via USB in the "File Transfer" mode... You need to connect it in a way that the cell phone is still operative. In the case of the Nokia N80 you should choose the "PC-Suite" option...
- And then type as root:
- # apt-get install wvdial
- # wvdialconf
- After doing this, wvdialconf has examined your cell phone and after a successful connection with it has determined the correct parameters of your modem and written it to a file. But now we must tweak this configuration file, so that we type as root:
- # apt-get install gedit
- # gedit /etc/wvdial.conf
- You need to delete the following lines of code:
- Modem Type = USB Modem
- Modem = /dev/ttyACM0
- And you need to add the following lines to the end of the file we are editing in the same order as it appears here:
- New PPPD = yes
- Phone = *99***1#
- Username = MOVISTAR
- Password = MOVISTAR
- Init6= AT+CGDCONT=1,"IP","movistar.es"
- [Dialer usb-scb]
- Modem Type = USB Modem
- Modem = /dev/ttyACM0
- [Dialer blz-scb]
- Modem = /dev/rfcomm0
- Now we save the file without changing name nor location and we are ready. The cell phone modem is completely configured, and we can use it indistinctly via USB or Bluetooth (as you prefer) without changing any parameter...
- Bringing Down the Network
- Before connecting your laptop to your cell phone, we first need to bring down your existing network connection. To do that, we type as root:
- # ifconfig eth0 down
- # mv /etc/resolv.conf /etc/resolv.conf.eth0
- And eth0 is the name of your active network interface. In case you are not sure about the name of your interface, just type as root:
- # ifconfig
- So that all active interfaces will appear...
- DNS settings
- To use the internet, you will need correct DNS settings. Normally, you will automatically get DNS settings when you connect, so you do not need to do anything.
- However, if your cellular network requires it, you may have to set the DNS servers manually. To do this:
- # echo "nameserver 194.179.1.100" > /etc/resolv.conf
- # echo "nameserver 194.179.1.101" >> /etc/resolv.conf
- The examples nameservers are valid only if you are connecting to the Spanish mobile net Movistar... consult your cellular network's documentation for the right settings.
- Connecting via USB
- If you want to connect your laptop to the internet via USB to your cell phone. Just connect the cables and type as root:
- # wvdial usb-scb&
- You are done. You can surf the web, or check your e-mail... ;-)
- Connecting via Bluetooth
- If you want to connect your laptop to the internet via Bluetooth to your cell phone. Just activate bluetooth both in the laptop and the cell phone, and then type as root:
- # hcitool scan
- The following information will appear:
- Scanning...
- 00:11:22:33:44:55 NameDevice
- This is the MAC address and the name assigned to your cell phone Bluetooth device. Now you type as root (using the same MAC address as above):
- # rfcomm connect 0 00:11:22:33:44:55 2&
- After the connection is established, you type as root:
- # wvdial blz-scb&
- You are done. You can surf the web, or check your e-mail... ;-)
- ---------------------------------------------------------------------
- PomocSpisTreści
- Hardware Support
- Installation with PPP and /etc/network/interfaces
- Advanced Installation with WVDial
- For Novatel
- For Option
- Extra Steps for the HSDPA card
- Extra steps for the Novatel U740 Card
- Extra Steps for the Huawei Cards
- Huawei E169
- Huawei E220
- Notes
- How to connect using a Franklin U210 USB wireless/WAN/mobile broadband modem
- FAQ
- TODO
- Resources
- External Links
- Hardware Support
- The following cards/phones works 100% with next scripts/configs:
- BandLuxe C100
- Huawei/E176 (works out of the box)
- Huawei/E169 works without any problems
- Huawei/E220
- Huawei/E620
- Huawei/K3565-Z
- Motorola E1000
- Nokia 6680 (just don't set the speed/service - no 3gonly and 384k configs)
- Nokia N80 (with a nice How-To UseYourCellPhoneAsModem)
- Novatel HSDPA Card
- Novatel Merlin U630
- Option Fusion
- Option HSDPA Card
- Option Quad
- Installation with PPP and /etc/network/interfaces
- This works with Debian Wheezy 7.
- Install the packages netbase, ifupdown, and ppp if you don't have them already:
- apt-get install netbase ifupdown ppp
- Create a file /etc/ppp/peers/gprs with this content:
- user "YOUR_USERNAME"
- connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T YOUR_APN"
- /dev/ttyUSB0
- noipdefault
- defaultroute
- replacedefaultroute
- hide-password
- #lcp-echo-interval 30
- #lcp-echo-failure 4
- noauth
- persist
- #mtu 1492
- #maxfail 0
- #holdoff 20
- usepeerdns
- #Optional, make it always appear as ppp2:
- #unit 2
- Then edit /etc/ppp/chap-secrets and add at the end:
- "YOUR_USERNAME" * "YOUR_PASSWORD"
- Similarly, edit /etc/ppp/pap-secrets and add at the end:
- "YOUR_USERNAME" * "YOUR_PASSWORD"
- Then edit /etc/network/interfaces and add the following:
- auto gprs
- iface gprs inet ppp
- provider gprs
- That's all you need most of the time. The connection will be brought up at boot, you can start it with ifup gprs or stop it with ifdown gprs.
- Advanced Installation with WVDial
- You need to download the new wvdial.conf for the HSDPA stuff to work !!!
- This was originally written for Gentoo Linux which compiles everything from source. As a result of things might be a bit different, but we can work around it. Firstly, we need to get Linux to detect your card, start your PCMCIA services - normally this can be done using (most distros do this for you):
- Before you insert your card, open a console/switch to an open console and as root run the following :
- invoke-rc.d pcmciautils start
- This will allow you to "see" what Linux is doing :
- tail -f /var/log/messages
- Right, now insert your card and you should see some stuff happening. I have included log traces of what the two cards "look" like under /var/log/messages in the attachment section.
- If you see only the option_insert_nousb.txt messages using an option card run the following command:
- modprobe usbserial vendor=0x0af0 product=0x5000
- If you had to run the above command, you will need to save the vmc_g file attached into /etc/modules.d.
- Now we need to find out where your card is - you will see in the messages where the card is - /dev/ttyS* for Novatel or /dev/ttyUSB* for Option:
- find /dev/ | grep ttyS
- Should show /dev/ttyS0 or /dev/ttyS1 for a Novatel Card.
- find /dev/ | grep ttyUSB
- Should show /dev/ttyUSB0 and USB1 and USB2 for an Option Card. (or /dev/tts/ttyUSB0-2 for udev)
- Once we found that, we need to change /etc/wvdial.conf to match your settings, attached is my working wvdial.conf (this one is tested on GSM network Play in Poland, with e169 modem, but uses no specific options so should be very portable). The file is:
- [Dialer Defaults]
- Modem = /dev/ttyUSB0
- Baud = 3600000
- Init1 = ATZ
- Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
- Phone = *99#
- Username = ppp
- Password = ppp
- Ask Password = 0
- Dial Command = ATDT
- Stupid Mode = 1
- Compuserve = 0
- Idle Seconds = 0
- ISDN = 0
- Auto DNS = 1
- It is possible to set the PIN that is sent to modem to unlock SIM card, how ever this example does not use this option (you should search for it). Some SIM cards do not need the PIN to work as modems.
- Now we can start dialing up.
- For Novatel
- wvdial novatel internet 3gonly 384k
- For Option
- wvdial option internet 3gonly 384k
- If you need to send your PIN, add "pin" infront of all the commands, e.g.
- wvdial pin novatel internet 3gonly 384k
- Once your connection is up - surf away Now you can setup things like KPPP and Gnome's Modem Lights to do your dialing for you.
- Extra Steps for the HSDPA card
- Download the kernel module from the link below. Extract it to a directory somewhere safe.
- Compile the driver using the following commands:
- make clean && make
- Once this is done, run the following command to insert the module into the kernel
- insmod nozomi.ko
- Once you have done that, use the following command to setup the connection:
- wvdial hsdpa
- Extra steps for the Novatel U740 Card
- Until I get time to update the files etc. our Novatel Linux Users out there can just type this command before using the normal dialing command:
- modprobe usbserial vendor=0x1410 product=0x1400
- OR
- modprobe usbserial vendor=0x1410 product=0x1410
- Using lsusb will show you the Vendor and Product ID's or cat /proc/bus/usb/devices will do the same.I will still add them into the FAQ but at least this should help for now
- This will add the USB's like the 3G Option did - am I seeing a swap here ? - so just dial /dev/ttyUSB0 or so - check the logs
- Extra Steps for the Huawei Cards
- None really - just make sure usbserial is loaded and the card will come up on /dev/ttyUSB0 - check the logs again to confirm
- If the card doesn't come up, unload usbserial and reload with the following command:
- rmmod usbserial
- modprobe usbserial vendor=0x12d1 product=0x1001
- I am still trying to work on the USB only card, so at the moment, I don't know if it will work under Linux.
- Huawei E169
- Tested by rfree on Debian Wheezy with Polish operator Play. All works well:
- make sure with stat /dev/ttyUSB0 that such device-file is (re)created when you connect the modem (and wait 10 seconds), the date of file should change.
- if device-file is not created (or if something does not work) then force the modem to work as modem only instead as card-reader/memory, using:
- rmmod usb_storage
- modprobe usbserial vendor=0x0af0 product=0x5000 # (or adjust vendor and product
- number to the ones you see in dmesg or lsusb when you look for your modem)
- copy the attached example file wvdial.conf-e169 to /etc/wvdial.conf
- run wvdial (install wvdial if you don't have it) - and should be done
- Huawei E220
- I have found that this modem will only work with the short cable supplied...not the long one with two plugs...*shrug*
- Same as the E620, except use the following modprobe command:
- rmmod usb-storage
- modprobe usbserial vendor=0x12d1 product=0x1003
- (Some have reported an ID of 0x1001 - use lsusb to confirm) After that, you will notice only one USB serial coming up, then, remove the device and re-attach it, you shouldn't need to re-insert usbserial.
- Notes
- I have only seen 3G speeds on this device, but I think it is because of my RF conditions and location. More on this to follow...
- How to connect using a Franklin U210 USB wireless/WAN/mobile broadband modem
- Though this section needs work, it documents how one Debian user connects to the Internet over NTelos' cellular network in the United States using a Franklin CDMA EV-DO U210 USB modem. NTelos uses Sprint's network, and moreover it would appear that Franklin's U210 is the base model of Franklin's U-series (U210, U600, U601, U602, U770, U772), so there is a reasonably good chance that you can use this information even if your situation differs somewhat from the writer's -- but, as they say, your mileage may vary.
- This advice is targeted to the beginning-to-intermediate user. Advanced users are challenged to edit the wiki to improve the advice.
- Your Franklin USB modem presents itself to the wireless network as though it were a cell phone. It has a phone number. To connect, it calls another phone number. On NTelos' (and presumably also on Sprint's) network in the United States, the phone number your USB modem must call is "#777". You need not, but probably can, discover your USB modem's own phone number by logging into your account on your cellular provider's website. The only number you need today however is the "#777".
- As root or via sudo(1), install the Debian package "wvdial", for instance by
- $ sudo apt-get install wvdial
- If desired, save the original state of /etc/wvdial.conf using RCS's ci(1) or the like (you can ignore this advice re RCS if you neither know nor care what it is about). Edit /etc/wvdial.conf to look something like this:
- [Dialer Defaults]
- Stupid Mode = true
- Init1 = ATZ
- Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
- Modem Type = USB Modem
- Baud = 460800
- New PPPD = yes
- Modem = /dev/ttyACM0
- ISDN = 0
- Phone = #777
- Password = <Your Password>
- Username = <Your Login Name>
- The important lines are the "Stupid Mode = true" and the "Phone = #777". You need not fill in a password or username.
- Edit "/etc/group" [again after using ci(1) first if you wish] to change
- dialout:x:20:
- to
- dialout:x:20:foo
- typing your username in place of "foo".
- At this point, you may need to log out and log back in to get the system (which part of the system? not sure) to recognize that you now belong to the "dialout" group. If unsure, check with the groups(1) command.
- Plug in your USB modem if you have not already done so. Not as root but as yourself, give the command "wvdial" at the terminal's command line. If all goes well, this should connect you to the Internet over your cellular network. Later, press <Ctrl-C> to disconnect.
- One is given to understand that the "usb-modeswitch" package may be necessary if your USB modem has not been used before. The writer has neither met nor tested the circumstance in question.
- To state the obvious: the procedure should be expected to work only if you have paid a subscription to the cellular network.
- It is not asserted that the procedure were the smoothest possible, but the procedure does have the virtue of being relatively obvious in its operation. Refinements may occur to the interested user.
- FAQ
- How do I enable "Internet Connection Sharing" ?
- A) Since the 2.6 kernel is main stream etc. I will only cover IPTables and Kernel 2.6. I am also assuming that ppp0 is your dialup and eth0 is your lan.
- Firstly - we need to add some rules to iptables - run the following commands:
- #This will CLEAR ALL RULES !!!
- iptables -F
- #Enable NAT (through the ppp0 interface)
- iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
- #then we need to enable routing:
- echo "1" > /proc/sys/net/ipv4/ip_forward
- That should do it - from here you can add rules to block incomming connections etc.
- My card is broken/replies "ERROR" to all the commands
- A) You didn't send your PIN to the card - either add the "pin" command or disable the PIN on the SIM
- My Novatel card is very slow - +-800 bytes per second
- A) Try running "setserial -a /dev/ttyS1 low_latency spd_warp" - replace /dev/ttyS1 with your port
- Once you have your setserial command, insert it into /etc/ppp/ip-up.local - this will cause the command to be ran everytime a connection is made.
- What does all the wvdial sections do/mean ?
- Defaults - What to do if nothing is selected (Always included)
- pin - send your pin to the card
- novatel - select the novatel card
- option - select the option card
- hsdpa - Option HSDPA card
- e1000 - select the E1000 via USB
- onboard - select the onboard modem of my notebook
- internet - select the internet APN
- internetvpn - select the internetvpn APN
- myapn - select your apn
- 384k,144k,64k - select the speed of your 3G connection
- 2gonly - select GPRS only
- 3gonly - select 3G only
- How do I see the usage under Linux ?
- ToDo Linux Usage
- TODO
- Make the Option card call "modprobe usbserial" by itself
- Make the Novatel card register the second port under Linux
- Do some research into the signal levels reported via +CSQ
- Get the PIN to work with wvdial and Novatel
- Resources
- Modem/3G/Cards
- Modem/3G/FAQ
- Modem/3G/Vodafone
- External Links
- http://www.peck.org.uk/GlobeTrotterGPRShowto.html - GPRS HowTo
- Vodafone_Mobile_Connect_USB_Modem
- http://markus.wernig.net/en/it/usb-serial-handy-ppp.phtml - How to connect a cell phone via USB to a Linux laptop and dial-up an internet connection.
- Hardware | Modem
- Modem/3G (ostatnio modyfikowane 2018-02-01 16:12:30)
- MoinMoin PoweredPython PoweredDebian Wiki team, bugs and config available.Hosting provided by Metropolitan Area Network Darmstadt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement