리눅스 네트워크 설정
- 네트워크 매니저 제거 : 네트워크 자동 관리 기능을 제거하는 것
- sudo apt-get remove -y –purge network-manager
- 네트워크 설정
- ifconfig : 현재 시스템에 설치된 네트워크 interface 설정 확인
123456789101112131415161718whan@whan-VirtualBox:~$ ifconfigenp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255inet6 fe80::6eba:4919:3101:7ffa prefixlen 64 scopeid 0x20<link>ether 08:00:27:a3:39:93 txqueuelen 1000 (Ethernet)RX packets 2573 bytes 2257942 (2.2 MB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 1176 bytes 87318 (87.3 KB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 242 bytes 16464 (16.4 KB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 242 bytes 16464 (16.4 KB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0- HWaddr : 네트워크 인터페이스의 하드웨어 주소(MAC Address)
- inet addr/inet : 네트워크 인터페이스에 할당된 IPv4 주소
- inet6 addr/inet6 : 네트워크 인터페이스에 할당된 IPv6 주소
- Bcast/broadcase : 브로드캐스트 주소
- Mask/netmask : 넷마스크
- RX : 받은
- TX : 보낸
- collisions : 충돌된
- ifconfig enp0s3 down : enp0s3 인터페이스를 종료
12345678910whan@whan-VirtualBox:~$ sudo ifconfig enp0s3 downwhan@whan-VirtualBox:~$ ifconfiglo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 231 bytes 18225 (18.2 KB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 231 bytes 18225 (18.2 KB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - ifconfig enp0s3 up : enp0s3 인터페이스를 실행
12345678910111213141516171819whan@whan-VirtualBox:~$ sudo ifconfig enp0s3 10.0.2.16 upwhan@whan-VirtualBox:~$ ifconfigenp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.2.16 netmask 255.255.255.0 broadcast 10.0.2.255inet6 fe80::99c1:d102:cc:5dac prefixlen 64 scopeid 0x20<link>ether 08:00:27:e8:d7:fb txqueuelen 1000 (Ethernet)RX packets 5902 bytes 5032086 (5.0 MB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 2841 bytes 273048 (273.0 KB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 231 bytes 18225 (18.2 KB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 231 bytes 18225 (18.2 KB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0- 재부팅하기 전까지는 IP가 10.0.2.16으로 설정됨
- 재부팅하면 다시 10.0.2.15로 수정됨
- PuTTY로 원격 접속하기 위해서는
- 장치 -> 네트워크 -> 네트워크설정->고급->고급포워딩에서 IP 10.0.2.15를 10.0.2.16으로 수정
- 장치 -> 네트워크 -> 네트워크 어댑터 연결을 해제 후 재 선택해야 함
- 재부팅하기 전까지는 IP가 10.0.2.16으로 설정됨
- /etc/network/interfaces : 네트워크 설정 파일(IPv4 설정)
12345auto lo#iface lo inet loopbackauto eth0iface eth0 inet dhcp
123456789auto lo#iface lo inet loopbackauto eth0iface eth0 inet staticaddress 192.168.0.3netmask 255.255.255.0gateway 192.168.0.1dns-nameservers 202.31.224.3
- ifconfig : 현재 시스템에 설치된 네트워크 interface 설정 확인
- 기타 네트워크 관련 명령어
- ifdown eth0 : 인터페이스 eth0 down
- ifup eth0 : 인터페이스 eth0 up
- iwconfig : 현재 시스템에 설치된 무선 네트워크 설정 확인
- ifconfig wlan0 up : 무선 네트워크 wlan0 활성화
- iwlist wlan0 scan : 무선 AP 검색
- 네트워크 상태 확인
- ping IP주소 : 통신 확인
- 요즘은 ping에 응답하지 않는 컴퓨터가 많음
- traceroute IP주소 : 통신 경로 확인
12345678910111213141516whan@whan-VirtualBox:~$ traceroute www.jj.ac.krtraceroute to www.jj.ac.kr (202.31.240.51), 30 hops max, 60 byte packets1 192.168.0.1 (192.168.0.1) 3.131 ms 3.171 ms 4.071 ms2 192.168.219.1 (192.168.219.1) 11.578 ms 11.697 ms 11.665 ms3 * * *4 * * *5 * * *6 1.213.139.109 (1.213.139.109) 17.006 ms 1.208.139.109 (1.208.139.109) 7.052 ms 1.213.139.109 (1.213.139.109) 7.260 ms7 1.213.99.157 (1.213.99.157) 7.448 ms 1.208.139.149 (1.208.139.149) 7.513 ms 1.213.99.1 (1.213.99.1) 8.501 ms8 1.213.107.169 (1.213.107.169) 13.825 ms 1.208.146.85 (1.208.146.85) 14.221 ms 1.208.144.81 (1.208.144.81) 13.969 ms9 203.233.17.110 (203.233.17.110) 9.462 ms 12.149 ms 1.208.148.86 (1.208.148.86) 12.166 ms10 211.53.1.246 (211.53.1.246) 12.164 ms 128.134.10.129 (128.134.10.129) 12.982 ms 211.170.3.210 (211.170.3.210) 13.464 ms11 * * *12 112.174.122.86 (112.174.122.86) 18.030 ms 112.174.18.222 (112.174.18.222) 13.758 ms 15.397 ms13 * * *14 211.230.172.58 (211.230.172.58) 13.655 ms 14.850 ms 15.579 ms - netstat -na : 네트워크 상태 정보 출력
123456789whan@whan-VirtualBox:~$ netstat -naActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address Statetcp 0 0 127.0.0.53:53 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:22 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:631 0.0.0.0:* LISTENtcp 0 0 10.0.2.15:22 10.0.2.2:11925 ESTABLISHEDtcp6 0 0 :::22 :::* LISTENtcp6 0 0 ::1:631 :::* LISTEN - tcpdump : 네트워크 상의 트래픽 덤프
- ping IP주소 : 통신 확인