{{tag>[linux serial ethernet]}} =====Serial<->Ethernet convertor===== * OS: CentOS 6.5 * Hardware: PC Engines APU This proof of concept is a serial-to-ethernet converter. It uses one IP-address per serial port, not an IP port. ^ IP address ^ IP Port ^ serial connection ^ | 192.168.100.101 | 22 | ntp2 server | | 192.168.100.102 | 22 | kvm host | | 192.168.100.103 | 22 | nas | ====Configure virtual IP addresses==== * Create **/etc/sysconfig/network-scripts/ifcfg-eth0:0** DEVICE="eth0:0" BOOTPROTO="none" ONBOOT="yes" IPADDR="192.168.100.101" NETMASK="255.255.255.0" * Create **/etc/sysconfig/network-scripts/ifcfg-eth0:1** DEVICE="eth0:0" BOOTPROTO="none" ONBOOT="yes" IPADDR="192.168.100.102" NETMASK="255.255.255.0" * Create **/etc/sysconfig/network-scripts/ifcfg-eth0:2** DEVICE="eth0:0" BOOTPROTO="none" ONBOOT="yes" IPADDR="192.168.100.103" NETMASK="255.255.255.0" * Restart networking service network restart ====Install and configure dropbear==== * Install dropbear from EPEL repository: yum install dropbear * Make sure dropbear does not start automaticly chkconfig dropbear off * Generate host keys. /usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key /usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key /usr/bin/dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key * Configure default OpenSSH daemon to listen only on management port. Edit **/etc/ssh/sshd_config** ListenAddress 192.168.100.99 * Restart OpenSSH service. service sshd restart ====Install and configure minicom==== * Install minicom: yum install minicom * Create NTP2 server config. **/etc/minirc.ntp2**pu port /dev/ttyUSB0 pu minit pu mreset pu mhangup * KVM server config. Create **/etc/minirc.kvm**pu port /dev/ttyUSB1 pu minit pu mreset pu mhangup * NAS config. Create **/etc/minirc.nas** pu port /dev/ttyUSB2 pu minit pu mreset pu mhangup ====Create login script==== * Create **/usr/local/bin/serial.sh** #!/bin/bash #disable ctrl-c ctrl-z trap '' 2 20 connectto=`echo $SSH_CONNECTION | cut -d " " -f3` case $connectto in 192.168.42.27) /usr/bin/minicom ntp2 ;; 192.168.42.28) echo "naar 28" ;; *) echo "Connection problem to $connectto" exit 1 ;; esac * Make it executable chmod +x /usr/local/bin/serial.sh * Add the script to **/etc/shells**. ====Create user==== * Add user serial: useradd -G dialout -s /usr/local/bin/serial.sh serial * Enter password: passwd serial ====Start SSH services==== You can also start a separate dropbear process per IP address. * Start dropbear SSHd services. /usr/sbin/dropbear -g -p 192.168.100.101:22 -p 192.168.100.102:22 -p 192.168.100.103:22 ====Test==== * Log in to the virtual IP addresses with user serial and test serial connections.