-
Notifications
You must be signed in to change notification settings - Fork 1
/
3. Linux Networking
68 lines (49 loc) · 2.64 KB
/
3. Linux Networking
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Networking commands:
ping
traceroute = must be installed via sudo apt-get install traceroute
ifconfig = display information for only one interface at a time. Also, ifconfig can be used to assign an IP address, shut and activate an interface, hardcode a MAC address, or even set the MTU of the interface
e.g: ifconfig
ifconfig interfacename up|down = shuts / unshuts an interface
ip link = similar to ifconfig, more powerful. ifconfig will be decommed soon, repalced by ip link. shows each interface w/o inet address assigned to it
ip addr list = shows list of interfaces with inet ip addresses assigned to it
ip addr = assigns an ip to an interface. this assigment is not persistent, meaning it will be gone after a reboot
e.g: sudo ip addr { add | del } a.b.c.d/yz dev <interface>
ip route = creates a non-persistent static route
e.g: sudo ip route { add | del } 172.16.10.0/24 via 192.168.200.50 dev eth1 (eth1 is egress interface)
ifup/ifdown = up/down an interface
e.g: sudo ifup lo
netstat:
netstat = displays local computer’s connection information, routing table information
netstat -r = displays routing table
netstat -i = displays interface statistics
e.g: netstat -i lo
dig = displays DNS info such as A, MX and CNAMES records. e.g: dig gmail.com
host = resolves host to ip and lists MX, CNAMES associated with name queried. e.g: host gmail.com
ssh = i think we all know what it does :)
e.g: ssh 192.168.1.1 (uses username associated with current terminal)
ssh [email protected] -p 2222
ssh –l john 192.168.1.1
# Viewing routing and ARP tables:
ip route list = shows local route table. cleaner output than netstat -r and becoming the Linux standard. can be used to add/del routes
route = same as ip route list
arp = shows local arp table and assign static arp
# Persistent network configuration:
changing ip information:
persistent network configs are added to the interfaces file under /etc/network. nano /etc/network/interfaces
e.g:
auto eth0
iface eth0 inet static
address 192.168.1.50
netmask 255.255.255.0
up ip route add 172.16.10.0/24 via 192.168.1.25 dev eth2
up ip route add 10.10.10.0/24 via 192.168.1.35 dev eth3
auto eth1
iface eth1 inet dhcp
# Changing DNS information:
persistent DNS configs are stored in the resolv.conf file under /etc/ (nano /etc/resolv.conf), dynamically constructed from files located in: /etc/resolvconf/resolv.conf.d/
To manually add a DNS entry:
add 'nameserver 127.0.1.1' to etc/resolvconf/resolv.conf.d
run sudo resolvconf -u to instruct Linux to update resolv.conf from resolv.conf.d
Restarting network service:
must be done after changing an ip, mask, GW or adding additional interfaces
run sudo service networking restart