Ubuntu networking: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
m (Text replacement - "<source" to "<syntaxhighlight")
m (Text replacement - "</source" to "</syntaxhighlight")
Line 10: Line 10:
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
</source>
</syntaxhighlight>


===Activate /etc/sysctl.d/60-disable-ipv6.conf===
===Activate /etc/sysctl.d/60-disable-ipv6.conf===
Line 18: Line 18:
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
</source>
</syntaxhighlight>


===Check settings===
===Check settings===
Line 24: Line 24:
# cat /proc/sys/net/ipv6/conf/all/disable_ipv6
# cat /proc/sys/net/ipv6/conf/all/disable_ipv6
1
1
</source>
</syntaxhighlight>


==The ip command==
==The ip command==
Line 36: Line 36:
# mygateway=172.16.78.1
# mygateway=172.16.78.1
# declare -a mynameservers=( 172.16.77.4 172.16.79.4 )
# declare -a mynameservers=( 172.16.77.4 172.16.79.4 )
</source>
</syntaxhighlight>


Create the bonding interface out of the two masters
Create the bonding interface out of the two masters
Line 46: Line 46:
# ip link set ${mymaster2} down
# ip link set ${mymaster2} down
# ip link set ${mymaster2} master ${myinterface}
# ip link set ${mymaster2} master ${myinterface}
</source>
</syntaxhighlight>


If you want to add a VLAN to your interface
If you want to add a VLAN to your interface
Line 53: Line 53:
# ip link add link ${myinterface} name ${myinterface}.${myvlan} type vlan id ${myvlan}
# ip link add link ${myinterface} name ${myinterface}.${myvlan} type vlan id ${myvlan}
# myinterface=${myinterface}.${myvlan}
# myinterface=${myinterface}.${myvlan}
</source>
</syntaxhighlight>


Bring your interface up and set yout ip address
Bring your interface up and set yout ip address
Line 59: Line 59:
# ip link set ${myinterface} up
# ip link set ${myinterface} up
# ip addr add ${myipaddr} dev ${myinterface}
# ip addr add ${myipaddr} dev ${myinterface}
</source>
</syntaxhighlight>


Set your default gateway and DNS
Set your default gateway and DNS
Line 65: Line 65:
# ip route add default via ${mygateway}
# ip route add default via ${mygateway}
# if (( ${#mynameservers[*]} > 1 )) ; then eval systemd-resolve --interface ${myinterface} --set-dns={$(IFS=,; printf '%s' "${mynameservers[*]}")} ; else eval systemd-resolve --interface ${myinterface} --set-dns=${mynameservers[0]} ; fi
# if (( ${#mynameservers[*]} > 1 )) ; then eval systemd-resolve --interface ${myinterface} --set-dns={$(IFS=,; printf '%s' "${mynameservers[*]}")} ; else eval systemd-resolve --interface ${myinterface} --set-dns=${mynameservers[0]} ; fi
</source>
</syntaxhighlight>


===ipa===
===ipa===
Line 71: Line 71:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
# ip a
# ip a
</source>
</syntaxhighlight>
shows you the configured addresses.
shows you the configured addresses.
It is the short cut for "ip address show".
It is the short cut for "ip address show".
Line 79: Line 79:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
# ip li sh up
# ip li sh up
</source>
</syntaxhighlight>
shows you all links (interfaces) that are up.  
shows you all links (interfaces) that are up.  
This is short for "ip link show up".
This is short for "ip link show up".
Line 92: Line 92:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
# netplan appy
# netplan appy
</source>
</syntaxhighlight>
Keep in mind: You might lose your connection depending on the changes made!
Keep in mind: You might lose your connection depending on the changes made!


Line 103: Line 103:
       dhcp4: yes
       dhcp4: yes
   version: 2
   version: 2
</source>
</syntaxhighlight>


====Bonding====
====Bonding====
Line 138: Line 138:
             - "192.168.3.60"
             - "192.168.3.60"
             - "192.168.3.61"
             - "192.168.3.61"
</source>
</syntaxhighlight>

Revision as of 02:06, 26 November 2021

Networking Networking

Disable IPv6

Create /etc/sysctl.d/60-disable-ipv6.conf

Create a file named /etc/sysctl.d/60-disable-ipv6.conf with this content:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Activate /etc/sysctl.d/60-disable-ipv6.conf

# sysctl -p /etc/sysctl.d/10-disable-ipv6.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Check settings

# cat /proc/sys/net/ipv6/conf/all/disable_ipv6
1

The ip command

Configure bond manually

Specify your environment

# mymaster1=eno5
# mymaster2=eno6
# myinterface=bond007
# myipaddr=172.16.78.9/24
# mygateway=172.16.78.1
# declare -a mynameservers=( 172.16.77.4 172.16.79.4 )

Create the bonding interface out of the two masters

# ip link add ${myinterface} type bond
# ip link set ${myinterface} type bond miimon 100 mode active-backup
# ip link set ${mymaster1} down
# ip link set ${mymaster1} master ${myinterface}
# ip link set ${mymaster2} down
# ip link set ${mymaster2} master ${myinterface}

If you want to add a VLAN to your interface

# myvlan=1234
# ip link add link ${myinterface} name ${myinterface}.${myvlan} type vlan id ${myvlan}
# myinterface=${myinterface}.${myvlan}

Bring your interface up and set yout ip address

# ip link set ${myinterface} up
# ip addr add ${myipaddr} dev ${myinterface}

Set your default gateway and DNS

# ip route add default via ${mygateway}
# if (( ${#mynameservers[*]} > 1 )) ; then eval systemd-resolve --interface ${myinterface} --set-dns={$(IFS=,; printf '%s' "${mynameservers[*]}")} ; else eval systemd-resolve --interface ${myinterface} --set-dns=${mynameservers[0]} ; fi

ipa

This is not only indian pale ale! On linux

# ip a

shows you the configured addresses. It is the short cut for "ip address show".

iplishup

This just sounds like a word and helps you to keep it in mind.

# ip li sh up

shows you all links (interfaces) that are up. This is short for "ip link show up".

New since Ubuntu 17.10

netplan

Former configuration in /etc/network/interfaces{,.d} is now found in /etc/netplan in YAML syntax. The name of the file is /etc/netplan/<whatever you want, I prefer the interface name>.yaml . The .yaml at the end is not optional!

netplan <command>

To apply changes to your files in /etc/netplan without reboot use:

# netplan appy

Keep in mind: You might lose your connection depending on the changes made!

DHCP

/etc/netplan/ens160.yaml

network:
  ethernets:
    ens160:
      dhcp4: yes
  version: 2

Bonding

/etc/netplan/bond007.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    slave1:
      match:
        macaddress: "3c:a7:2a:22:af:70"
      dhcp4: no
    slave2:
      match:
        macaddress: "3c:a7:2a:22:af:71"
      dhcp4: no
  bonds:
    bond007:
      interfaces:
        - slave1
        - slave2
      parameters:
        mode: balance-rr
        mii-monitor-interval: 10
      dhcp4: no
      addresses:
        - 192.168.189.202/27
      gateway4: 192.168.189.193
      nameservers:
          search: 
            - mcs.de
          addresses:
            - "192.168.3.60"
            - "192.168.3.61"