Static IP Address for Raspbian: Difference between revisions

From KlavoWiki
Jump to navigationJump to search
No edit summary
Line 73: Line 73:
<pre>
<pre>
static domain_name_servers=2001:4860:4860::8888 2001:4860:4860::8844
static domain_name_servers=2001:4860:4860::8888 2001:4860:4860::8844
</pre>
= VLAN =
== Load 8021q Module ==
<pre>
vi /etc/modules
</pre>
Add the line
<pre>
8021q
</pre>
== Create Interface ==
Define a VLAN for a specific interface.
<pre>
vi /etc/network/interfaces
</pre>
<pre>
# VLAN 101 Interface
auto eth0.101
iface eth0.101 inet manual
    vlan-raw-device eth0
</pre>
== Assign IP Address ==
Set a static IP for new interface
<pre>
vi /etc/dhcpcd.conf
</pre>
<pre>
# Static IP configuration for VLan.10
interface eth0.101
static ip_address=192.168.1.101/24
</pre>
</pre>


[[Category : Raspbian]]
[[Category : Raspbian]]

Revision as of 00:00, 23 November 2018

interfaces

make sure the interfaces file has not been modified.

vi /etc/network/interfaces

The default settings are:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

dhcpcd.conf

vi /etc/dhcpcd.conf

Append the following. The entry of static will stop the server looking for an IP address from DHCP.

interface eth0
static ip_address=192.168.13.200/24
static routers=192.168.13.1
static domain_name_servers=8.8.8.8 8.8.4.4
static domain_search=mydomain.com ap.mydomain.com

Alias

Temporary

To create a temporary alias rather than a permanent one you can issue the following command from the CLI.

ifconfig eth0:0 192.168.22.1/24

IPv6

I haven't figured out a way for this to work with configuration file dhcpcd.conf.

vi /etc/network/interfaces
auto eth0
iface eth0 inet6 static
address 2321:3fa4:4f7a:d100::1234
netmask 56
gateway 2321:3fa4:4f7a:d100::ffff

Edit dhcpcd.conf for name servers

vi /etc/dhcpcd.conf
static domain_name_servers=2001:4860:4860::8888 2001:4860:4860::8844

VLAN

Load 8021q Module

vi /etc/modules

Add the line

8021q

Create Interface

Define a VLAN for a specific interface.

vi /etc/network/interfaces
# VLAN 101 Interface
auto eth0.101
iface eth0.101 inet manual
    vlan-raw-device eth0

Assign IP Address

Set a static IP for new interface

vi /etc/dhcpcd.conf
# Static IP configuration for VLan.10
interface eth0.101
static ip_address=192.168.1.101/24