enp2s0에 modbusTCP 통신할 모듈과 연결 하기 위함
모듈의 ip 169.254.111.111
게이트웨이 169.254.111.1
sudo vi /etc/network/interfaces
#interfaces(5) file used by ifup(8) and ifdown(8)
#auto lo #지워준다
#iface lo inet loopback #지워준다
auto enp1s0
iface enp1s0 inet dhcp
#이더넷 인터페이스
auto enp2s0
#enps2s0 인터페이스를 고정
iface enp2s0 inet static
address 169.254.111.222
netmask 255.255.255.0
broadcast 169.254.111.255
#gateway 169.254.111.1 #있으면 라우터 충돌남
dns-nameservers 8.8.8.8
#-------------------------------------------------------------
up route add -net 169.254.0.0 netmask 255.255.255.0 dev enp2s0
#up route add -net 172.16.0.0 netmask 255.255.255.0 default gw 172.16.100.100 dev enp1s0
네트워크 재시작
sudo systemctl restart networking.service
위의 설정 중 윗 분할 부분만 설정하면 인터넷만 되고 모듈과는 아직 통신이 되지 않는다
왜냐하면 모든 요청이 enp1s0 포트를 통해서만 요청하기 때문.
따라서, 아래 분할을 추가하여 특정 IP로 갈때는 enp2s0포트를 사용하도록 변경
현재의 라우팅 테이블 확인
sudo route -n
참고 네트워크 상태확인
sudo lshw -class network
sudo ip link set dev enp2s0 up