Linux Networking

From MK Wiki EN
Revision as of 06:01, 2 September 2019 by MkWikiEnSysOp (talk | contribs) (Initial creation: add address, gateway, forwarding)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Some important commands and settings that are needed frequently.

Add IPv4/IPv6 address to interface

In the past, ifconfig was used to add ip addresses. Nowadays, the ip command is used instead.

ip [-6] a a address dev iface

Examples:

ip a a 10.0.0.1 dev enp2s0
ip -6 a a fd40:cafe:affe:1234::1 dev enp0s3

Set default IPv6 gateway

ip -6 r a gateway dev iface

gateway must not be a link local address (that is one that starts with "fe80")!

IPv6 forwarding

Query:

sysctl net.ipv6.conf.all.forwarding

Or using procfs:

cat /proc/sys/net/ipv6/conf/all/forwarding

Activating:

sysctl -w net.ipv6.conf.all.forwarding=1

Remark: "all" can be substituted by any network interface on the system, for example, cat /proc/sys/net/ipv6/conf/eth0/forwarding prints the value for interface "eth0".